@@ -54,15 +54,18 @@ export class ScreenTrackingService implements OnDestroy {
5454 } ;
5555 const component = activationEnd . snapshot . component ;
5656 const routeConfig = activationEnd . snapshot . routeConfig ;
57+ const loadedConfig = routeConfig && ( routeConfig as any ) . _loadedConfig ;
5758 const loadChildren = routeConfig && routeConfig . loadChildren ;
5859 if ( component ) {
5960 return of ( { ...params , firebase_screen_class : nameOrToString ( component ) } ) ;
61+ } else if ( loadedConfig && loadedConfig . module && loadedConfig . module . _moduleType ) {
62+ return of ( { ...params , firebase_screen_class : nameOrToString ( loadedConfig . module . _moduleType ) } ) ;
6063 } else if ( typeof loadChildren === "string" ) {
6164 // TODO is this an older lazy loading style parse
6265 return of ( { ...params , firebase_screen_class : loadChildren } ) ;
6366 } else if ( loadChildren ) {
64- // TODO look into the return types here
65- return from ( loadChildren ) . pipe ( map ( child => ( { ...params , firebase_screen_class : nameOrToString ( child ) } ) ) ) ;
67+ // TODO look into the other return types here
68+ return from ( loadChildren ( ) as Promise < any > ) . pipe ( map ( child => ( { ...params , firebase_screen_class : nameOrToString ( child ) } ) ) ) ;
6669 } else {
6770 // TODO figure out what forms of router events I might be missing
6871 return of ( params ) ;
@@ -77,7 +80,7 @@ export class ScreenTrackingService implements OnDestroy {
7780 analytics . setCurrentScreen ( params . screen_name , { global : true } )
7881 }
7982 } ) ,
80- map ( params => ( { firebase_screen_id : getScreenId ( params ) , ...params } ) ) ,
83+ map ( params => ( { firebase_screen_id : nextScreenId ( params ) , ...params } ) ) ,
8184 groupBy ( params => params . outlet ) ,
8285 mergeMap ( group => group . pipe ( startWith ( undefined ) , pairwise ( ) ) ) ,
8386 map ( ( [ prior , current ] ) => prior ? {
@@ -123,19 +126,19 @@ export class UserTrackingService implements OnDestroy {
123126 }
124127}
125128
126- let nextScreenId = Math . floor ( Math . random ( ) * 2 ** 64 ) - 2 ** 63 ;
129+ // firebase_screen_id is an INT64 but use INT32 cause javascript
130+ const randomInt32 = ( ) => Math . floor ( Math . random ( ) * ( 2 ** 32 - 1 ) ) - 2 ** 31 ;
127131
128- const screenIds : { [ key :string ] : number } = { } ;
132+ const currentScreenIds : { [ key :string ] : number } = { } ;
129133
130- const getScreenId = ( params :AngularFireAnalyticsEventParams ) => {
131- const name = params . firebase_screen_class || params . screen_name ;
132- const existingScreenId = screenIds [ name ] ;
133- if ( existingScreenId ) {
134- return existingScreenId ;
134+ const nextScreenId = ( params :AngularFireAnalyticsEventParams ) => {
135+ const scope = params . outlet ;
136+ if ( currentScreenIds . hasOwnProperty ( scope ) ) {
137+ return ++ currentScreenIds [ scope ] ;
135138 } else {
136- const screenId = nextScreenId ++ ;
137- screenIds [ name ] = screenId ;
138- return screenId ;
139+ const ret = randomInt32 ( ) ;
140+ currentScreenIds [ scope ] = ret ;
141+ return ret ;
139142 }
140143}
141144
0 commit comments