Skip to content

Commit b9e6e6d

Browse files
committed
[Landing] Fix gtag user id
1 parent 0005271 commit b9e6e6d

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

landing/src/context/AuthContext.tsx

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@ import React, {
88
useState,
99
} from 'react'
1010

11-
import {
12-
constants,
13-
getDefaultUserPlan,
14-
UserPlan,
15-
} from '@brunolemos/devhub-core'
11+
import { constants, UserPlan } from '@brunolemos/devhub-core'
1612
import { getDefaultDevHubHeaders } from '../helpers'
1713

1814
export interface AuthProviderProps {
@@ -111,11 +107,12 @@ export function AuthProvider(props: AuthProviderProps) {
111107
}, [JSON.stringify(authData)])
112108

113109
useEffect(() => {
114-
if (typeof window === 'undefined' || typeof window.gtag === 'undefined')
115-
return
110+
if (typeof gtag === 'undefined') return
116111

117112
if (authData && authData._id) {
118-
window.gtag('set', { user_id: authData && authData._id })
113+
gtag('config', 'UA-52350759-6', {
114+
user_id: (authData && authData._id) || undefined,
115+
})
119116
}
120117
}, [authData && authData._id])
121118

@@ -482,7 +479,5 @@ function saveOnCache(auth: AuthData | undefined) {
482479
}
483480

484481
declare global {
485-
interface Window {
486-
gtag?: (...args: any[]) => void
487-
}
482+
const gtag: ((...args: any[]) => void) | undefined
488483
}

0 commit comments

Comments
 (0)