diff --git a/site/worker.js b/site/worker.js index 4a69c01a1..2890f7561 100644 --- a/site/worker.js +++ b/site/worker.js @@ -365,9 +365,12 @@ export async function relay(req, url) { } } -// beacon adds Cloudflare Web Analytics and PostHog's Web Analytics to a page. -// The dashboard's automatic injection skips whatever a worker returns, and -// every page passes through this one. PostHog's requests go through RELAY +// beacon adds PostHog's Web Analytics to a page; every page passes through +// this one. Cloudflare Web Analytics is not added here: Cloudflare injects +// its own beacon into worker responses now, and that one reports to this +// site's /cdn-cgi/rum. A second, manual beacon loaded first and won, and +// reported to cloudflareinsights.com, which answers 404 for this site's +// token, so Web Analytics counted no visits at all. PostHog's requests go through RELAY // on this site. PostHog keeps its visitor id in // localStorage, never a cookie: these pages vary on Cookie (the lang // cookie), and a per-visitor cookie would ride on every request. It isn't @@ -379,7 +382,7 @@ export async function relay(req, url) { // flags aren't turned off. Nothing is loaded under Do Not Track or Global // Privacy Control. Its project is the daily count's. const WEB_ANALYTICS = ``; -const BEACON = `` + WEB_ANALYTICS; +const BEACON = WEB_ANALYTICS; // The contributors page: its #wall gets the table credits-cli.mjs rendered // for that language at deploy. Without it (a deploy that couldn't build diff --git a/site/worker.test.mjs b/site/worker.test.mjs index b3d131e58..3b3d9d0b0 100644 --- a/site/worker.test.mjs +++ b/site/worker.test.mjs @@ -647,7 +647,8 @@ test("contributors: each language's page gets its own table, and keeps its line assert.match(html, /
/, path); assert.ok(html.includes(head), `${path} has the ${lang} table`); assert.ok(html.includes("packinggoodsllc_07668") && html.includes("v0.1.2581"), path); - assert.match(html, /static\.cloudflareinsights\.com/, `${path} keeps the beacon`); + assert.match(html, /posthog\.init\(/, `${path} keeps the analytics`); + assert.doesNotMatch(html, /cloudflareinsights/, `${path} leaves Cloudflare's beacon to Cloudflare`); } fragments = false; const bare = await get("/docs/zh/contributors");