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

View File

@@ -74,9 +74,10 @@ window.addEventListener("load", (function() {
t.text = "Peru hyväksyntäsi" t.text = "Peru hyväksyntäsi"
} }
} }
// )), )),
// window.addEventListener("CookiebotOnAccept", (function(e) { 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), 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),
// adobe.optIn.complete()) window.adobe.optIn.complete(),
// } window.dispatchEvent(new Event("load")))
}
)); ));