From d3b03cca791da197c6ecb6148c3f71b295dc0518 Mon Sep 17 00:00:00 2001 From: Arvid Norlin Date: Thu, 7 Mar 2024 09:24:21 +0100 Subject: [PATCH] debug: re-enable CookiebotOnAccept logic within JSX --- components/Current/Tracking.tsx | 69 ++++++++++++++-------------- public/_static/dist/js/cookie-bot.js | 9 +--- 2 files changed, 35 insertions(+), 43 deletions(-) diff --git a/components/Current/Tracking.tsx b/components/Current/Tracking.tsx index d72e0dac3..446663fb5 100644 --- a/components/Current/Tracking.tsx +++ b/components/Current/Tracking.tsx @@ -74,41 +74,40 @@ 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 + window.addEventListener( + "CookiebotOnAccept", + function CookiebotCallback_OnAccept(e) { + 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")) + } + } + ) + + window.addEventListener( + "CookiebotOnDecline", + function CookebotCallback_OnDecline() { + if (window.Cookiebot?.changed && window.adobe) { + window.adobe.optIn.deny(window.adobe.OptInCategories.ANALYTICS, true) + } + } + ) + }, [consentCookie]) return null } diff --git a/public/_static/dist/js/cookie-bot.js b/public/_static/dist/js/cookie-bot.js index 821d0db3f..cc2f9e43b 100644 --- a/public/_static/dist/js/cookie-bot.js +++ b/public/_static/dist/js/cookie-bot.js @@ -73,11 +73,4 @@ window.addEventListener("load", (function() { e.text = "Muuta hyväksyntäsi", t.text = "Peru hyväksyntäsi" } -} -)), -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"))) -} -)); +}));