Automated scanners probing for WordPress paths (/blog/wp/v2/posts/*, POST /) generate a React Router 404 or 405 on every hit, and handleError forwarded all of them to Sentry, exhausting the quota. The existing defence was a list of ignoreErrors regexes that needed a new entry for each scanner pattern. Filter on what the error is instead: shouldReportServerError drops 4xx responses React Router generated itself (internal: true) for requests that matched nothing. Responses the app throws deliberately still report, as do all 5xx and real exceptions. A request carrying a same-origin Referer is still reported, so a broken internal link remains visible in Sentry -- only cold scanner hits are dropped. No HTTP response changes; every URL returns the status and page it did before. Also adds /blog to the Express bot-probe filter so the highest-volume path 404s without an SSR render, and removes the now-redundant route-404 ignoreErrors entries. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ESrxBMZMx2BD9rcKTCgLe4
14 lines
492 B
JavaScript
14 lines
492 B
JavaScript
import * as Sentry from '@sentry/react-router';
|
|
|
|
Sentry.init({
|
|
dsn: "https://1a366de494f1acf8fc94a4c592807b10@o1356837.ingest.us.sentry.io/4511024367861760",
|
|
enabled: process.env.NODE_ENV === "production",
|
|
sendDefaultPii: true,
|
|
tracesSampleRate: 0,
|
|
beforeSend(event) {
|
|
const msg = event.exception?.values?.[0]?.value ?? "";
|
|
// Drop React Flight protocol probe errors (e.g. $1:aa:aa in multipart body)
|
|
if (/\$\d+:[a-z]/.test(msg)) return null;
|
|
return event;
|
|
},
|
|
});
|