diff --git a/examples/cookie-banner-react/src/tabs/ThemedBannerTab.tsx b/examples/cookie-banner-react/src/tabs/ThemedBannerTab.tsx index c90e367c6..7b526e67c 100644 --- a/examples/cookie-banner-react/src/tabs/ThemedBannerTab.tsx +++ b/examples/cookie-banner-react/src/tabs/ThemedBannerTab.tsx @@ -55,6 +55,15 @@ export function ThemedBannerTab({ events, pushEvent }: ThemedBannerTabProps) { ); const sendPing = useCallback(() => { + // Defensive: `PosthogPanel` already disables the button while opted out, + // and pure telemetry pings like this one are fine to ship cookielessly + // (PostHog's `cookieless_mode` is designed exactly for that). Only gate + // manual captures when the event carries user-specific data — e.g. an + // identified `distinct_id`, an email, a workspace name — that must not + // leave the browser without consent. We keep the guard here purely to + // make the example fail closed if the panel is reused without its + // disabled-state wiring. + if (posthog.has_opted_out_capturing()) return; posthog.capture("themed_tab_manual_ping", { source: "example" }); setManualPing(new Date().toISOString()); }, []); diff --git a/examples/cookie-banner-react/src/tabs/_components/PosthogPanel.tsx b/examples/cookie-banner-react/src/tabs/_components/PosthogPanel.tsx index 8e09bfe31..8addcb288 100644 --- a/examples/cookie-banner-react/src/tabs/_components/PosthogPanel.tsx +++ b/examples/cookie-banner-react/src/tabs/_components/PosthogPanel.tsx @@ -58,14 +58,14 @@ export function PosthogPanel({ status, manualPing, onSendPing }: PosthogPanelPro {manualPing && ( - last sent: {manualPing} (only delivered when opted in) + last sent: {manualPing} )}