1
0
mirror of synced 2025-12-19 18:10:59 -05:00

Always call initializeEvents with a truthy csrfToken (#29721)

This commit is contained in:
Peter Bengtsson
2022-08-08 18:10:00 +02:00
committed by GitHub
parent 623a040851
commit ef277d6640
2 changed files with 4 additions and 4 deletions

View File

@@ -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()

View File

@@ -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])