From 948ea4c1028fe286a9066184e07b403a1396890f Mon Sep 17 00:00:00 2001 From: Gabriel Vigil Date: Fri, 19 Dec 2025 13:27:27 -0700 Subject: [PATCH 01/15] added trustarc scripts to top of head --- components/TrustArcScripts/TrustArcScripts.tsx | 12 ++++++++++++ components/TrustArcScripts/index.tsx | 1 + pages/_app.tsx | 2 ++ 3 files changed, 15 insertions(+) create mode 100644 components/TrustArcScripts/TrustArcScripts.tsx create mode 100644 components/TrustArcScripts/index.tsx diff --git a/components/TrustArcScripts/TrustArcScripts.tsx b/components/TrustArcScripts/TrustArcScripts.tsx new file mode 100644 index 0000000000..827bc76482 --- /dev/null +++ b/components/TrustArcScripts/TrustArcScripts.tsx @@ -0,0 +1,12 @@ +import { addScriptBody } from "../GTMScripts/GTMScripts"; + +export default function insertTrustArcScriptTags() { + const trustArcAutoBlockCore = ``; + const trustArcAutoBlock = ``; + + const trustArcInitScript = ``; + // Run + addScriptBody({ scriptBody: trustArcAutoBlockCore, tagType: `script` }); + addScriptBody({ scriptBody: trustArcAutoBlock, tagType: `script` }); + addScriptBody({ scriptBody: trustArcInitScript, tagType: `script` }); +} diff --git a/components/TrustArcScripts/index.tsx b/components/TrustArcScripts/index.tsx new file mode 100644 index 0000000000..c6bad2f926 --- /dev/null +++ b/components/TrustArcScripts/index.tsx @@ -0,0 +1 @@ +export { default as insertTrustArcScriptTags } from "./TrustArcScripts"; \ No newline at end of file diff --git a/pages/_app.tsx b/pages/_app.tsx index dd87314e7a..9b256f361b 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -6,6 +6,7 @@ import { useEffect } from "react"; import * as Sentry from "@sentry/react"; import { insertGTMScriptTags } from "../components/GTMScripts"; +import { insertTrustArcScriptTags } from "../components/TrustArcScripts"; import { SENTRY_VARS } from "../utils/error-reporting"; import { useSprig } from "../hooks/useSprig"; @@ -14,6 +15,7 @@ export default function MyApp({ Component, pageProps }: AppProps) { useSprig(); useEffect(() => { + insertTrustArcScriptTags(); insertGTMScriptTags(); window.sentry = Sentry.init(SENTRY_VARS); From 1aeb51c94a5091fc46aa91317d7b0e681fa62e15 Mon Sep 17 00:00:00 2001 From: Gabriel Vigil Date: Fri, 19 Dec 2025 13:56:54 -0700 Subject: [PATCH 02/15] move to document head and format properly --- .../TrustArcScripts/TrustArcScripts.tsx | 23 ++++++++++--------- components/TrustArcScripts/index.tsx | 2 +- pages/_app.tsx | 2 -- pages/_document.js | 6 +++-- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/components/TrustArcScripts/TrustArcScripts.tsx b/components/TrustArcScripts/TrustArcScripts.tsx index 827bc76482..0c6788f9e2 100644 --- a/components/TrustArcScripts/TrustArcScripts.tsx +++ b/components/TrustArcScripts/TrustArcScripts.tsx @@ -1,12 +1,13 @@ -import { addScriptBody } from "../GTMScripts/GTMScripts"; +export default function TrustArcScripts() { + const trustArcAutoBlockCoreSrc = `https://consent.trustarc.com/v2/autoblockasset/core.min.js?cmId=9iv2en`; + const trustArcAutoBlockSrc = `https://consent.trustarc.com/v2/autoblock?cmId=9iv2en`; + const trustArcInitScriptSrc = `https://consent.trustarc.com/v2/notice/9iv2en`; -export default function insertTrustArcScriptTags() { - const trustArcAutoBlockCore = ``; - const trustArcAutoBlock = ``; - - const trustArcInitScript = ``; - // Run - addScriptBody({ scriptBody: trustArcAutoBlockCore, tagType: `script` }); - addScriptBody({ scriptBody: trustArcAutoBlock, tagType: `script` }); - addScriptBody({ scriptBody: trustArcInitScript, tagType: `script` }); -} + return ( + <> + + + + + ) +} \ No newline at end of file diff --git a/components/TrustArcScripts/index.tsx b/components/TrustArcScripts/index.tsx index c6bad2f926..3d1848d8ac 100644 --- a/components/TrustArcScripts/index.tsx +++ b/components/TrustArcScripts/index.tsx @@ -1 +1 @@ -export { default as insertTrustArcScriptTags } from "./TrustArcScripts"; \ No newline at end of file +export { default as TrustArcScripts } from "./TrustArcScripts"; \ No newline at end of file diff --git a/pages/_app.tsx b/pages/_app.tsx index 9b256f361b..dd87314e7a 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -6,7 +6,6 @@ import { useEffect } from "react"; import * as Sentry from "@sentry/react"; import { insertGTMScriptTags } from "../components/GTMScripts"; -import { insertTrustArcScriptTags } from "../components/TrustArcScripts"; import { SENTRY_VARS } from "../utils/error-reporting"; import { useSprig } from "../hooks/useSprig"; @@ -15,7 +14,6 @@ export default function MyApp({ Component, pageProps }: AppProps) { useSprig(); useEffect(() => { - insertTrustArcScriptTags(); insertGTMScriptTags(); window.sentry = Sentry.init(SENTRY_VARS); diff --git a/pages/_document.js b/pages/_document.js index 0c06cdea5c..ae58d27c82 100644 --- a/pages/_document.js +++ b/pages/_document.js @@ -1,10 +1,12 @@ import { Html, Head, Main, NextScript } from "next/document"; -import Script from "next/script"; +import { TrustArcScripts } from "../components/TrustArcScripts"; export default function Document() { return ( - + + +
From 7c89013a0f3cd02f77aba7287e4286c4bd3a3b5d Mon Sep 17 00:00:00 2001 From: Gabriel Vigil Date: Fri, 19 Dec 2025 14:25:57 -0700 Subject: [PATCH 03/15] added all needed code to document instead of relying on gtm --- components/TrustArcScripts/TrustArcScripts.tsx | 6 ++++++ pages/_document.js | 1 + 2 files changed, 7 insertions(+) diff --git a/components/TrustArcScripts/TrustArcScripts.tsx b/components/TrustArcScripts/TrustArcScripts.tsx index 0c6788f9e2..f88c965763 100644 --- a/components/TrustArcScripts/TrustArcScripts.tsx +++ b/components/TrustArcScripts/TrustArcScripts.tsx @@ -3,11 +3,17 @@ export default function TrustArcScripts() { const trustArcAutoBlockSrc = `https://consent.trustarc.com/v2/autoblock?cmId=9iv2en`; const trustArcInitScriptSrc = `https://consent.trustarc.com/v2/notice/9iv2en`; + const reloadOnBannerScript = `var _STATE={};function runOnce(){!_STATE.hasRunOnce&&window.truste&&truste.eu&&truste.eu.prefclose&&(_STATE.oldValue=truste.eu.bindMap.prefCookie&&truste.eu.bindMap.prefCookie.split(":")[0].replace(/[^\d.]/g,"-"),_STATE.oldMethod=truste.eu.prefclose,truste.eu.prefclose=function(){_STATE.oldMethod(),truste.eu.bindMap.prefCookie&&truste.eu.bindMap.prefCookie.split(":")[0].replace(/[^\d.]/g,"-")!==_STATE.oldValue&&setTimeout(function(){window.location.reload()},20)},_STATE.hasRunOnce=!0,_STATE.i&&clearInterval(_STATE.i))}_STATE.i=setInterval(runOnce,10);` + + const reloadOnPreviewScript = `document.body.addEventListener("click",function(t){t&&t.target&&"truste-consent-button"===t.target.id&&setTimeout(function(){window.location.reload()},1e3)});` + return ( <> + + ) } \ No newline at end of file diff --git a/pages/_document.js b/pages/_document.js index ae58d27c82..99a66b073c 100644 --- a/pages/_document.js +++ b/pages/_document.js @@ -49,6 +49,7 @@ export default function Document() { {/* Empty script tag as chrome bug fix, see https://stackoverflow.com/a/42969608/943337 */} + ); From bcc787f11b15652cc08adae5e4e75ea11dec84a2 Mon Sep 17 00:00:00 2001 From: Gabriel Vigil Date: Fri, 19 Dec 2025 14:41:13 -0700 Subject: [PATCH 04/15] fixed reload script --- components/TrustArcScripts/TrustArcScripts.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/TrustArcScripts/TrustArcScripts.tsx b/components/TrustArcScripts/TrustArcScripts.tsx index f88c965763..fdaeac0658 100644 --- a/components/TrustArcScripts/TrustArcScripts.tsx +++ b/components/TrustArcScripts/TrustArcScripts.tsx @@ -3,17 +3,17 @@ export default function TrustArcScripts() { const trustArcAutoBlockSrc = `https://consent.trustarc.com/v2/autoblock?cmId=9iv2en`; const trustArcInitScriptSrc = `https://consent.trustarc.com/v2/notice/9iv2en`; - const reloadOnBannerScript = `var _STATE={};function runOnce(){!_STATE.hasRunOnce&&window.truste&&truste.eu&&truste.eu.prefclose&&(_STATE.oldValue=truste.eu.bindMap.prefCookie&&truste.eu.bindMap.prefCookie.split(":")[0].replace(/[^\d.]/g,"-"),_STATE.oldMethod=truste.eu.prefclose,truste.eu.prefclose=function(){_STATE.oldMethod(),truste.eu.bindMap.prefCookie&&truste.eu.bindMap.prefCookie.split(":")[0].replace(/[^\d.]/g,"-")!==_STATE.oldValue&&setTimeout(function(){window.location.reload()},20)},_STATE.hasRunOnce=!0,_STATE.i&&clearInterval(_STATE.i))}_STATE.i=setInterval(runOnce,10);` - - const reloadOnPreviewScript = `document.body.addEventListener("click",function(t){t&&t.target&&"truste-consent-button"===t.target.id&&setTimeout(function(){window.location.reload()},1e3)});` + // Reload on preference change from footer link. Uncomment and ensure works when link is added + // const reloadOnPreferencesScript = `var _STATE={};function runOnce(){!_STATE.hasRunOnce&&window.truste&&truste.eu&&truste.eu.prefclose&&(_STATE.oldValue=truste.eu.bindMap.prefCookie&&truste.eu.bindMap.prefCookie.split(":")[0].replace(/[^\d.]/g,"-"),_STATE.oldMethod=truste.eu.prefclose,truste.eu.prefclose=function(){_STATE.oldMethod(),truste.eu.bindMap.prefCookie&&truste.eu.bindMap.prefCookie.split(":")[0].replace(/[^\d.]/g,"-")!==_STATE.oldValue&&setTimeout(function(){window.location.reload()},20)},_STATE.hasRunOnce=!0,_STATE.i&&clearInterval(_STATE.i))}_STATE.i=setInterval(runOnce,10);` + const reloadOnBannerScript = `document.body.addEventListener("click",function(t){t&&t.target&&("truste-consent-button"===t.target.id||"truste-consent-required"===t.target.id)&&setTimeout(function(){window.location.reload()},1e3)});` return ( <> - + {/* */} ) } \ No newline at end of file From 1ff1da1c3a1c53d224e9c63f08b35d435639352c Mon Sep 17 00:00:00 2001 From: Gabriel Vigil Date: Fri, 19 Dec 2025 14:55:44 -0700 Subject: [PATCH 05/15] fixed how script string is loaded --- components/TrustArcScripts/TrustArcScripts.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/TrustArcScripts/TrustArcScripts.tsx b/components/TrustArcScripts/TrustArcScripts.tsx index fdaeac0658..334b7f70e1 100644 --- a/components/TrustArcScripts/TrustArcScripts.tsx +++ b/components/TrustArcScripts/TrustArcScripts.tsx @@ -12,8 +12,8 @@ export default function TrustArcScripts() { - - {/* */} + - - - {/* Empty script tag as chrome bug fix, see https://stackoverflow.com/a/42969608/943337 */} + From 0d4cbfd7971d1b45fdab349695f940f79af69ed3 Mon Sep 17 00:00:00 2001 From: Gabriel Vigil Date: Wed, 7 Jan 2026 12:03:16 -0700 Subject: [PATCH 07/15] add cookie preferences for testing --- theme.config.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/theme.config.tsx b/theme.config.tsx index e654329853..3e7a7d4d55 100644 --- a/theme.config.tsx +++ b/theme.config.tsx @@ -61,7 +61,12 @@ const config: DocsThemeConfig = { useLink: () => "https://mixpanel.com/contact-us/support", }, footer: { - content: `© Mixpanel ${new Date().getFullYear()}`, + content: ( + <> +
© Mixpanel {new Date().getFullYear()}
+
Cookie Preferences
+ + ), }, logo: , logoLink: "https://mixpanel.com/home/", From 46d28a9748bc408ba462e40425e62107f79bd2d6 Mon Sep 17 00:00:00 2001 From: Gabriel Vigil Date: Wed, 7 Jan 2026 12:23:02 -0700 Subject: [PATCH 08/15] add correct anchor and styling --- theme.config.tsx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/theme.config.tsx b/theme.config.tsx index 3e7a7d4d55..5ca9adfc65 100644 --- a/theme.config.tsx +++ b/theme.config.tsx @@ -62,10 +62,17 @@ const config: DocsThemeConfig = { }, footer: { content: ( - <> -
© Mixpanel {new Date().getFullYear()}
-
Cookie Preferences
- +
+
+ © Mixpanel {new Date().getFullYear()} +
+
+ {/* @ts-expect-error - truste is injected by TrustArc script at runtime */} + truste.eu.clickListener}> + Cookie Preferences + +
+
), }, logo: , From f2dcab1af899be5ed4b2d16a87854969ca866578 Mon Sep 17 00:00:00 2001 From: Gabriel Vigil Date: Wed, 7 Jan 2026 12:39:47 -0700 Subject: [PATCH 09/15] duh --- theme.config.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/theme.config.tsx b/theme.config.tsx index 5ca9adfc65..885bf9a160 100644 --- a/theme.config.tsx +++ b/theme.config.tsx @@ -67,8 +67,11 @@ const config: DocsThemeConfig = { © Mixpanel {new Date().getFullYear()}
- {/* @ts-expect-error - truste is injected by TrustArc script at runtime */} - truste.eu.clickListener}> + truste.eu.clickListener()} + > Cookie Preferences
From f20fd039839d63cfd2a2efc95f5f5c9177c18d46 Mon Sep 17 00:00:00 2001 From: Gabriel Vigil Date: Wed, 7 Jan 2026 12:50:24 -0700 Subject: [PATCH 10/15] add expect error --- theme.config.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/theme.config.tsx b/theme.config.tsx index 885bf9a160..f402385751 100644 --- a/theme.config.tsx +++ b/theme.config.tsx @@ -69,7 +69,7 @@ const config: DocsThemeConfig = {
truste.eu.clickListener()} > Cookie Preferences From bd76c928218df24d010cf462649d3ad0953fe174 Mon Sep 17 00:00:00 2001 From: Gabriel Vigil Date: Wed, 7 Jan 2026 13:36:26 -0700 Subject: [PATCH 11/15] added reload script --- components/TrustArcScripts/TrustArcScripts.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/components/TrustArcScripts/TrustArcScripts.tsx b/components/TrustArcScripts/TrustArcScripts.tsx index c20a4ee0ff..6becd6a2a0 100644 --- a/components/TrustArcScripts/TrustArcScripts.tsx +++ b/components/TrustArcScripts/TrustArcScripts.tsx @@ -13,8 +13,7 @@ export function TrustArcHeadScripts() { } export function TrustArcBodyScripts() { - // Reload on preference change from footer link. Uncomment and ensure works when link is added - // const reloadOnPreferencesScript = `var _STATE={};function runOnce(){!_STATE.hasRunOnce&&window.truste&&truste.eu&&truste.eu.prefclose&&(_STATE.oldValue=truste.eu.bindMap.prefCookie&&truste.eu.bindMap.prefCookie.split(":")[0].replace(/[^\d.]/g,"-"),_STATE.oldMethod=truste.eu.prefclose,truste.eu.prefclose=function(){_STATE.oldMethod(),truste.eu.bindMap.prefCookie&&truste.eu.bindMap.prefCookie.split(":")[0].replace(/[^\d.]/g,"-")!==_STATE.oldValue&&setTimeout(function(){window.location.reload()},20)},_STATE.hasRunOnce=!0,_STATE.i&&clearInterval(_STATE.i))}_STATE.i=setInterval(runOnce,10);` + const reloadOnPreferencesScript = `var _STATE={};function runOnce(){!_STATE.hasRunOnce&&window.truste&&truste.eu&&truste.eu.prefclose&&(_STATE.oldValue=truste.eu.bindMap.prefCookie&&truste.eu.bindMap.prefCookie.split(":")[0].replace(/[^\\d.]/g,"-"),_STATE.oldMethod=truste.eu.prefclose,truste.eu.prefclose=function(){_STATE.oldMethod(),truste.eu.bindMap.prefCookie&&truste.eu.bindMap.prefCookie.split(":")[0].replace(/[^\\d.]/g,"-")!==_STATE.oldValue&&setTimeout(function(){window.location.reload()},20)},_STATE.hasRunOnce=!0,_STATE.i&&clearInterval(_STATE.i))}_STATE.i=setInterval(runOnce,10);`; const reloadOnBannerScript = `document.body.addEventListener("click",function(t){t&&t.target&&("truste-consent-button"===t.target.id||"truste-consent-required"===t.target.id)&&setTimeout(function(){window.location.reload()},1e3)});`; @@ -25,7 +24,10 @@ export function TrustArcBodyScripts() { // eslint-disable-next-line @typescript-eslint/naming-convention dangerouslySetInnerHTML={{ __html: reloadOnBannerScript }} /> - {/*