Skip to content

Loader ignores the ignoreErrors and beforeSend options in init #3117

@brenogazzola

Description

@brenogazzola

Package + Version

  • @sentry/browser
  • @sentry/node
  • raven-js
  • raven-node (raven for node)
  • other: loader

Version:

https://js.sentry-cdn.com/9d47f206e38d4cd7b271b86b73b4d8fe.min.js

Description

I have Sentry installed through yarn, and using ignoreErrors and beforeSend as init options. It is working perfectly in production.

I've just discovered loader and tried to use it:

1 - I copy pasted the code in the url above to a file in my bundle
2 - I required it into the js file where I was configuring sentry previously
3 - I wrapper Sentry.init with Sentry.onload.

Sentry is now working, but the two options mentioned are being ignored. I'm seeing errors that are in ignoreErrors, and the beforeSend function is not being called.

import Util from '../lib/util'

require('./sentry-loader.min')

Sentry.onLoad(function () {
  Sentry.init({
    whitelistUrls: [
      /festalab\.com\.br\/packs\/js\/public.*js/,
      /festalab\.com\.br\/packs\/js\/internal.*js/,
      /festalab\.com\.br\/packs\/js\/legacy.*js/,
      /festalab\.com\.br\/packs\/js\/fudgeballs.*js/
    ],

    ignoreErrors: [
      /SecurityError: DOM Exception 18$/,
      /SecurityError: Failed to execute 'replaceState'/,
      /SecurityError: Failed to read the 'localStorage'/,
      /SecurityError: The operation is insecure/,
      /NotAllowedError/,
      /TypeError/,
      /sendBeacon/
    ],

    beforeSend (event, hint) {
      // Ignore Safari WebView inside Facebook app
      if (/fbclid/i.test(event.request.url)) {
        return null
      }

      // Ignore browsers we do not want to support
      if (!Util.deviceIsSupported()) {
        return null
      }

      return event
    }
  })
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions