observability: backend-agnostic error-capture seam (Phase 1, inert until SENTRY_DSN)

This commit is contained in:
Moheeb Zara
2026-05-21 17:00:37 -07:00
parent 95f79771ec
commit c89e4d95e1
12 changed files with 434 additions and 5 deletions
+27
View File
@@ -0,0 +1,27 @@
// Next.js instrumentation. `onRequestError` is the framework-wide hook that
// fires for any error thrown out of a route handler, server component, or
// server action -- so it is the broad net that gives every server action
// error capture without per-action wiring. Swallowed best-effort failures
// (notification fan-outs, cron soft-fails, the Stripe handler that returns 500
// instead of throwing) do NOT reach this hook, so those are captured manually
// at their sites. Inert until SENTRY_DSN is set (the seam no-ops).
import { captureException } from '@/lib/observability/capture'
export async function register(): Promise<void> {
// No global init: the capture seam is a stateless fetch transport.
}
export async function onRequestError(
err: unknown,
request: { path?: string; method?: string },
context: { routerKind?: string; routePath?: string; routeType?: string },
): Promise<void> {
captureException(err, {
surface: 'request',
tags: {
route: context?.routePath,
routeType: context?.routeType,
method: request?.method,
},
})
}