From cb2a202a0f7e2f25c9eaf64bc53589b892a5900d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ullrich=20Sch=C3=A4fer?= Date: Wed, 25 Mar 2026 09:02:13 +0100 Subject: [PATCH] Filter 404s from Sentry on client and server Client ErrorBoundary: skip captureException for HTTP errors < 500. Server beforeSend: drop events where __serialized__.status is 404. Resolves JOURNAL-2 and JOURNAL-8 (scanner bot noise). Co-Authored-By: Claude Opus 4.6 (1M context) --- apps/journal/app/entry.server.tsx | 6 ++++++ apps/journal/app/root.tsx | 5 ++++- apps/planner/app/root.tsx | 4 +++- apps/planner/server.ts | 5 +++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/apps/journal/app/entry.server.tsx b/apps/journal/app/entry.server.tsx index e7df39c..01dbf3d 100644 --- a/apps/journal/app/entry.server.tsx +++ b/apps/journal/app/entry.server.tsx @@ -15,6 +15,12 @@ Sentry.init({ environment: sentryEnvironment, tracesSampleRate: 1.0, enabled: process.env.NODE_ENV === "production" && !process.env.CI, + beforeSend(event) { + // Drop 404s — they're expected (scanners, typos), not bugs + const serialized = event.extra?.__serialized__ as Record | undefined; + if (serialized?.status === 404) return null; + return event; + }, }); export const streamTimeout = 5_000; diff --git a/apps/journal/app/root.tsx b/apps/journal/app/root.tsx index fb07974..cdd85c1 100644 --- a/apps/journal/app/root.tsx +++ b/apps/journal/app/root.tsx @@ -123,7 +123,10 @@ export default function App({ loaderData }: Route.ComponentProps) { } export function ErrorBoundary({ error }: Route.ErrorBoundaryProps) { - Sentry.captureException(error); + // Don't report expected HTTP errors (404, 403) to Sentry + if (!(isRouteErrorResponse(error) && error.status < 500)) { + Sentry.captureException(error); + } const { t } = useTranslation(); if (isRouteErrorResponse(error)) { diff --git a/apps/planner/app/root.tsx b/apps/planner/app/root.tsx index ff708ce..ec78097 100644 --- a/apps/planner/app/root.tsx +++ b/apps/planner/app/root.tsx @@ -33,7 +33,9 @@ export default function App() { } export function ErrorBoundary({ error }: Route.ErrorBoundaryProps) { - Sentry.captureException(error); + if (!(isRouteErrorResponse(error) && error.status < 500)) { + Sentry.captureException(error); + } const { t } = useTranslation(); if (isRouteErrorResponse(error)) { diff --git a/apps/planner/server.ts b/apps/planner/server.ts index d4cfc93..aaa4121 100644 --- a/apps/planner/server.ts +++ b/apps/planner/server.ts @@ -13,6 +13,11 @@ Sentry.init({ environment: sentryEnvironment, tracesSampleRate: 1.0, enabled: process.env.NODE_ENV === "production" && !process.env.CI, + beforeSend(event) { + const serialized = event.extra?.__serialized__ as Record | undefined; + if (serialized?.status === 404) return null; + return event; + }, }); const port = Number(process.env.PORT ?? 3001);