You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Analytics: Serve the Umami tracker first-party so adblockers stop hiding our traffic
gitstrata.com loaded the tracker straight from a third-party analytics domain at the well-known `/script.js` path — both on adblock blocklists, so most visitors went uncounted. A Cloudflare Pages Function now proxies it same-origin under `/u/*`, matching the first-party setup on the other sites.
- Add `functions/u/[[path]].ts`: proxies `/u/mami` → upstream `/script.js` and passes the beacon (`/u/api/send`) plus everything else straight through. Forwards the real visitor IP via `x-forwarded-for` so Umami still counts uniques; caches the script briefly, never the beacon. Upstream host defaults to our Umami instance, overridable with the `ANALYTICS_UPSTREAM` Pages env var for self-hosters.
- `+layout.svelte`: load the tracker from same-origin `/u/mami` (was `{PUBLIC_ANALYTICS_URL}/script.js`). The tracker derives its beacon endpoint from its own script directory, so it posts to `/u/api/send`.
- Gate the tag on `PUBLIC_ANALYTICS_ID` alone; the upstream URL now lives in the Function, so drop `PUBLIC_ANALYTICS_URL` from the frontend and the CI build env.
- Docs: add `functions/CLAUDE.md`; update architecture, deploying, AGENTS, and `.env.example`.
- Ignore the local `.wrangler/` dir that `wrangler pages dev` creates.
|`PUBLIC_CORS_PROXY_URL`| Frontend (`.env`) |`https://cors.isomorphic-git.org`| URL of your deployed CORS proxy |
140
+
|`PUBLIC_SHARED_CACHE_URL`| Frontend (`.env`) | _(none)_ | URL of shared cache API (same as CORS proxy when R2 is enabled) |
141
+
|`PUBLIC_CACHE_WRITE_TOKEN`| Frontend (`.env` / `ci.yml`) | _(none)_ | Bearer token for cache writes (must match worker secret below) |
142
+
|`ALLOWED_ORIGIN`| Worker (`wrangler.toml`) |`https://gitstrata.com`| CORS origin restriction — override in`.dev.vars`forlocal dev |
143
+
|`CACHE_WRITE_TOKEN`| Worker secret / `.dev.vars`| _(none)_ | Server-side token that cache PUT requests are checked against |
144
+
|`PUBLIC_ANALYTICS_ID`| Frontend (`.env`) | _(none)_ | Umami website ID (UUID from your Umami dashboard) — set to enable tracking |
145
+
|`ANALYTICS_UPSTREAM`| Pages Function (runtime var) | git strata's Umami instance| Your Umami server URL that `/u/*` proxies to (for example, `https://umami.yourdomain.com`) |
146
146
147
147
`PUBLIC_CACHE_WRITE_TOKEN` and `CACHE_WRITE_TOKEN` must have the same value. The frontend token is hard-coded in
148
148
`ci.yml` for production builds. The worker token is set via `wrangler secret put` (production) or `cors-proxy/.dev.vars`
149
149
(local dev).
150
150
151
-
Both `PUBLIC_ANALYTICS_URL` and `PUBLIC_ANALYTICS_ID` must be set to enable analytics. When either is missing, no
152
-
tracking script is loaded.
151
+
Set `PUBLIC_ANALYTICS_ID` to enable analytics. When it's missing, no tracking script is loaded. The tracker loads
152
+
first-party from the Pages Function at `/u/*` (see `functions/CLAUDE.md`) so adblockers don't strip it — this dodges the
153
+
third-party analytics domain and the well-known `/script.js` filename, both on adblock blocklists. Set
154
+
`ANALYTICS_UPSTREAM` on the Pages project (Cloudflare dashboard > **Settings > Environment variables**) to point `/u/*`
155
+
at your own Umami host.
153
156
154
157
Frontend variables are set at build time in CI (see the `deploy-frontend` job in `ci.yml`). For local development,
0 commit comments