@@ -1887,148 +1887,180 @@ <h4><a href="#/analytics/events/key/{{encodeURIComponent this.name}}">{{this.nam
1887
1887
1888
1888
< script > Backbone . history . start ( ) ; </ script >
1889
1889
< % if (!offline_mode) { %>
1890
- < % if (!track || track == "GA" && member['global_admin'] || track == "noneGA" && !member['global_admin']) { %>
1891
- <!--Countly script-->
1892
- < script type ='text/javascript ' src ='<%- cdn %>sdk/web/countly.min.js?<%= countlyVersion %> '> </ script >
1893
- < script type ='text/javascript '>
1894
-
1895
- Countly . getViewName = function ( ) {
1896
- var view = "/dashboard#" ;
1897
- var fragment = Backbone . history . getFragment ( ) ;
1898
- var parts = fragment . split ( "/" ) ;
1899
- if ( fragment . indexOf ( "/analytics/retention/" ) === 0 ) {
1900
- parts [ 4 ] = ":event" ;
1901
- }
1902
- if ( fragment . indexOf ( "/attribution/" ) === 0 ) {
1903
- parts [ 2 ] = ":campaign_id" ;
1904
- }
1905
- for ( var i = 1 ; i < parts . length ; i ++ ) {
1906
- if ( / \d / . test ( parts [ i ] ) ) {
1907
- parts [ i ] = ":id" ;
1908
- }
1909
- if ( parts [ i ] [ 0 ] === "{" ) {
1910
- parts [ i ] = ":query" ;
1911
- }
1890
+ <!--Countly script-->
1891
+ < script type ='text/javascript ' src ='<%- cdn %>sdk/web/countly.min.js?<%= countlyVersion %> '> </ script >
1892
+ < script type ='text/javascript '>
1893
+
1894
+ Countly . getViewName = function ( ) {
1895
+ var view = "/dashboard#" ;
1896
+ var fragment = Backbone . history . getFragment ( ) ;
1897
+ var parts = fragment . split ( "/" ) . slice ( 0 , 3 ) ;
1898
+ if ( fragment . indexOf ( "/attribution/" ) === 0 ) {
1899
+ parts [ 2 ] = ":campaign_id" ;
1900
+ }
1901
+ if ( fragment . indexOf ( "/users/" ) === 0 && parts . length === 3 ) {
1902
+ parts [ 2 ] = ":user_id" ;
1903
+ }
1904
+ for ( var i = 1 ; i < parts . length ; i ++ ) {
1905
+ if ( / \d / . test ( parts [ i ] ) ) {
1906
+ parts [ i ] = ":id" ;
1912
1907
}
1913
- return view + parts . join ( "/" ) ;
1914
- } ;
1915
-
1916
- Countly . getViewUrl = function ( ) {
1917
- var view = "/dashboard#" ;
1918
- var fragment = Backbone . history . getFragment ( ) ;
1919
- var parts = fragment . split ( "/" ) ;
1920
- if ( fragment . indexOf ( "/analytics/retention/" ) === 0 ) {
1921
- parts [ 4 ] = "[CLY]_session" ;
1908
+ if ( parts [ i ] [ 0 ] === "{" ) {
1909
+ parts [ i ] = ":query" ;
1922
1910
}
1923
- if ( fragment . indexOf ( "/attribution/" ) === 0 ) {
1924
- parts [ 2 ] = "" ;
1911
+ }
1912
+ return view + parts . join ( "/" ) ;
1913
+ } ;
1914
+
1915
+ Countly . getViewUrl = function ( ) {
1916
+ var view = "/dashboard#" ;
1917
+ var fragment = Backbone . history . getFragment ( ) ;
1918
+ var parts = fragment . split ( "/" ) . slice ( 0 , 3 ) ;
1919
+ if ( fragment . indexOf ( "/attribution/" ) === 0 ) {
1920
+ parts [ 2 ] = "" ;
1921
+ }
1922
+ if ( fragment . indexOf ( "/users/" ) === 0 && parts . length === 3 ) {
1923
+ parts [ 2 ] = "" ;
1924
+ }
1925
+ for ( var i = 1 ; i < parts . length ; i ++ ) {
1926
+ if ( / \d / . test ( parts [ i ] ) ) {
1927
+ parts [ i ] = "" ;
1925
1928
}
1926
- for ( var i = 1 ; i < parts . length ; i ++ ) {
1927
- if ( / \d / . test ( parts [ i ] ) ) {
1928
- parts [ i ] = "" ;
1929
- }
1930
- if ( parts [ i ] [ 0 ] === "{" ) {
1931
- parts [ i ] = "{}" ;
1932
- }
1929
+ if ( parts [ i ] [ 0 ] === "{" ) {
1930
+ parts [ i ] = "{}" ;
1933
1931
}
1934
- return view + parts . join ( "/" ) ;
1935
- } ;
1932
+ }
1933
+ return view + parts . join ( "/" ) ;
1934
+ } ;
1936
1935
1937
- if ( countlyGlobal . countly_tracking ) {
1938
- var domain = countlyGlobal . countly_domain ;
1936
+ if ( countlyGlobal . countly_tracking ) {
1937
+ var domain = countlyGlobal . countly_domain ;
1939
1938
1940
- try {
1941
- // try to extract hostname from full domain url
1942
- var urlObj = new URL ( domain ) ;
1943
- domain = urlObj . hostname ;
1944
- }
1945
- catch ( _ ) {
1946
- // do nothing, domain from config will be used as is
1947
- }
1939
+ try {
1940
+ // try to extract hostname from full domain url
1941
+ var urlObj = new URL ( domain ) ;
1942
+ domain = urlObj . hostname ;
1943
+ }
1944
+ catch ( _ ) {
1945
+ // do nothing, domain from config will be used as is
1946
+ }
1948
1947
1949
- //initializing countly with params
1950
- Countly . init ( {
1951
- app_key : countlyGlobal . frontend_app ,
1952
- url : countlyGlobal . frontend_server ,
1953
- device_id : domain ,
1954
- app_version : "<%= countlyVersion %>" ,
1955
- interval :1000
1956
- } ) ;
1948
+ //initializing countly with params
1949
+ Countly . init ( {
1950
+ app_key : countlyGlobal . frontend_app ,
1951
+ url : countlyGlobal . frontend_server ,
1952
+ device_id : domain ,
1953
+ app_version : "<%= countlyVersion %>" ,
1954
+ interval :1000
1955
+ } ) ;
1957
1956
1958
- // if domain has changed since the last time it is saved as device id set the new domain as device id and merge it with the old domain
1959
- if ( Countly . get_device_id ( ) !== domain ) {
1960
- Countly . change_id ( domain , true ) ;
1961
- }
1957
+ // if domain has changed since the last time it is saved as device id set the new domain as device id and merge it with the old domain
1958
+ if ( Countly . get_device_id ( ) !== domain ) {
1959
+ Countly . change_id ( domain , true ) ;
1960
+ }
1961
+
1962
+ //track sessions automatically
1963
+ Countly . track_sessions ( ) ;
1962
1964
1963
- //track sessions automatically
1964
- Countly . track_sessions ( ) ;
1965
+ //track pageviews automatically
1966
+ Countly . track_pageview ( Countly . getViewName ( ) ) ;
1965
1967
1966
- //track pageviews automatically
1968
+ $ ( window ) . on ( 'hashchange' , function ( ) {
1967
1969
Countly . track_pageview ( Countly . getViewName ( ) ) ;
1970
+ } ) ;
1971
+
1972
+ //track any clicks to webpages automatically
1973
+ Countly . track_clicks ( ) ;
1968
1974
1969
- $ ( window ) . on ( 'hashchange' , function ( ) {
1970
- Countly . track_pageview ( Countly . getViewName ( ) ) ;
1975
+ //track javascript errors
1976
+ Countly . track_errors ( ) ;
1977
+
1978
+ //display in app messages
1979
+ if ( Countly . content . enterContentZone ) {
1980
+ Countly . content . enterContentZone ( ) ;
1981
+ }
1982
+
1983
+ if ( Countly . report_trace && window . performance && window . performance . timing ) {
1984
+ $ ( window ) . on ( "load" , function ( ) {
1985
+ setTimeout ( function ( ) {
1986
+ var trace = {
1987
+ type : "device" ,
1988
+ name : Countly . getViewName ( ) ,
1989
+ stz : window . performance . timing . navigationStart ,
1990
+ etz : window . performance . timing . domContentLoadedEventEnd ,
1991
+ apm_metrics : { }
1992
+ } ;
1993
+ if ( window . performance . timing . domLoading && window . performance . timing . navigationStart ) {
1994
+ trace . apm_metrics . first_paint = window . performance . timing . domLoading - window . performance . timing . navigationStart ;
1995
+ }
1996
+ if ( window . performance . timing . domContentLoadedEventStart && window . performance . timing . navigationStart ) {
1997
+ trace . apm_metrics . first_contentful_paint = window . performance . timing . domContentLoadedEventStart - window . performance . timing . navigationStart ;
1998
+ }
1999
+ if ( window . performance . timing . domInteractive && window . performance . timing . navigationStart ) {
2000
+ trace . apm_metrics . dom_interactive = window . performance . timing . domInteractive - window . performance . timing . navigationStart ;
2001
+ }
2002
+ if ( window . performance . timing . domContentLoadedEventEnd && window . performance . timing . domContentLoadedEventStart ) {
2003
+ trace . apm_metrics . dom_content_loaded_event_end = window . performance . timing . domContentLoadedEventEnd - window . performance . timing . domContentLoadedEventStart ;
2004
+ }
2005
+ if ( window . performance . timing . loadEventEnd && window . performance . timing . loadEventStart ) {
2006
+ trace . apm_metrics . load_event_end = window . performance . timing . loadEventEnd - window . performance . timing . loadEventStart ;
2007
+ }
2008
+ if ( Object . keys ( trace . apm_metrics ) . length ) {
2009
+ Countly . report_trace ( trace ) ;
2010
+ }
2011
+ } , 1 ) ;
1971
2012
} ) ;
2013
+ }
2014
+
2015
+ Countly . userData . set ( "lastServer" , window . location . hostname ) ;
2016
+ Countly . userData . set ( "lastVersion" , "<%= countlyVersion %>" ) ;
2017
+ Countly . userData . set ( "lastEdition" , "<%= countlyTypeTrack %>" ) ;
2018
+ Countly . userData . set ( "isTrial" , < %= countlyTrial % > );
2019
+ Countly.userData.set("cpus", < %= cpus % > );
2020
+ Countly.userData.push_unique("servers", window.location.hostname);
2021
+ Countly.userData.push_unique("versions", "< %= countlyVersion % > ");
2022
+ Countly.userData.push_unique("editions", "< %= countlyTypeTrack % > ");
2023
+ Countly.userData.save();
1972
2024
1973
- //track any clicks to webpages automatically
1974
- Countly . track_clicks ( ) ;
2025
+ < % if ( installed ) { % >
2026
+ Countly.add_event({
2027
+ key :"INSTALL"
2028
+ } );
2029
+ < % } % >
2030
+ }
1975
2031
1976
- //track javascript errors
1977
- Countly . track_errors ( ) ;
2032
+ if ( countlyGlobal . config . self_tracking ) {
2033
+ //initializing countly with params
2034
+ var Countly2 = Countly . init ( {
2035
+ app_key : countlyGlobal . config . self_tracking ,
2036
+ url : window . location . origin ,
2037
+ device_id : countlyGlobal . member . email ,
2038
+ app_version : "<%= countlyVersion %>" ,
2039
+ interval :1000
2040
+ } ) ;
1978
2041
1979
- //display in app messages
1980
- Countly . content . enterContentZone ( ) ;
1981
-
1982
- if ( Countly . report_trace && window . performance && window . performance . timing ) {
1983
- $ ( window ) . on ( "load" , function ( ) {
1984
- setTimeout ( function ( ) {
1985
- var trace = {
1986
- type : "device" ,
1987
- name : Countly . getViewName ( ) ,
1988
- stz : window . performance . timing . navigationStart ,
1989
- etz : window . performance . timing . domContentLoadedEventEnd ,
1990
- apm_metrics : { }
1991
- } ;
1992
- if ( window . performance . timing . domLoading && window . performance . timing . navigationStart ) {
1993
- trace . apm_metrics . first_paint = window . performance . timing . domLoading - window . performance . timing . navigationStart ;
1994
- }
1995
- if ( window . performance . timing . domContentLoadedEventStart && window . performance . timing . navigationStart ) {
1996
- trace . apm_metrics . first_contentful_paint = window . performance . timing . domContentLoadedEventStart - window . performance . timing . navigationStart ;
1997
- }
1998
- if ( window . performance . timing . domInteractive && window . performance . timing . navigationStart ) {
1999
- trace . apm_metrics . dom_interactive = window . performance . timing . domInteractive - window . performance . timing . navigationStart ;
2000
- }
2001
- if ( window . performance . timing . domContentLoadedEventEnd && window . performance . timing . domContentLoadedEventStart ) {
2002
- trace . apm_metrics . dom_content_loaded_event_end = window . performance . timing . domContentLoadedEventEnd - window . performance . timing . domContentLoadedEventStart ;
2003
- }
2004
- if ( window . performance . timing . loadEventEnd && window . performance . timing . loadEventStart ) {
2005
- trace . apm_metrics . load_event_end = window . performance . timing . loadEventEnd - window . performance . timing . loadEventStart ;
2006
- }
2007
- if ( Object . keys ( trace . apm_metrics ) . length ) {
2008
- Countly . report_trace ( trace ) ;
2009
- }
2010
- } , 1 ) ;
2011
- } ) ;
2012
- }
2042
+ //track sessions automatically
2043
+ Countly2 . track_sessions ( ) ;
2013
2044
2014
- Countly . userData . set ( "lastServer" , window . location . hostname ) ;
2015
- Countly . userData . set ( "lastVersion" , "<%= countlyVersion %>" ) ;
2016
- Countly . userData . set ( "lastEdition" , "<%= countlyTypeTrack %>" ) ;
2017
- Countly . userData . set ( "isTrial" , < %= countlyTrial % > );
2018
- Countly.userData.set("cpus", < %= cpus % > );
2019
- Countly.userData.push_unique("servers", window.location.hostname);
2020
- Countly.userData.push_unique("versions", "< %= countlyVersion % > ");
2021
- Countly.userData.push_unique("editions", "< %= countlyTypeTrack % > ");
2022
- Countly.userData.save();
2023
-
2024
- < % if ( installed ) { % >
2025
- Countly.add_event({
2026
- key :"INSTALL"
2027
- } );
2028
- < % } % >
2045
+ //track pageviews automatically
2046
+ Countly2 . track_pageview ( Countly . getViewName ( ) ) ;
2047
+
2048
+ $ ( window ) . on ( 'hashchange' , function ( ) {
2049
+ Countly2 . track_pageview ( Countly . getViewName ( ) ) ;
2050
+ } ) ;
2051
+
2052
+ //display in app messages
2053
+ if ( Countly2 . content . enterContentZone ) {
2054
+ Countly2 . content . enterContentZone ( ) ;
2029
2055
}
2030
- </ script >
2031
- < % } %>
2056
+
2057
+ Countly2.user_details({
2058
+ "name" : countlyGlobal . member . full_name || "" ,
2059
+ "username" : countlyGlobal . member . username || "" ,
2060
+ "email" : countlyGlobal . member . email
2061
+ } );
2062
+ }
2063
+ </ script >
2032
2064
< % } %>
2033
2065
< script type ='text/javascript '>
2034
2066
app . recordEvent = function ( event ) {
0 commit comments