Consolidate Sentry config into shared package; fix inconsistencies

Introduces @trails-cool/sentry-config with three helpers that encode
the common Sentry.init options:
- nodeSentryConfig(appContext) for the two HTTP servers
- browserSentryConfig(appContext, env) for the Journal client
- mobileSentryConfig(__DEV__) for the React Native app
- drop404s beforeSend for servers

Also fixes three inconsistencies found in the audit:
- Planner server was missing sendDefaultPii: false (IPs could leak)
- Planner entry.server.tsx didn't call Sentry.captureException on SSR
  render errors; Journal's SSR did
- Sentry.init location now matches across apps (both in server.ts;
  Journal previously had it in app/entry.server.tsx, which meant init
  ran lazily on first request rather than at server startup)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ullrich Schäfer 2026-04-18 00:30:09 +02:00
parent 4092f21475
commit 8e576ac578
No known key found for this signature in database
GPG key ID: A32FF691A0F752D9
13 changed files with 160 additions and 64 deletions

View file

@ -1,3 +1,4 @@
import * as Sentry from "@sentry/node";
import { PassThrough } from "node:stream";
import type { AppLoadContext, EntryContext } from "react-router";
import { createReadableStreamFromReadable } from "@react-router/node";
@ -71,6 +72,7 @@ export default function handleRequest(
responseStatusCode = 500;
if (shellRendered) {
console.error(error);
Sentry.captureException(error);
}
},
},