diff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.md index 0e91fe9..41603f2 100644 --- a/apps/web/AGENTS.md +++ b/apps/web/AGENTS.md @@ -236,7 +236,10 @@ Or run repo-wide via root `pnpm typecheck` / `pnpm test` / `pnpm build`. - **Build settings:** root directory `apps/web`, build command `pnpm run build`, deploy command `npx wrangler deploy`. - **Build variables:** `VITE_TURNSTILE_SITE_KEY`, the widget's site key. Vite - inlines it at build time, so it is a _build_ variable. Also set + inlines it at build time, so it is a _build_ variable. Optionally + `VITE_CF_BEACON_TOKEN`, the Web Analytics token: `vite.config.ts` adds the + beacon script to `index.html` only when it is set (production builds only, and + the dashboard site on manual installation, so there is one beacon). Also set `NODE_VERSION=24.21.0` and `PNPM_VERSION=12.4.2`: the version files sit outside the `apps/web` root, and the build image's defaults are older. - **Runtime secret:** `TURNSTILE_SECRET` under the Worker's Settings → Variables diff --git a/apps/web/README.md b/apps/web/README.md index 0d53cad..c98590c 100644 --- a/apps/web/README.md +++ b/apps/web/README.md @@ -142,6 +142,16 @@ Without the site key the GitHub field is hidden and the folder picker is the page's only loader. The Worker verifies each token with Turnstile's `siteverify` before it fetches, and rate-limits each IP to 5 loads a minute. +### Web Analytics + +Cloudflare Web Analytics is optional. Add the site in the dashboard (Web +Analytics → Add a site) with manual JS snippet installation, not automatic +injection, which would load a second beacon. Copy the `token` from its snippet +into the build variable `VITE_CF_BEACON_TOKEN` (Settings → Build → Variables), +and set it for production builds only so previews don't report into the site. +The token is public: the build puts the beacon `