Skip to content

Commit

Permalink
✨ Improve cookiebot toggle code #1309
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandolucchesi committed Oct 24, 2022
1 parent 9a727ce commit b2db727
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions web/lib/hooks/useConsentState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Flags } from '../../common/helpers/datasetHelpers'
//COOKIEBOT
declare global {
interface Window {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Cookiebot: any
}
}
Expand Down
13 changes: 11 additions & 2 deletions web/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,17 @@ function MyApp({ Component, pageProps }: CustomAppProps): JSX.Element {
}
}, [router.asPath])

useConsentState('statistics', loadSiteImproveScript, cleanUpSiteImproveScript)
useConsentState('statistics', enableDynatrace, disableDynatrace)
const enableStatistics = () => {
loadSiteImproveScript()
enableDynatrace()
}

const disableStatistics = () => {
cleanUpSiteImproveScript()
disableDynatrace()
}

useConsentState('statistics', enableStatistics, disableStatistics)

return (
<ErrorBoundary FallbackComponent={ErrorFallback} onError={HandleBoundaryError}>
Expand Down

0 comments on commit b2db727

Please sign in to comment.