Skip to content

feat(server): a request wide event for every route - #488

Merged
allisonmahmood merged 5 commits into
mainfrom
t3code/implement-issue-37
Oct 2, 2026
Merged

allisonmahmood merged 5 commits into
mainfrom
t3code/implement-issue-37

Conversation

@allisonmahmood

@allisonmahmood allisonmahmood commented Oct 2, 2026 •

Copy link
Copy Markdown
Owner

When someone says "publish failed", there's nothing to look at: only /api/runtime/* produced wide events. Publish, the portal, sign-in, device login, connections, served pages and the SDK tarball left no trace.

Now every request outside the runtime path emits one type: "request" event through the existing WideEvents service (stdout for CloudWatch, plus PostHog):

  • Route template, never the URL. Effect's router only knows the matched route inside route middleware, so the event opens there and records route (e.g. /api/patches/:patchRef, /:company/:name/*, or /* / /api/* for unmatched requests), method and status. Two things happen before routing and are recorded at the edge: the API guard's own answers go under /api/* (with the refusing limitId on a 429), and a target the router can't decode at all goes under /*. The edge also keeps the method the client sent, since Serving answers HEAD as GET.
  • Outcome is what the client received. 2xx/3xx success, 4xx refused with the body's code, 5xx failure, interruption interrupted (with the status the server answers). This includes responses the server derives from a failed exit, such as a query that doesn't decode (400, refused); the cause is re-raised outside the event, so the server's response and error reporting are unchanged.
  • Attribution where identity already resolves. Bearer auth and the session helpers add viewerId and companyId; publish (including replays), served pages, patch reads, portal pages and :patchId routes add patchId, and versionId for the version served, created or current (a rollback records the one it made current). Tokens, cookies, codes, bodies, filenames and paths never reach an event; a test pins that across a publish, a cookie page view and a full device-login exchange.
  • Left alone: runtime routes keep their own events, unchanged, and /healthz emits nothing.

docs/OPERATIONS.md describes the events and how to find one in CloudWatch Logs Insights. It says "the host service's log group" until #415 names it.

One side effect: the guard doesn't classify PUT /api/runtime/staged-files/… or GET /api/runtime/file-handles/… as runtime, so a 429 on those now emits a guard event under /api/* where nothing was recorded before. It never doubles a runtime event.

Closes #37

Made by Claude Opus 5.5 via Claude Code; reviewed by GPT 6.1 Sol via codex.

@github-actions github-actions Bot added area:server Touches the server area area:docs Touches the docs area area:ui Portal and first-party browser pages, shared rendering and styles size:l 501-1,000 changed lines labels Oct 2, 2026
@allisonmahmood
allisonmahmood force-pushed the t3code/implement-issue-37 branch 2 times, most recently from 08b055d to 0b9a396 Compare October 2, 2026 20:37
allisonmahmood and others added 5 commits October 2, 2026 23:07
Only /api/runtime/* produced wide events; publish, the portal, sign-in,
device login, connections, patch serving and the SDK left no trace.

Route middleware now opens one request event per routed request, named
by the matched template, never the URL. The outcome follows the status
the client received, and a refusal carries its body's code. The API guard
records its own answers under /api/*. Runtime routes keep their own
events, and health probes emit none. Auth, Patches, Serving and Portal
name the viewer, company, patch and version where they resolve them.

Closes #37.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A request the server answers itself, such as a query that does not decode,
failed the event's exit and was recorded as a failure. The event now closes
over the exit and takes its outcome from the response the server derives,
then raises the cause again for the server to answer and report. A
replayed publish names its patch and version, the guard picks one bucket,
and the tests decode bodies and check more of what must stay off events.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A target the router could not decode failed before even the `/*` fallback
and left no event; an outermost middleware now records it there, and keeps
the method the client sent, since Serving answers HEAD as GET before routing.
Recording a response now survives the handler's interruption. Routes about
one patch record its current version, and a rollback the version it made
current.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Retire, restore, describe and delete answered with the patch but recorded
only its id; they now record its current version too, as reads do.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…sion

Sharing and reading the inventory recorded only the patch id. setScope now
returns the patch's id and current version with its scope, and the
inventory read records them where it locks the row, so every route about
one patch names a version.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@allisonmahmood
allisonmahmood force-pushed the t3code/implement-issue-37 branch from 0b9a396 to 370c293 Compare October 2, 2026 21:07
@allisonmahmood
allisonmahmood merged commit d5bb7a6 into main Oct 2, 2026
11 checks passed
@allisonmahmood
allisonmahmood deleted the t3code/implement-issue-37 branch October 2, 2026 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:docs Touches the docs area area:server Touches the server area area:ui Portal and first-party browser pages, shared rendering and styles size:l 501-1,000 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(server): a request wide event for every route

1 participant