Filtering unhandledrejection events from browser extensions

We currently use a handler to publish errors for unhandledrejection events with something like the following:

window.addEventListener('unhandledrejection', (event) => {
  if (error.reason) {
    if (error.reason instanceof Error) {
      raven.captureException(error.reason);      
    } else {
      raven.captureMessage('unhandledrejection.reason has type: ' + typeof error.reason);
    }
  } else {
    raven.captureMessage('unhandledrejection.reason was undefined');
  }
});

This generally works fine, but we recently experienced a significant spike in errors where the reason was undefined. We were ultimately able to identify a Chrome Extension as the root cause, but the process was far from perfect and is likely to recur.

Ideally we’d be able to address this more broadly and either only capture unhandledrejection events that originate from our app code or filter events from browser extensions. Is anyone aware of any approaches to accomplish this?

Thanks in advance

Have you tried using whitelistUrls to whitelist errors to only those occurring from your scripts?