@sentry/browser
@sentry/node
raven-js
raven-node
_(raven for node)_4.0.4
Is it possible to filter out ReportingObserver events from Chrome extensions like we can with regular Sentry errors? We just got one like:
{
anticipatedRemoval: 2019-03-12T04:00:00.000Z,
columnNumber: 307,
id: ElementCreateShadowRoot,
lineNumber: 2,
message: [Filtered],
sourceFile: chrome-extension://mgijmajocgfcbeboacabfgobmjgjcoja/content.min.js
}
Yes, ReportingObserver events are the very same events you'd get for regular exceptions. You can use eventProcessing to filter one you don't need - https://github.com/getsentry/sentry-javascript/blob/9c131a04dec99fd9716d3b9e850082680f21e497/packages/browser/src/integrations/reportingobserver.ts#L94-L127
init({
dsn: '__DSN__',
beforeSend(event) {
// Detect if we got a ReportingObserver event
if (event.message && event.message.startsWith('ReportingObserver')) {
// And check if the observer's report had a body, if so, check whether sourceFile points to chrome-extension. If so, drop the event.
if (event.extra.body && event.extra.body.sourceFile && event.extra.body.sourceFile.startsWith('chrome-extension')) return null;
}
// Otherwise, just let it through
return event;
}
})
Or see this comment to see how to do it as a separate event processor - https://github.com/getsentry/sentry-javascript/issues/1329#issuecomment-423979370
Hope that helps. Cheers!
I appreciate the snippet, but am concerned that I could not find this in the docs: https://docs.sentry.io/search/?platform=browser&q=beforesend
@vincentwoo https://docs.sentry.io/learn/hints/?platform=browser#before-send
Thanks for the snippet but I think there should be a correction:
beforeSend(event) {
// Detect if we got a ReportingObserver event
if (event.message && event.message.startsWith('ReportingObserver')) {
// And check if the observer's report had a body, if so, check whether sourceFile points to chrome-extension. If so, drop the event.
if (
event.extra.body &&
+ event.extra.body.sourceFile &&
event.extra.body.sourceFile.startsWith('chrome-extension')
) {
return null;
}
}
// Otherwise, just let it through
return event;
}
without it I'm currently getting the error Cannot read property 'startsWith' of undefined
You're right. Updated :) Thanks!
Worth noting here that #1713 removed ReportingObserver from the defaults, so starting with v4.3.0+ this shouldn't be an issue anymore 馃槃
Most helpful comment
Worth noting here that #1713 removed ReportingObserver from the defaults, so starting with v4.3.0+ this shouldn't be an issue anymore 馃槃