Vue & Sentry & ErrorHandler

Vue & Sentry & ErrorHandler


import * as Sentry from '@sentry/browser';
import { Vue as VueIntegration } from '@sentry/integrations';

import ErrorHandler from './ErrorHandler.js';
import * as PACKAGE from '../package.json';

const env = process.env.NODE_ENV === 'production' ? 'prod' : 'dev';

if(env === 'prod' && window.location.host === 'app.xgqfrms.com') {
    // 僅用於 prod 環境
    Sentry.init({
        environment: `${env === 'prod' ? '生產環境' : '測試環境'}`,
        ignoreErrors: ['ResizeObserver loop limit exceeded'],
        release: `${PACKAGE.name}@${PACKAGE.version}`,
        dsn: 'https://[email protected]//2020',
        integrations: [new VueIntegration({Vue, attachProps: true, logErrors: true})],
    });
}

const errorHandler = new ErrorHandler('vue_error');

Vue.config.errorHandler = (err, vm, info) => errorHandler.onError(err, vm, info);


refs



©xgqfrms 2012-2020

www.cnblogs.com 發佈文章使用:只允許註冊用戶纔可以訪問!

原創文章,版權所有©️xgqfrms, 禁止轉載 🈲️,侵權必究⚠️!


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章