We have a beforeSend filter set up with Sentry that looks like this:
beforeSend: (event: Event, hint?: EventHint) => {
if (hint) {
// Filter out some errors we don't care about
const error = hint.originalException
let errorMessage: string | undefined
if (typeof error === 'string') {
errorMessage = error
} else if (error instanceof Error) {
errorMessage = error.message
}
switch (errorMessage) {
case 'timeout':
case 'Invalid to header':
case 'Invalid To header':
case 'Mailbox not enabled':
case 'Auth window was closed by user':
case 'The request timed out.':
case 'Network request failed':
case 'Mail service not enabled':
case 'apiClient is null - call configure first':
case 'Backend Error':
return null
default:
break
}
}
return event
}
This filter doesn’t seem to be filtering out some events I would expect it to, though. We’re still getting reports of “Backend Error” events when those should be filtered out. Here’s an example: https://sentry.io/organizations/ginger-labs-inc/issues/948636756/?project=1393587&query=is%3Aunresolved
Here’s a direct link to the JSON for that event, if that’s helpful: https://sentry.io/organizations/ginger-labs-inc/issues/948636756/events/b3b5ea86fbb2464481d72519c5ece55c/json/
I can see by running window.__SENTRY__.hub._stack[0].client._options.beforeSend.toString()
in the console window for our prod site in Chrome that ‘Backend Error’ is included in the list of events we should be filtering out. I’m seeing this with @sentry/browser 5.0.6.
How can I make the beforeSend function filter out this event? Do I need to check for “UnhandledRejection: Backend Error” too?