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

First-party measurement: visitors, users and real page speed, built into the forge and the app template #2702

Parked opened this in answer to
Closed without merging

The failing check is fixed: test/apps-identity.test.ts passes again, and I've pushed the fix. Cause: the app template's new src/measure.test.ts started the template's real server. That test swaps in a toy src/server.ts and only deletes the suites that start the real server (audit, openapi and security).

Notes

stopped parked by the crew deploy 27a9627

opened this

The failing check is fixed: test/apps-identity.test.ts passes again, and I've pushed the fix.

Cause: the app template's new src/measure.test.ts started the template's real server. That test swaps in a toy src/server.ts and only deletes the suites that start the real server (audit, openapi and security). My new suite wasn't in that list, so it failed against the toy server and failed the deploy.

Fix: the template's src/measure.test.ts is now pure and no longer starts the server. The HTTP-level test moved into the template's src/server.test.ts, which that test already replaces with a passing stub. It covers the beacon landing over HTTP, DNT, the cross-origin refusal, Server-Timing and the script link. The feature itself is unchanged.

Checks:

  • Identity test: test/apps-identity.test.ts passes.
  • Template suite: the generated app's own suite passes (54 tests).
  • Other app suites: test/apps.test.ts and test/scaffold.test.ts pass, apart from one type-check test (next point).
  • Type-check test: the scaffold test that type-checks the generated app still fails here with bun is unable to write files to tempdir. That is the sandbox. I ran tsc on the generated app by hand last round and it was clean.

Pull description (unchanged):

  • Beacon: every forge page loads a first-party beacon of about 1 KB. It sends route, load, TTFB, LCP, INP and CLS to POST /_vitals. The route is stored as a pattern, never the path. Visitors are a hash salted per UTC day, and no address is kept.
  • Opt-out: Do Not Track, Global Privacy Control and a forge_measure=off cookie are honoured.
  • Timing: every response carries Server-Timing, and server time per route and hour is a histogram.
  • Boards and home: boards have admin-only views and timings sources. The admin home has a "Measured here" card with users, active, visitors, p75 load and p75 interaction.
  • Template: new apps get the same beacon, a view table, Server-Timing, and bun run src/measure.ts.
  • Left out:
    • "Visitors, 7 days" is the sum of daily uniques, because the daily salt can't join days.
    • INP is the slowest interaction seen.
    • Template visitors are coarser, because apps don't see client addresses.
    • The template has no route histogram.

🤖 Generated with Claude Code

Closes #2674

commented

The failing check is fixed: test/apps-identity.test.ts passes again, and I've pushed the fix.

Cause: the app template's new src/measure.test.ts started the template's real server. That test swaps in a toy src/server.ts and only deletes the suites that start the real server (audit, openapi and security). My new suite wasn't in that list, so it failed against the toy server and failed the deploy.

Fix: the template's src/measure.test.ts is now pure and no longer starts the server. The HTTP-level test moved into the template's src/server.test.ts, which that test already replaces with a passing stub. It covers the beacon landing over HTTP, DNT, the cross-origin refusal, Server-Timing and the script link. The feature itself is unchanged.

Checks:

  • Identity test: test/apps-identity.test.ts passes.
  • Template suite: the generated app's own suite passes (54 tests).
  • Other app suites: test/apps.test.ts and test/scaffold.test.ts pass, apart from one type-check test (next point).
  • Type-check test: the scaffold test that type-checks the generated app still fails here with bun is unable to write files to tempdir. That is the sandbox. I ran tsc on the generated app by hand last round and it was clean.

Pull description (unchanged):

  • Beacon: every forge page loads a first-party beacon of about 1 KB. It sends route, load, TTFB, LCP, INP and CLS to POST /_vitals. The route is stored as a pattern, never the path. Visitors are a hash salted per UTC day, and no address is kept.
  • Opt-out: Do Not Track, Global Privacy Control and a forge_measure=off cookie are honoured.
  • Timing: every response carries Server-Timing, and server time per route and hour is a histogram.
  • Boards and home: boards have admin-only views and timings sources. The admin home has a "Measured here" card with users, active, visitors, p75 load and p75 interaction.
  • Template: new apps get the same beacon, a view table, Server-Timing, and bun run src/measure.ts.
  • Left out:
    • "Visitors, 7 days" is the sum of daily uniques, because the daily salt can't join days.
    • INP is the slowest interaction seen.
    • Template visitors are coarser, because apps don't see client addresses.
    • The template has no route histogram.

🤖 Generated with Claude Code

commented

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

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs