Skip to content

feat(docs): add Cloudflare Web Analytics - #59

Merged
moshiur01 merged 1 commit into
mainfrom
feat/cloudflare-web-analytics
Nov 18, 2026
Merged

moshiur01 merged 1 commit into
mainfrom
feat/cloudflare-web-analytics

Conversation

@moshiur01

Copy link
Copy Markdown
Contributor

Summary

  • Load the Cloudflare Web Analytics beacon (static.cloudflareinsights.com/beacon.min.js) when the NEXT_PUBLIC_CF_WEB_ANALYTICS_TOKEN build variable is set.
  • Render @vercel/analytics only when VERCEL is set at build time. On Cloudflare its script path doesn't exist and would return 404.

Setup

  1. In the Cloudflare dashboard, go to Web Analytics → Add a site and enter docs.tween-ui.workers.dev. Copy the token from the JS snippet.
  2. On the docs Worker, go to Settings → Build → Variables and secrets and add the build variable NEXT_PUBLIC_CF_WEB_ANALYTICS_TOKEN with that token.
  3. Merge or retry the build so the token is baked into the pages.

Testing

  • tsc --noEmit and prettier pass.
  • Not checked in a running build yet: the beacon only renders once the token is set.

🤖 Generated with Claude Code

Load the Cloudflare Web Analytics beacon when the
NEXT_PUBLIC_CF_WEB_ANALYTICS_TOKEN build variable is set, and only load
Vercel Analytics on Vercel builds, where its script exists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@moshiur01
moshiur01 merged commit 4ecc4d3 into main Nov 18, 2026
1 of 2 checks passed
@moshiur01
moshiur01 deleted the feat/cloudflare-web-analytics branch November 18, 2026 18:53
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