Skip to content

Add optional Cloudflare Web Analytics from a build variable - #48

Merged
valuecodes merged 1 commit into
mainfrom
feat/cf-web-analytics
Oct 15, 2026
Merged

valuecodes merged 1 commit into
mainfrom
feat/cf-web-analytics

Conversation

@valuecodes

Copy link
Copy Markdown
Owner

What

  • Adds Cloudflare Web Analytics without committing the beacon token: the token comes from the VITE_CF_BEACON_TOKEN build variable.
  • A small Vite plugin in vite.config.ts adds Cloudflare's beacon <script type="module"> to index.html only in builds where the variable is set. Unset, the page has no beacon. A malformed token fails the build.
  • Documents the variable in the web README and AGENTS.md: set it as a Workers Builds build variable for production builds only, with the dashboard site on manual snippet installation.

How to test

pnpm --filter web build
VITE_CF_BEACON_TOKEN=0123456789abcdef0123456789abcdef pnpm --filter web build

The first build's dist/index.html has no cloudflareinsights script. The second has the beacon tag with data-cf-beacon.

Security review

No security-impacting changes. The existing CSP already allows the beacon's origins, and the token is validated as 32 hex digits before it goes into the HTML.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings October 15, 2026 07:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-15T07:08:27.526155Z 788fc0d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@valuecodes
valuecodes merged commit e05c888 into main Oct 15, 2026
10 checks passed
@valuecodes
valuecodes deleted the feat/cf-web-analytics branch October 15, 2026 07:08
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.

2 participants