@@ -48,6 +48,7 @@ type Route = {
4848const AppLayout : React . FunctionComponent < IAppLayout > = ( { children, className } ) => {
4949 const { data : session , status } = useSession ( ) ;
5050 const [ isExperimentalEnabled , setExperimental ] = useState ( false ) ;
51+ const [ analyticsInitialised , setAnalyticsInitialised ] = useState ( false ) ;
5152
5253 const router = useRouter ( ) ;
5354 const pathname = usePathname ( ) ;
@@ -63,9 +64,9 @@ const AppLayout: React.FunctionComponent<IAppLayout> = ({ children, className })
6364 } , [ ] ) ;
6465
6566 React . useEffect ( ( ) => {
66- console . log ( "Get analytics effect " + window . analytics ) ;
6767 if ( ! window . analytics ) {
6868 initAnalytics ( ) ;
69+ setAnalyticsInitialised ( true ) ;
6970 }
7071 } , [ ] ) ;
7172
@@ -74,15 +75,16 @@ const AppLayout: React.FunctionComponent<IAppLayout> = ({ children, className })
7475 window . analytics . trackPageView ( pathname ) ;
7576 }
7677
77- } , [ pathname ] ) ;
78+ } , [ pathname , analyticsInitialised ] ) ;
7879
7980 React . useEffect ( ( ) => {
80- console . log ( ( "Identify effect " + session ?. user ) )
8181 if ( window . analytics ) {
8282 // TODO we may potentially want to hash this. Also different code per target install?
83- window . analytics . identify ( session ?. user ?. name ? session . user . name : '-unknown-user-name ' ) ;
83+ // TODO pass other parameters as properties
84+ window . analytics . identify ( session ?. user ?. name ? session . user . name : '-unknown-user-name ' , { }
85+ ) ;
8486 }
85- } , [ session ?. user ?. name , session ?. user ] ) ;
87+ } , [ analyticsInitialised , session ?. user ?. name , session ?. user ] ) ;
8688
8789 React . useEffect ( ( ) => {
8890 if ( status === 'loading' ) return ; // Do nothing while loading
0 commit comments