Always call initializeEvents with a truthy csrfToken (#29721)
This commit is contained in:
@@ -273,9 +273,9 @@ function initPrintEvent() {
|
||||
})
|
||||
}
|
||||
|
||||
export default function initializeEvents(xcsrfToken?: string) {
|
||||
export function initializeEvents(xcsrfToken: string) {
|
||||
csrfToken = xcsrfToken // always update the csrfToken
|
||||
if (initialized || !xcsrfToken) return
|
||||
if (initialized) return
|
||||
initialized = true
|
||||
initPageAndExitEvent() // must come first
|
||||
initLinkEvent()
|
||||
|
||||
@@ -6,7 +6,7 @@ import { ThemeProvider, SSRProvider, ThemeProviderProps } from '@primer/react'
|
||||
|
||||
import '../stylesheets/index.scss'
|
||||
|
||||
import events from 'components/lib/events'
|
||||
import { initializeEvents } from 'components/lib/events'
|
||||
import experiment from 'components/lib/experiment'
|
||||
import { LanguagesContext, LanguagesContextT } from 'components/context/LanguagesContext'
|
||||
import { useSession } from 'components/hooks/useSession'
|
||||
@@ -22,7 +22,7 @@ const MyApp = ({ Component, pageProps, languagesContext }: MyAppProps) => {
|
||||
const { session } = useSession()
|
||||
useEffect(() => {
|
||||
if (session?.csrfToken) {
|
||||
events(session.csrfToken)
|
||||
initializeEvents(session.csrfToken)
|
||||
}
|
||||
experiment()
|
||||
}, [session])
|
||||
|
||||
Reference in New Issue
Block a user