@@ -48,6 +48,7 @@ type Route = {
48
48
const AppLayout : React . FunctionComponent < IAppLayout > = ( { children, className } ) => {
49
49
const { data : session , status } = useSession ( ) ;
50
50
const [ isExperimentalEnabled , setExperimental ] = useState ( false ) ;
51
+ const [ analyticsInitialised , setAnalyticsInitialised ] = useState ( false ) ;
51
52
52
53
const router = useRouter ( ) ;
53
54
const pathname = usePathname ( ) ;
@@ -63,9 +64,9 @@ const AppLayout: React.FunctionComponent<IAppLayout> = ({ children, className })
63
64
} , [ ] ) ;
64
65
65
66
React . useEffect ( ( ) => {
66
- console . log ( "Get analytics effect " + window . analytics ) ;
67
67
if ( ! window . analytics ) {
68
68
initAnalytics ( ) ;
69
+ setAnalyticsInitialised ( true ) ;
69
70
}
70
71
} , [ ] ) ;
71
72
@@ -74,15 +75,16 @@ const AppLayout: React.FunctionComponent<IAppLayout> = ({ children, className })
74
75
window . analytics . trackPageView ( pathname ) ;
75
76
}
76
77
77
- } , [ pathname ] ) ;
78
+ } , [ pathname , analyticsInitialised ] ) ;
78
79
79
80
React . useEffect ( ( ) => {
80
- console . log ( ( "Identify effect " + session ?. user ) )
81
81
if ( window . analytics ) {
82
82
// 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
+ ) ;
84
86
}
85
- } , [ session ?. user ?. name , session ?. user ] ) ;
87
+ } , [ analyticsInitialised , session ?. user ?. name , session ?. user ] ) ;
86
88
87
89
React . useEffect ( ( ) => {
88
90
if ( status === 'loading' ) return ; // Do nothing while loading
0 commit comments