Sentry.init({ Vue, dsn: '<文档描述中的 dsn>', environment: process.env.VUE_APP_SENTRY_ENVIRONMENT, integrations: [ new Integrations.BrowserTracing({ routingInstrumentation: Sentry.vueRouterInstrumentation(router), tracingOrigins: ['localhost', /^\//] }) ], // Set tracesSampleRate to 1.0 to capture 100% // of transactions for performance monitoring. // We recommend adjusting this value in production tracesSampleRate: 1.0 })
if (env.NODE_ENV !== 'development') { Sentry.init({ dsn: '项目的dsn', environment: '环境变量', release: '版本信息', integrations: [ new VueIntegration({ Vue, tracing: true }), new Integrations.BrowserTracing({ // routingInstrumentation: Sentry.vueRouterInstrumentation(router), tracingOrigins: ['localhost', /^\//] }) ], // Set tracesSampleRate to 1.0 to capture 100% // of transactions for performance monitoring. // We recommend adjusting this value in production tracesSampleRate: 1.0 }) }
Sentry.init({ Vue, dsn: '<文档描述中的 dsn>', environment: '<环境信息>', release: `${Pkg.name}@${Pkg.version}`, integrations: [ new Integrations.BrowserTracing({ routingInstrumentation: Sentry.vueRouterInstrumentation(router), tracingOrigins: ['localhost', /^\//] }) ], // Set tracesSampleRate to 1.0 to capture 100% // of transactions for performance monitoring. // We recommend adjusting this value in production tracesSampleRate: 1.0 })
上述我们大致介绍了一下环境配置,实际上,上文的环境配置只能覆盖 development 和 production 这两个环境,更多的环境例如 QA、test、pre-release等并不能覆盖到,因此会导致真正的线上环境和测试环境等混淆在一起无法区分(虽然可以通过触发监控的域名区分,但是并不好,无法做警告通知,数据统计等)。
Sentry.init({ Vue, dsn: '此处填写 dsn', environment: responseHeader.vue_env ?? process.env.VUE_APP_SENTRY_ENVIRONMENT, release: `${Pkg.name}@${Pkg.version}`, integrations: [ new Integrations.BrowserTracing({ routingInstrumentation: Sentry.vueRouterInstrumentation(router), tracingOrigins: ['localhost', /^\//] }) ], // Set tracesSampleRate to 1.0 to capture 100% // of transactions for performance monitoring. // We recommend adjusting this value in production tracesSampleRate: 1.0 })
exportdefaultfunction ({ isDev, $axios, store }) { if (!isDev) { $axios.get('env', { baseURL: '' }).then(({ data }) => { store.commit(ACTIONS.ENV, data ?? 'test') // 将环境变量存起来,以防它用 Sentry.init({ dsn: '写入你的 dsn', environment: data ?? process.env.NODE_ENV, release: `${Pkg.name}@${Pkg.version}`, integrations: [ new VueIntegration({ Vue, tracing: true }), new Integrations.BrowserTracing({ // routingInstrumentation: Sentry.vueRouterInstrumentation(router), tracingOrigins: ['localhost', /^\//] }) ], // Set tracesSampleRate to 1.0 to capture 100% // of transactions for performance monitoring. // We recommend adjusting this value in production tracesSampleRate: 1.0 }) }) } }