Staging needs named rule admins, an ops bearer token, and cookieless Umami without rebuilding the Next image every time env changes.
NEXT_PUBLIC_* is normally inlined at build time, so cloudron env set would not show the tracker. This reads the Umami vars at request time, always allows the analytics host in CSP, and documents the staging env plus smoke checks.
Changes
lib/umami.ts — read NEXT_PUBLIC_UMAMI_SRC / NEXT_PUBLIC_UMAMI_WEBSITE_ID by key at call time (not a static process.env.NEXT_PUBLIC_* lookup that gets inlined).
app/layout.tsx — Umami script in a Suspense child that await connection(), so the tracker can appear after env is set, with data-do-not-track and data-exclude-search.
next.config.mjs — CSP always allows https://analytics.communityrule.info for script and connect, even when the tracker is off.
scripts/staging-smoke.sh — logged-out /api/ops/rule-counts expects 401 (or 404 skip if neither admin emails nor token is set); optional bearer 200; homepage data-website-id (required only with EXPECT_UMAMI=1).
Docs: staging env for RULE_ADMIN_EMAILS and OPS_PRUNE_TOKEN, Umami install with --no-sso, smoke flags.
Tests for request-time Umami env and the analytics origin in CSP.
Screenshots
How to Test
npx vitest run tests/unit/umami.test.ts tests/unit/securityHeaders.test.ts
npx tsc --noEmit
Against staging (token from 1Password, do not paste it into the PR):
## Overview
Staging needs named rule admins, an ops bearer token, and cookieless Umami without rebuilding the Next image every time env changes.
`NEXT_PUBLIC_*` is normally inlined at build time, so `cloudron env set` would not show the tracker. This reads the Umami vars at request time, always allows the analytics host in CSP, and documents the staging env plus smoke checks.
## Changes
- `lib/umami.ts` — read `NEXT_PUBLIC_UMAMI_SRC` / `NEXT_PUBLIC_UMAMI_WEBSITE_ID` by key at call time (not a static `process.env.NEXT_PUBLIC_*` lookup that gets inlined).
- `app/layout.tsx` — Umami script in a Suspense child that `await connection()`, so the tracker can appear after env is set, with `data-do-not-track` and `data-exclude-search`.
- `next.config.mjs` — CSP always allows `https://analytics.communityrule.info` for script and connect, even when the tracker is off.
- `scripts/staging-smoke.sh` — logged-out `/api/ops/rule-counts` expects 401 (or 404 skip if neither admin emails nor token is set); optional bearer 200; homepage `data-website-id` (required only with `EXPECT_UMAMI=1`).
- Docs: staging env for `RULE_ADMIN_EMAILS` and `OPS_PRUNE_TOKEN`, Umami install with `--no-sso`, smoke flags.
- Tests for request-time Umami env and the analytics origin in CSP.
## Screenshots

## How to Test
1. `npx vitest run tests/unit/umami.test.ts tests/unit/securityHeaders.test.ts`
2. `npx tsc --noEmit`
3. Against staging (token from 1Password, do not paste it into the PR):
```bash
./scripts/staging-smoke.sh staging.communityrule.info
EXPECT_UMAMI=1 OPS_PRUNE_TOKEN=... ./scripts/staging-smoke.sh staging.communityrule.info
Tracker env is read at request time and the CSP already allows the analytics host, so staging can set a rule admin, an ops bearer token, and the cookieless Umami site without rebuilding.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Overview
Staging needs named rule admins, an ops bearer token, and cookieless Umami without rebuilding the Next image every time env changes.
NEXT_PUBLIC_*is normally inlined at build time, socloudron env setwould not show the tracker. This reads the Umami vars at request time, always allows the analytics host in CSP, and documents the staging env plus smoke checks.Changes
lib/umami.ts— readNEXT_PUBLIC_UMAMI_SRC/NEXT_PUBLIC_UMAMI_WEBSITE_IDby key at call time (not a staticprocess.env.NEXT_PUBLIC_*lookup that gets inlined).app/layout.tsx— Umami script in a Suspense child thatawait connection(), so the tracker can appear after env is set, withdata-do-not-trackanddata-exclude-search.next.config.mjs— CSP always allowshttps://analytics.communityrule.infofor script and connect, even when the tracker is off.scripts/staging-smoke.sh— logged-out/api/ops/rule-countsexpects 401 (or 404 skip if neither admin emails nor token is set); optional bearer 200; homepagedata-website-id(required only withEXPECT_UMAMI=1).RULE_ADMIN_EMAILSandOPS_PRUNE_TOKEN, Umami install with--no-sso, smoke flags.Screenshots
How to Test
npx vitest run tests/unit/umami.test.ts tests/unit/securityHeaders.test.tsnpx tsc --noEmitAgainst staging (token from 1Password, do not paste it into the PR):