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