Block common bot scanning paths (wp-admin, .env, .php, etc.) in Express before React Router handles them, preventing spurious Sentry errors. Also filter Sentry events for React Flight protocol probes ($1:aa:aa multipart body pattern) and any remaining bot-path 404 noise. https://claude.ai/code/session_01Y5Ca6oxd5zyyM89acmogf7
23 lines
No EOL
932 B
JavaScript
23 lines
No EOL
932 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,
|
|
ignoreErrors: [
|
|
/No route matches URL ".*\.css"/,
|
|
/No route matches URL ".*\.js"/,
|
|
/No route matches URL ".*\.(php|env|xml|aspx|asp|bak|sql|ini)"/i,
|
|
/No route matches URL ".*\/(wp-admin|wp-login|phpmyadmin|xmlrpc)"/i,
|
|
],
|
|
beforeSend(event) {
|
|
const url = event.request?.url ?? "";
|
|
const msg = event.exception?.values?.[0]?.value ?? "";
|
|
// Drop React Flight protocol probe errors (e.g. $1:aa:aa in multipart body)
|
|
if (msg.includes("$1:")) return null;
|
|
// Belt-and-suspenders: drop any remaining bot probe URL errors
|
|
if (/\.(php|env|htaccess|xml|aspx|bak|sql)$|wp-admin|phpmyadmin/i.test(url)) return null;
|
|
return event;
|
|
},
|
|
}); |