zcloud-ui
Version:
A Component Library for Vue.js.
89 lines (73 loc) • 3.35 kB
JavaScript
;
exports.__esModule = true;
var _vue = require('vue');
var _vue2 = _interopRequireDefault(_vue);
var _vue3 = require('@sentry/vue');
var Sentry = _interopRequireWildcard(_vue3);
var _tracing = require('@sentry/tracing');
var _rrweb = require('@sentry/rrweb');
var _rrweb2 = _interopRequireDefault(_rrweb);
var _index = require('zcloud-ui/lib/config/index');
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// import * as Sentry from '@sentry/browser';
window.Sentry = Sentry;
// import { Vue as VueIntegration } from '@sentry/integrations';
/**
* sentry 配置文件
* @tiem 2020/10/20
*/
var integrations = [];
// https://docs.sentry.io/platforms/javascript/configuration/options/ option配置
var users = function users() {
if (_index.Environment.USER_SENTRY && _index.Environment.NODE_ENV === 'production') {
if (_index.Environment.USER_SENTRY_RRWEB) {
integrations.push(new _rrweb2.default({
checkoutEveryNms: 1 * 60 * 1000 // 只保存最近1分钟的
}));
}
// integrations.push(new VueIntegration({ Vue, attachProps: true, logErrors: true }));
integrations.push(new _tracing.Integrations.BrowserTracing());
Sentry.init({
Vue: _vue2.default,
tracingOptions: {
trackComponents: true
},
dsn: _index.Environment.SENTRY_DSN,
beforeSend: function beforeSend(event, hint) {
var values = event.exception ? event.exception.values || [] : [];
// 排除no catch 错误
if (values && values.length && values[0].type === 'UnhandledRejection') {
if (event.extra && event.extra.__serialized__ && event.extra.__serialized__.api && values[0].value.includes('res')) {
values[0].value = '请求地址: ' + event.extra.__serialized__.api;
values[0].mechanism = { handled: false, type: 'generic' };
values[0].type = '请求返回,发生错误';
} else {
return null;
}
}
// // 排除element带来的错误影响
// if (values && values.length && values[0].type === 'Error') {
// if (values[0].value === 'ResizeObserver loop limit exceeded') {
// return null;
// } else {
// return event;
// }
// }
return event;
},
ignoreErrors: [/ResizeObserver loop limit exceeded/i, /Request failed with status code 405/i].concat(_index.Environment.SENTRY_IGNORE),
sampleRate: 1, // 采样收集率 0-1之前
sendDefaultPii: true, // 个人身份信息
maxBreadcrumbs: 50, // 面包屑的总量
normalizeDepth: 6, // 上下文数据标准化到给定深度
integrations: integrations,
// release: Environment.PROJECTNAME + '@' + Environment.RELEASE,
release: _index.Environment.RELEASE,
logErrors: true,
environment: _index.Environment.USER_ENVIRONMENT
});
Sentry.setTag('rrweb.active', _index.Environment.USER_SENTRY_RRWEB ? 'yes' : 'no');
}
};
exports.default = users;