Skip to content

Commit

Permalink
✨ Enable cookiebot logic in global dev #1309
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandolucchesi committed Oct 20, 2022
1 parent 64e844f commit 5318fdb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion web/lib/hooks/useConsentState.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useEffect, useState } from 'react'
import { useRouter } from 'next/router'
import { Flags } from '../../common/helpers/datasetHelpers'

//COOKIEBOT
declare global {
Expand Down Expand Up @@ -31,7 +32,11 @@ function useConsentState(consentType: ConsentType, callback: () => void, cleanup
}, [consentType])

useEffect(() => {
if (!window?.location.origin.includes('localhost') && consent) {
// Disable Radix.equinor.com due to SiteImprove (possibly) collecting wrong data
const host = window?.location.origin
const isLocalHost = host.includes('localhost')
const enableConsentLogic = !isLocalHost && (Flags.IS_DEV || !host.includes('radix.equinor.com'))
if (enableConsentLogic && consent) {
callback()
return () => {
if (cleanup) cleanup()
Expand Down

0 comments on commit 5318fdb

Please sign in to comment.