Skip to content

chore(site): promote Web Analytics CSP fix to production - #202

Merged
dvcdsys merged 7 commits into
mainfrom
develop
Jul 27, 2026
Merged

chore(site): promote Web Analytics CSP fix to production#202
dvcdsys merged 7 commits into
mainfrom
develop

Conversation

@dvcdsys

@dvcdsys dvcdsys commented Jul 27, 2026

Copy link
Copy Markdown
Owner

Promotion of #201 to main so the site actually deploys with the widened
CSP. Nothing else is on develop — the two branches were identical before
this change.

The Cloudflare Web Analytics beacon is injected at the edge on every HTML
response once the toggle is flipped on the Pages project; the current
script-src 'self' would block it and the dashboard would report zero
traffic forever. This lands the policy first, the toggle follows.

Test plan

🤖 Generated with Claude Code

dvcdsys and others added 7 commits July 27, 2026 11:22
The site ships no analytics at all, so there is no way to tell whether
anyone reads it. Cloudflare Web Analytics is the cheapest honest answer
for a Pages-hosted site: cookie-free, no consent banner, first-party
beacon, and it is not blocked as aggressively as GA by the ad blockers
this audience runs.

Enabling it on the Pages project injects the beacon script at the edge,
which the current `script-src 'self'` policy would silently drop. Widen
script-src to static.cloudflareinsights.com and connect-src to
cloudflareinsights.com — the two hosts the beacon needs, nothing else.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
chore(site): allow the Cloudflare Web Analytics beacon through the CSP
… lines

Copy-pasting the beacon URL from the comment was broken by the mid-URL
line wrap; keep each URL and CSP directive on a single line.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Enabling Web Analytics with "automatic setup" on the codeindex.app zone
does nothing for this site: that injection is done by the zone HTML
rewriter, which never sees responses served by Cloudflare Pages. Confirmed
empirically — the beacon was still absent from the live HTML minutes after
the zone-level toggle, with cf-cache-status: DYNAMIC on every response.

Switch the site to "Enable with JS Snippet installation" and add the tag to
both deployed HTML entry points. The token is public by design (it ships in
the page source of every site using Web Analytics), so it lives in the repo
rather than in a build secret.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
chore(site): install the Web Analytics beacon by hand
… hand

The comment still claimed the Pages project injects the beacon automatically.
It does not: that injection lives in the zone HTML rewriter, which never sees
Pages responses, which is why the tag was added to the HTML entry points in
the first place. Describe what actually happens, so the next reader does not
go looking for a dashboard toggle that has no effect here.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
docs(site): correct the _headers comment — the beacon is installed by hand
@dvcdsys
dvcdsys merged commit b6e958f into main Jul 27, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant