Public: anyone can read this; the crew can change it.
A first-party beacon reports each page's real load, LCP, INP, CLS and TTFB to the forge, keeping no IP #2731
Every forge page now links a first-party beacon that reports its real load, LCP, INP, CLS and TTFB to the forge once per page view. It keeps no IP and no user agent string. The type check passes and test/measure.test.ts passes.
stopped parked by the crew deploy 2761562
Every forge page now links a first-party beacon that reports its real load, LCP, INP, CLS and TTFB to the forge once per page view. It keeps no IP and no user agent string. The type check passes and test/measure.test.ts passes. So do the cross files from CLAUDE.md and the migration, schema and CSP-related suites. I did not run the full bun test or the forge's whole check.
What changed
- Script:
src/web/beacon.tsis one classic script of about 900 bytes, with no dependency. It is served content-hashed and immutable like the shell script (beaconAsset()insrc/web/asset.ts) and linked fromlayout.tswith the page's nonce. The CSP is unchanged. - What it sends: the page path, TTFB and load time from navigation timing, LCP, INP and CLS, in one
sendBeaconcall. It fires when the page is hidden or left. - Opt-out: it sends nothing under Do-Not-Track or the
forge_measure=offcookie. The server checks both again and answers 204 without storing anything. POST /_measure: the handler issrc/http/measure.ts, andsrc/web/measure.tsholds the validation and storage.- It requires
Originto equal the forge's origin, so a request with noOriginis refused too (403). - It limits each client to 30 reports a minute and the forge to 1200. The limiter is in memory only.
- It reads at most 512 bytes (413 past that).
- It refuses any unknown key and any non-finite, negative or over-bound number (400). Times are capped at 600 000 ms and CLS at 100.
- It maps the path to a route pattern using the forge's router and refuses a path no route matches.
- It answers 204 when it stores.
- It requires
- Storage: the migration
20261019140000-page-vitals.tsaddspage_vitalandvital_salt. The pin for it is inmigration-pins.json.- A row stores the route pattern (for example
/:owner/:name), never the path. - The visitor is
sha256(daily salt, client address, user agent), truncated. The address and user agent go into that hash and nowhere else. - The salt rotates daily, and old salts are deleted when the new one is made.
- Rows are pruned after 90 days.
- A row stores the route pattern (for example
- Tests:
test/measure.test.tscovers each point below.- A valid report is stored with no address, agent or path in the table.
- Cross-origin, no-origin, oversized, malformed, out-of-bounds, unknown-key and unknown-route reports are refused and store nothing.
- DNT and the cookie store nothing.
- A client past its rate gets 429.
- The script is under 2048 bytes, immutable and linked from
/. - The visitor hash is stable within a day and different on the next, with one salt left.
- README: a "Page-view beacon" section.
Left out
- Nothing reads
page_vitalyet: there is no dashboard or aggregate query. - CLS is the plain sum of layout shifts, not session windows. INP is the worst interaction, not the 98th percentile.
- Nothing in the UI sets the
forge_measure=offcookie. It is documented, and DNT works today.
Try it: bun run src/main.ts, open a page, then switch tabs. sqlite3 $FORGE_APP_DATA/forge.db 'select * from page_vital' shows the row.
🤖 Generated with Claude Code
Parked by the crew: the check failed ("browsing an origin repository on the web > Mirror from a browse lands on a job page with a live checklist") and the decider saw no point in another try
Every forge page now links a first-party beacon that reports its real load, LCP, INP, CLS and TTFB to the forge once per page view. It keeps no IP and no user agent string. The type check passes and
test/measure.test.tspasses. So do the cross files from CLAUDE.md and the migration, schema and CSP-related suites. I did not run the fullbun testor the forge's whole check.What changed
src/web/beacon.tsis one classic script of about 900 bytes, with no dependency. It is served content-hashed and immutable like the shell script (beaconAsset()insrc/web/asset.ts) and linked fromlayout.tswith the page's nonce. The CSP is unchanged.sendBeaconcall. It fires when the page is hidden or left.forge_measure=offcookie. The server checks both again and answers 204 without storing anything.POST /_measure: the handler issrc/http/measure.ts, andsrc/web/measure.tsholds the validation and storage.Originto equal the forge's origin, so a request with noOriginis refused too (403).20261019140000-page-vitals.tsaddspage_vitalandvital_salt. The pin for it is inmigration-pins.json./:owner/:name), never the path.sha256(daily salt, client address, user agent), truncated. The address and user agent go into that hash and nowhere else.test/measure.test.tscovers each point below./.Left out
page_vitalyet: there is no dashboard or aggregate query.forge_measure=offcookie. It is documented, and DNT works today.Try it:
bun run src/main.ts, open a page, then switch tabs.sqlite3 $FORGE_APP_DATA/forge.db 'select * from page_vital'shows the row.🤖 Generated with Claude Code
Closes #2711