Reputation: 4656
With the deprecated client Raven you could ignore troublesome errors :
Raven.config('your-dsn', {
ignoreErrors: [
'Can\'t execute code from freed script',
/SecurityError\: DOM Exception 18$/
]
}).install();
The only way I found with the new client is with the before-send
hook :
https://docs.sentry.io/error-reporting/configuration/filtering/?platform=browser#before-send
import * as Sentry from '@sentry/browser';
init({
beforeSend(event, hint) {
const { message } = hint.originalException;
if (message && message.match(/database unavailable/i)) {
return null;
}
return event;
}
});
I searched all over the docs but didn't find a global way to ignore errors.
Upvotes: 8
Views: 36356
Reputation: 29
I have to solve it in this way according to the documentation.
https://docs.sentry.io/platforms/javascript/guides/vue/configuration/filtering/
let ignoreError = false;
Sentry.init({
Vue,
dsn: getEnv("SENTRY_DSN"),
beforeBreadcrumb: (response) => {
if (response &&
response.category &&
response.category === "xhr" &&
response.data &&
response.data.status_code &&
response.data.status_code == 401 || 404
) {
ignoreError = true;
} else {
ignoreError = false;
}
},
beforeSend: (event, hint) => {
if (ignoreError) {
return null;
}
return event;
},
environment: getEnv("NODE_ENV"),
sampleRate: parseFloat(getEnv("SENTRY_SAMPLE_RATE")),
integrations: [
new BrowserTracing({
routingInstrumentation: Sentry.vueRouterInstrumentation(router),
tracingOrigins: [getEnv("SENTRY_TRACING_ORIGINS")],
}),
],
trackComponents: true,
logError: true,
debug: false,
tracesSampler: samplingContext => {
if (samplingContext?.transactionContext?.name === 'GET /health') {
return 0.0;
} else {
return parseFloat(getEnv("SENTRY_TRACES_SAMPLE_RATE"));
}
},
});
export default Sentry
Upvotes: 1
Reputation: 578
simple, im using this config for nuxtjs app in nuxt.config.js
sentry: {
disabled: process.env.APP_ENV === 'development',
dsn: 'xxxx'
maxBreadcrumbs: 50,
config: {
environment: process.env.APP_ENV,
debug: process.env.APP_ENV === 'development',
release: '1.0.0',
beforeSend: (event, hint) => {
// see all errors, what you wants.
// using console.log(hint.originalException)
// for example, not send when error code 404 when using axios
const { response } = hint.originalException
if (response && response.status && response.status === 404) {
return null
}
return event
}
}
},
Upvotes: 4
Reputation: 12437
There seems to be an ignoreErrors
config option. It's documented in their example app here:
Upvotes: 23
Reputation: 415
Plain JS:
process.on('unhandledRejection', (reason, promise) => {
//console.log('(Custom message) Unhandled Rejection found at:', reason.stack, reason.caputureStackTrace);
console.log('Unhandled Rejection at: Promise', promise, 'reason:', reason, reason.constructor.name);
});
I guess your regex doesn't match, try: /SecurityError\\: DOM Exception 18$/
instead of /SecurityError\: DOM Exception 18$/
, notice \\
Upvotes: 1