Skip to content

Commit

Permalink
Always call initializeEvents with a truthy csrfToken (github#29721)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbe authored Aug 8, 2022
1 parent 623a040 commit ef277d6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions components/lib/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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])
Expand Down

0 comments on commit ef277d6

Please sign in to comment.