Files
copilotkit__copilotkit/docs/lib/providers/scarf-pixel.tsx
Benjamin Taylor 3342282bd8 feat(docs): gate trackers behind cookie consent banner
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>
2026-05-04 10:00:08 -05:00

28 lines
738 B
TypeScript

"use client";
import React from "react";
import { useConsent } from "@/lib/consent/ConsentContext";
export function ScarfPixel() {
const { state, hydrated } = useConsent();
const SCARF_PIXEL_ID = process.env.NEXT_PUBLIC_SCARF_PIXEL_ID;
if (!SCARF_PIXEL_ID) return null;
if (!hydrated || !state.categories.marketing) return null;
return (
// eslint-disable-next-line @next/next/no-img-element
<img
referrerPolicy="no-referrer-when-downgrade"
src={`https://static.scarf.sh/a.png?x-pxid=${SCARF_PIXEL_ID}`}
alt=""
style={{
position: "absolute",
width: "1px",
height: "1px",
opacity: 0,
pointerEvents: "none",
left: "-9999px",
}}
/>
);
}