debug: move CookebotOnAccept logic to legacy cookie-bot script

This commit is contained in:
Arvid Norlin
2024-03-06 19:47:29 +01:00
parent f19b79f732
commit a65b2aa73a
2 changed files with 41 additions and 40 deletions

View File

@@ -74,41 +74,41 @@ export default function Tracking({ pageData }: TrackingProps) {
}
}, [pathName, queryString, pageData])
useEffect(() => {
// handle consent
console.log("in effect")
window.addEventListener(
"CookiebotOnAccept",
function CookiebotCallback_OnAccept(e) {
console.log("Cookiebot onAccept callback fired ✅")
setConsentCookie(window._satellite.cookie.get("CookieConsent"))
if (window.Cookiebot?.changed && window.adobe) {
if (consentCookie?.includes("statistics:true")) {
window.adobe.optIn.approve(
window.adobe.OptInCategories.ANALYTICS,
true
)
} else {
window.adobe.optIn.deny(
window.adobe.OptInCategories.ANALYTICS,
true
)
}
window.adobe.optIn.complete()
window.dispatchEvent(new Event("load"))
console.log("dispatched load event")
}
}
)
window.addEventListener(
"CookiebotOnDecline",
function CookebotCallback_OnDecline() {
if (window.Cookiebot?.changed && window.adobe) {
window.adobe.optIn.deny(window.adobe.OptInCategories.ANALYTICS, true)
}
}
)
}, [consentCookie])
// useEffect(() => {
// // handle consent
// console.log("in effect")
// window.addEventListener(
// "CookiebotOnAccept",
// function CookiebotCallback_OnAccept(e) {
// console.log("Cookiebot onAccept callback fired ✅")
// setConsentCookie(window._satellite.cookie.get("CookieConsent"))
// if (window.Cookiebot?.changed && window.adobe) {
// if (consentCookie?.includes("statistics:true")) {
// window.adobe.optIn.approve(
// window.adobe.OptInCategories.ANALYTICS,
// true
// )
// } else {
// window.adobe.optIn.deny(
// window.adobe.OptInCategories.ANALYTICS,
// true
// )
// }
// window.adobe.optIn.complete()
// window.dispatchEvent(new Event("load"))
// console.log("dispatched load event")
// }
// }
// )
// window.addEventListener(
// "CookiebotOnDecline",
// function CookebotCallback_OnDecline() {
// if (window.Cookiebot?.changed && window.adobe) {
// window.adobe.optIn.deny(window.adobe.OptInCategories.ANALYTICS, true)
// }
// }
// )
// }, [consentCookie])
return null
}

View File

@@ -74,9 +74,10 @@ window.addEventListener("load", (function() {
t.text = "Peru hyväksyntäsi"
}
}
// )),
// window.addEventListener("CookiebotOnAccept", (function(e) {
// window.Cookiebot.changed && adobe && (window.Cookiebot.consent.statistics ? adobe.optIn.approve(adobe.OptInCategories.ANALYTICS, !0) : adobe.optIn.deny(adobe.OptInCategories.ANALYTICS, !0),
// adobe.optIn.complete())
// }
)),
window.addEventListener("CookiebotOnAccept", (function(e) {
window.Cookiebot.changed && window.adobe && (window.Cookiebot.consent.statistics ? window.adobe.optIn.approve(window.adobe.OptInCategories.ANALYTICS, !0) : window.adobe.optIn.deny(window.adobe.OptInCategories.ANALYTICS, !0),
window.adobe.optIn.complete(),
window.dispatchEvent(new Event("load")))
}
));