[READ-ONLY] Mirror of https://github.com/openstatusHQ/openstatus. 🫖 Status page with uptime monitoring & API monitoring as code 🫖 openstatus.dev
bun drizzle-orm monitoring monitoring-as-code nextjs observability on-call open-source shadcn-ui status-page statuspage synthetic-monitoring tinybird turso uptime uptime-checker uptime-monitor

Centralize tRPC error handling and Sentry filtering (#2391) master

* fix(dashboard): stop reporting expected tRPC client errors to Sentry The `monitor 8197 not found` Sentry noise (OPENSTATUS-7MR) came from `createOnError` in the tRPC route handler unconditionally `console.error`-ing every failed procedure. captureConsoleIntegration then shipped those console.error calls to Sentry, including expected 4xx client errors like NOT_FOUND. - Skip logging expected client error codes in `createOnError`, so the console integration never sees them. - Harden the `beforeSend` guard: `instanceof TRPCError` failed across bundle boundaries (the config's `@trpc/server` copy differs from the app chunk's), so match on the duck-typed `name === "TRPCError"` + code instead, and cover the full set of expected codes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EGFu8ChhYtctyi2WatLPo6 * refactor(dashboard): restore tRPC error-code type safety Address review: use the real `TRPCError["code"]` type instead of loose `string` for the ignore/expect code lists, via a type-only import of `@trpc/server` (compile-time only, no runtime bundle concern). The `onError` payload is typed as `Pick<TRPCError, "code" | "message">` and `isIgnoredTRPCError` narrows to `TRPCError`. Only the runtime `instanceof` is avoided — that's the part that breaks across the app/instrumentation bundle split; the type is safe to import. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EGFu8ChhYtctyi2WatLPo6 * refactor(api): centralize tRPC error classification for Sentry Extract the expected-client-error logic into `@openstatus/api/src/trpc-errors` so all three Next.js apps (dashboard, status-page, web) share one source of truth instead of each duplicating the code list and guard: - `EXPECTED_TRPC_CODES` / `isExpectedTRPCErrorCode` — the 4xx code set. - `isExpectedTRPCError` — duck-typed guard for Sentry `beforeSend` (`instanceof TRPCError` is unreliable across the app/instrumentation bundle split). - `createTRPCOnError` — route-handler `onError` that skips logging expected client errors, so captureConsoleIntegration doesn't report them. The module only type-imports `@trpc/server`, so it stays safe to import from the edge and client Sentry configs. Each app's sentry.{server,edge}.config and tRPC route handler now import from the package; the per-app `createOnError` duplicates are removed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EGFu8ChhYtctyi2WatLPo6 * test(api): cover trpc-errors classification helpers Unit tests for the shared tRPC error utilities: expected-code matching, the duck-typed `isExpectedTRPCError` guard (including the cross-bundle name+code case and non-error inputs), and `createTRPCOnError`'s logging gate (silent for client errors, logs server errors). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EGFu8ChhYtctyi2WatLPo6 --------- Co-authored-by: Claude <noreply@anthropic.com>


+170 -109
14 changed files