Skip to content

feat(error-tracking): Next.js 14/15/16 fixtures with scenario manifests - #4805

Draft
ablaszkiewicz wants to merge 2 commits into
mainfrom
mfga/nextjs
Draft

ablaszkiewicz wants to merge 2 commits into
mainfrom
mfga/nextjs

Conversation

@ablaszkiewicz

@ablaszkiewicz ablaszkiewicz commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Pull requests: 1. PostHog/posthog-js#5472 2. PostHog/posthog-js#5473 3. PostHog/context-mill#446 4. 👉 this PR 5. PostHog/posthog#125314

Problem

The Next.js error-tracking fixtures (next, no-posthog-next) have one page each, so a run touches almost none of the places a Next.js app throws: server components, route handlers, server actions, the proxy, edge routes, after(), background promises. Nothing records what each run should capture, so a run that loses every server error still looks like a pass.

Changes

Four fixtures, one invoicing app (Ledgerly) so their scenarios line up. Each scenario is a plausible bug reached by a fixed input, with an opaque error code and its own error class.

App Stack What it tests
no-posthog-next-16-app Next.js 16.4.2, App Router, Turbopack, no PostHog 15 scenarios: client render under error.tsx and at the root, onClick, Server Component render, generateMetadata, route handlers (tracing headers, page fetch), server action, proxy.ts, edge route, after(), fire-and-forget rejection, timer throw, notFound(), redirect()
next-16-app Same app with posthog-js and posthog-node already used for analytics, and a branded global-error.tsx The same 15, from an existing init
no-posthog-next-14-app Next.js 14.2.35, App Router, webpack, edge middleware.ts 14: no onRequestError and no client error callbacks on this version
no-posthog-next-15-pages Next.js 15.5.28, Pages Router, webpack 11: getServerSideProps, API routes, edge API route, edge middleware, the default _error 404
  • apps/error-tracking/.scenarios/<app>.json: one machine-checkable manifest per app (how to build and start it, how to trigger each error, what PostHog must receive). It sits outside the app directories, so the agent never sees it. .scenarios/README.md documents the schema.
  • apps/error-tracking/README.md: prose expectations for the four apps.
  • Lockfiles resolved with a seven-day cooldown (npm install --before).

How it was tested

  • Every scenario shows its symptom in a production build without PostHog (55 of 55): the expected status, page error or console error.
  • wizard error-tracking on each app, then each instrumented copy was exercised in a browser and over HTTP and checked in PostHog: count, issue, $lib, distinct ID and session, request properties, release, top stack frame. The results drove the context-mill and docs changes above.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FkuJAD3n8f6Ra7L9p2UmPw

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.

1 participant