如何使用 sentry v5 全局忽略错误以减少噪音

BTL*_*BTL 2 javascript sentry vue.js

使用已弃用的客户端 Raven,您可以忽略麻烦的错误:

Raven.config('your-dsn', {
    ignoreErrors: [
        'Can\'t execute code from freed script',
        /SecurityError\: DOM Exception 18$/
    ]
}).install();
Run Code Online (Sandbox Code Playgroud)

我在新客户端中找到的唯一方法是使用before-send钩子:https : //docs.sentry.io/error-reporting/configuration/filtering/?platform=browser#before-send

import * as Sentry from '@sentry/browser';

init({
  beforeSend(event, hint) {
    const { message } = hint.originalException;
    if (message && message.match(/database unavailable/i)) {
      return null;
    }
    return event;
  }
});
Run Code Online (Sandbox Code Playgroud)

我搜索了所有文档,但没有找到忽略错误的全局方法。