Skip to content

Hosted: aggregate daily launch counts, link refs, and an admin metrics page - #1398

Merged
nedtwigg merged 4 commits into
mainfrom
hosted-metrics-counts
Oct 28, 2026
Merged

nedtwigg merged 4 commits into
mainfrom
hosted-metrics-counts

Conversation

@nedtwigg

Copy link
Copy Markdown
Member

First-party launch metrics: aggregate daily counts on our own servers. No identifiers are stored and no client telemetry is sent.

  • Counts. A new dormouse_metrics_daily table (migration 013) holds only the UTC day, the event, a label from that event's METRIC_LABELS allowlist, and the count; rows are kept forever. Events counted: enroll.approved [remote|voice], burrow.enrolled, voice.speak [ok|capped|error], voice.fallback-cap (once per account per day), push.sent and pocket.signin. Writes are best effort through waitUntil, so they never change or delay the response they count.
  • Link refs. Every link to dormouse.sh/hosted carries ?ref= from lib/src/lib/hosted-links.ts: the Settings plans and voice links, HostedPlansLink (now taking from), the home page, the Pocket tutorial and playground, HostingRequirementNotice, both READMEs, and the account page's no-plan offer. /hosted strips the ref on arrival. Nothing counts it yet: takeVisitRef() is the seam the PostHog follow-up reads.
  • Admin page. /admin/metrics on the account app is behind a new cookieAdmin gate: 401 when signed out, 404 for anyone but the verified ADMIN_EMAIL. It shows today, the last 30 days and all-time totals, per-label tables, and plain-CSS bars. The page header and footer moved into a shared HostedShell, with the markup unchanged.
  • Specs. A new hosted.md → "Metrics" section. security-hosted.md gets FAIL IF S278 (row shape and admin-only read), cookieAdmin added to S78, and the metric upsert excepted in S110. pricing.md gets the ref rule.
  • Privacy names each kind of count and says the ref is neither counted nor stored.

Login, account-created and billing events wait for a pgstencil hook and for checkout.

#1397 also takes S278, and spec-lint forbids a gap, so whichever PR merges second renumbers to S279.

🤖 Generated with Claude Code

nedtwigg and others added 4 commits October 28, 2026 01:33
A dormouse_metrics_daily row is a UTC day, an event, one of that event's
allowlisted labels, and a count: nothing that names an account. The relay
and voice Workers write theirs on their own roles, best effort through
waitUntil, so a failed write is logged and never changes or delays the
answer it counts. Counted now: approvals by purpose, enrollments, speech by
outcome and the call that spends the day's last, push deliveries, and Pocket
sign-ins. GET /api/admin/metrics reads the last 30 days and all-time totals
for the verified admin only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every link to dormouse.sh/hosted carries ?ref= from one shared list
(lib/src/lib/hosted-links.ts), ahead of its fragment: the Settings plans and
voice links, the home page, the Pocket tutorial and playground, the self-host
page, both READMEs, and the account page's no-plan offer. The Hosted page
takes it off the address bar on arrival, so a copied link never carries it;
nothing counts or sends it yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
/admin/metrics (with or without the trailing slash) reads
/api/admin/metrics and shows each counted event's today, 30-day, and
all-time counts, its labels, and 30 days of plain-CSS bars. Signed out it
links sign-in; anyone but the admin sees Not found. The header and footer
move into HostedShell, which the account page now shares.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hosted.md gains a Metrics section (the events, labels refused off-list,
best-effort writes); security-hosted.md a FAIL IF (S278) on what a row may
hold and who reads the admin route, with cookieAdmin on the account-boundary
inspect list; pricing.md the ref every Hosted page link carries. Privacy
names each kind of count and says a link's label is stripped, never counted.
A canary patch takes the new migration pin as context.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Deploying mouseterm with  Cloudflare Pages  Cloudflare Pages

Latest commit: d6d7c52
Status: ✅  Deploy successful!
Preview URL: https://001442e0.mouseterm.pages.dev
Branch Preview URL: https://hosted-metrics-counts.mouseterm.pages.dev

View logs

@nedtwigg
nedtwigg merged commit 5da3d1e into main Oct 28, 2026
18 checks passed
@nedtwigg
nedtwigg deleted the hosted-metrics-counts branch October 28, 2026 08:57
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