背景
记录sentry的配置
sentry是前端监控的平台,平常时候也是在使用的
下面是记录简单的配置功能
涉及功能
- 开关
- 环境判断
- 初始化
- DSN
- ignoreErrors,报错忽略
- 自定义上报信息
setup
import * as Sentry from '@sentry/browser';
import { Vue as VueIntegration } from '@sentry/integrations';
import sentryConfig from 'src/commons/utils/sentryConfig';
// enable 是开关,后面是环境判断
if (sentryConfig.enable && process.env && process.env.NODE_ENV === 'production') {
Sentry.init({
dsn: sentryConfig.masterDSN,
integrations: [
new VueIntegration({ Vue, attachProps: true, logErrors: true })
],
// 有些报错需要忽略,可以写在这里,下面是demo
ignoreErrors: [
'timeout of 0ms exceeded'
]
});
// 上报文章信息
// 下面是自定义上报信息
Sentry.setContext('关联文章信息', {
文章id: '',
文章标题: ''
});
}