From 50a27fea9806367ff7e5c0d68a4ba387b10f5df0 Mon Sep 17 00:00:00 2001 From: Arthur Belleville Date: Wed, 3 Dec 2025 21:03:18 +0100 Subject: [PATCH] Grant all RUM tracking --- apps/main/src/lib/rum.ts | 48 ++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/apps/main/src/lib/rum.ts b/apps/main/src/lib/rum.ts index b80299f..1e97733 100644 --- a/apps/main/src/lib/rum.ts +++ b/apps/main/src/lib/rum.ts @@ -1,10 +1,10 @@ import { datadogRum } from "@datadog/browser-rum"; import { reactPlugin } from "@datadog/browser-rum-react"; -import { getCookieConsent } from "../hooks/useCookieConsent"; +// import { getCookieConsent } from "../hooks/useCookieConsent"; // Check if user has consented to analytics cookies before initializing -const consent = getCookieConsent(); -const hasAnalyticsConsent = consent?.analytics ?? false; +// const consent = getCookieConsent(); +// const hasAnalyticsConsent = consent?.analytics ?? false; datadogRum.init({ applicationId: "8e268e1a-1be0-44c6-b12a-978530d497c7", @@ -22,32 +22,36 @@ datadogRum.init({ trackViewsManually: true, trackUserInteractions: true, trackResources: true, - trackingConsent: hasAnalyticsConsent ? "granted" : "not-granted", + // TODO: Uncomment when we have enough data + // trackingConsent: hasAnalyticsConsent ? "granted" : "not-granted", + trackingConsent: "granted", startSessionReplayRecordingManually: false, }); -// Listen for storage changes to update tracking consent when cookie preferences change -window.addEventListener("storage", (event) => { - if (event.key === "xtablo-cookie-consent") { - const newConsent = getCookieConsent(); - const newHasAnalyticsConsent = newConsent?.analytics ?? false; +// TODO: Uncomment when we have enough data - datadogRum.setTrackingConsent(newHasAnalyticsConsent ? "granted" : "not-granted"); - } -}); +// Listen for storage changes to update tracking consent when cookie preferences change +// window.addEventListener("storage", (event) => { +// if (event.key === "xtablo-cookie-consent") { +// const newConsent = getCookieConsent(); +// const newHasAnalyticsConsent = newConsent?.analytics ?? false; + +// datadogRum.setTrackingConsent(newHasAnalyticsConsent ? "granted" : "not-granted"); +// } +// }); // Also listen for changes within the same tab (storage event doesn't fire for same-origin changes) -const originalSetItem = localStorage.setItem; -localStorage.setItem = function setItem(key, value) { - const result = originalSetItem.apply(this, [key, value]); - if (key === "xtablo-cookie-consent") { - const newConsent = getCookieConsent(); - const newHasAnalyticsConsent = newConsent?.analytics ?? false; +// const originalSetItem = localStorage.setItem; +// localStorage.setItem = function setItem(key, value) { +// const result = originalSetItem.apply(this, [key, value]); +// if (key === "xtablo-cookie-consent") { +// const newConsent = getCookieConsent(); +// const newHasAnalyticsConsent = newConsent?.analytics ?? false; - datadogRum.setTrackingConsent(newHasAnalyticsConsent ? "granted" : "not-granted"); - } +// datadogRum.setTrackingConsent(newHasAnalyticsConsent ? "granted" : "not-granted"); +// } - return result; -}; +// return result; +// }; export default datadogRum;