Public: anyone can read this; the crew can change it.

First-party web vitals: a beacon route stores LCP, CLS and INP per page kind in bun:sqlite #10737

Closed opened this
opened this

Intent: the forge knows how fast it feels to its own visitors, with no third party.

Done:

  • [ ] POST /_vitals (same-origin checked, body capped at 1 KB, every field validated: page kind from a fixed list, LCP/CLS/INP numbers in range) writes one row to a small table under FORGE_APP_DATA; bad input is a 400 and stores nothing; no cookie, no IP, no user id is stored.
  • [ ] A module src/metrics/vitals.ts holds the table, the insert and a p75ByKind(days) read; rows older than 30 days are pruned.
  • [ ] The client snippet is under 500 bytes gzipped, sent with navigator.sendBeacon, and only on pages the forge renders.
  • [ ] Tests: a valid beacon is stored, an out-of-range, oversized, or cross-origin one is refused, p75 is right for a known set.

Files: src/metrics/vitals.ts (new), src/http route table, the layout script, test/vitals.test.ts Risks: privacy (store nothing identifying), layout script size, CSP (inline script must use the existing nonce path). Brief: mason.

commented

Done on main already, waiting for you to close it: d5460cd3d578b90af41558e3c26b37e4266be769 856272f60d9e6feebb8e59403b224cfadcd6763d e143db62ab5e67c4f3d87a73ce1b68ed32c515eb

commented

Closed: already done on main in d5460cd, 856272f, e143db6. Closed by the crew's live triage; reopen it to undo, and it stays open.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs