mirror of
https://github.com/CopilotKit/CopilotKit.git
synced 2026-09-14 16:26:20 +08:00
3342282bd8
Adds a geo-aware consent banner to the docs site, mirroring the marketing site approach. Middleware classifies visitors as eu / us-ca / other from Vercel geo headers; EU/UK/EEA and California default to opt-in (no trackers until accept), other regions default to opt-out. HubSpot, RB2B, Reo, Google Analytics, PostHog, and Scarf are all gated behind Analytics or Marketing categories. Privacy policy link points at www.copilotkit.ai/privacy-policy. Independent cookie (cpk_docs_consent) from the marketing site — separate banners by design. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
"use client";
|
|
|
|
import Script from "next/script";
|
|
import { useConsent } from "./ConsentContext";
|
|
|
|
const RB2B_KEY = process.env.NEXT_PUBLIC_REB2B_KEY;
|
|
const REO_KEY = process.env.NEXT_PUBLIC_REO_KEY;
|
|
|
|
const REO_SNIPPET = `!function(){var e,t,n;e="${REO_KEY ?? ""}";t=function(){if(window.Reo){window.Reo.init({clientID:"${REO_KEY ?? ""}"});}};n=document.createElement("script");n.src="https://static.reo.dev/"+e+"/reo.js";n.defer=true;n.onload=t;document.head.appendChild(n);}();`;
|
|
|
|
export function TrackingScripts() {
|
|
const { state, hydrated } = useConsent();
|
|
if (!hydrated) return null;
|
|
|
|
const { analytics, marketing } = state.categories;
|
|
|
|
return (
|
|
<>
|
|
{analytics && REO_KEY && (
|
|
<Script
|
|
id="reo-init-script"
|
|
strategy="afterInteractive"
|
|
dangerouslySetInnerHTML={{ __html: REO_SNIPPET }}
|
|
/>
|
|
)}
|
|
{marketing && (
|
|
<>
|
|
<Script
|
|
id="hubspot-script"
|
|
src="https://js.hs-scripts.com/45532593.js"
|
|
type="text/javascript"
|
|
strategy="lazyOnload"
|
|
async
|
|
defer
|
|
/>
|
|
{RB2B_KEY && (
|
|
<Script
|
|
id="reb2b-script"
|
|
strategy="afterInteractive"
|
|
src={`https://b2bjsstore.s3.us-west-2.amazonaws.com/b/${RB2B_KEY}/${RB2B_KEY}.js.gz`}
|
|
/>
|
|
)}
|
|
</>
|
|
)}
|
|
</>
|
|
);
|
|
}
|