【问题标题】:How can I prevent Sentry from reporting an error in javascript in the browswer?如何防止 Sentry 在浏览器中报告 javascript 错误?
【发布时间】:2021-06-05 02:30:06
【问题描述】:

似乎 Sentry 报告了一个我故意吞下的错误。为什么是这样?我怎样才能告诉 Sentry 不要报告这个被吞下的错误?

【问题讨论】:

    标签: javascript logging browser error-handling sentry


    【解决方案1】:
    Sentry.init({
      ignoreErrors: ['NotSupportedError']
      // or
      ignoreErrors: [/operation is not supported/]
    })
    

    beforeSend

    Sentry.init({
      beforeSend(event) {
        // or `value` instead of a `type`
        if (event.exception && event.exception.values[0].type === 'NotSupportedError') {
          return null
        }
        return event;
      }
    })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-04-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-30
      • 1970-01-01
      • 2015-11-21
      • 2021-05-22
      相关资源
      最近更新 更多