Commit 50c6a868 authored by 郭志伟's avatar 郭志伟

feat: sentry接入

parent d24fa207
const crypto = require('crypto');
const pkgInfo = require('./package.json');
const project = pkgInfo.name;
const hashName = crypto
.createHash('md5')
.update(project)
.digest('hex')
.substr(0, 8);
module.exports = { module.exports = {
org: 'sentry', org: 'sentry',
project: 'group-buy-ui', project,
authToken: '3f1f6f3789594e3a81280c1cd8d4d1008037a7abad714698b60b6f358c3d7562', authToken: '3f1f6f3789594e3a81280c1cd8d4d1008037a7abad714698b60b6f358c3d7562',
url: 'http://newsentry.quantgroups.com', url: 'http://newsentry.quantgroups.com',
dsn: 'http://d36508238b7c4e5fa8306948b52948e1@newsentry.quantgroups.com/11', release: `${project}@1.0.0`,
release: 'group-buy-ui@1.0.0',
ignore: ['node_modules', 'tests'], ignore: ['node_modules', 'tests'],
silent: true, silent: true,
include: [ include: [
{ {
paths: ['./dist/js'] paths: ['./dist/js'],
urlPrefix: `https://misc.lkbang.net/${hashName}/`
} }
] ]
}; };
...@@ -8,22 +8,15 @@ import '@/service/cherryUI.service'; ...@@ -8,22 +8,15 @@ import '@/service/cherryUI.service';
import './style/index.less'; import './style/index.less';
import saService from '@/service/sa.service'; import saService from '@/service/sa.service';
import Bridge from '@qg/js-bridge'; import Bridge from '@qg/js-bridge';
import * as Sentry from '@sentry/vue'; import { init as sentryInit } from '@sentry/vue';
import { Integrations } from '@sentry/tracing';
import { release, dsn } from '../.sentryclirc';
import lazyload from '@qg/cherry-ui/src/lazyload/index'; import lazyload from '@qg/cherry-ui/src/lazyload/index';
import 'intersection-observer'; import 'intersection-observer';
if (process.env.SENTRY_ENV !== 'test' && process.env.NODE_ENV === 'production') { if (process.env.SENTRY_ENV !== 'test' && process.env.NODE_ENV === 'production') {
Sentry.init({ sentryInit({
Vue, Vue,
dsn, dsn: 'https://d36508238b7c4e5fa8306948b52948e1@sentry.q-gp.com/11', // 项目设置中的Client Keys
integrations: [ release: 'group-buy-ui@1.0.0', // 项目名加版本号
new Integrations.BrowserTracing({ tracesSampleRate: 0.5, // 上报频率, 1最大, 0最小, 建议验证设置为1, 项目运行根据情况降低频率
routingInstrumentation: Sentry.vueRouterInstrumentation(router)
})
],
release,
tracesSampleRate: 1.0, // 上报频率, 1最大, 0最小, 建议验证设置为1, 项目运行根据情况降低频率
environment: process.env.NODE_ENV environment: process.env.NODE_ENV
}); });
} }
......
const path = require('path'); const path = require('path');
const resolve = dir => path.join(__dirname, dir); const resolve = dir => path.join(__dirname, dir);
const IS_PROD = process.env.NODE_ENV === 'production'; const IS_PROD = process.env.NODE_ENV === 'production';
const webpack = require('webpack');
const WebpackCosCdnUploadPlugin = require('@qg/webpack-cos-cdn-upload-plugin'); const WebpackCosCdnUploadPlugin = require('@qg/webpack-cos-cdn-upload-plugin');
const SentryPlugin = require('@qg/sentry-webpack-plugin'); const SentryPlugin = require('@qg/sentry-webpack-plugin');
const SentryConfig = require('./.sentryclirc'); const SentryConfig = require('./.sentryclirc');
...@@ -88,6 +89,11 @@ module.exports = { ...@@ -88,6 +89,11 @@ module.exports = {
priority: 10, priority: 10,
chunks: 'initial' // only package third parties that are initially dependent chunks: 'initial' // only package third parties that are initially dependent
}, },
sentry: {
name: 'chunk-sentry', // sentry
priority: 20, // the weigh1t needs to be larger than libs and app or it will be packaged into libs or app
test: /[\\/]node_modules[\\/]@sentry[\\/]/ // in order to adapt to cnpm
},
libs: { libs: {
name: 'chunk-libs', // 分离非在入口加载的,但是引用超过2次的依赖 name: 'chunk-libs', // 分离非在入口加载的,但是引用超过2次的依赖
test: /[\\/]node_modules[\\/]/, test: /[\\/]node_modules[\\/]/,
...@@ -127,8 +133,13 @@ module.exports = { ...@@ -127,8 +133,13 @@ module.exports = {
if (IS_PROD) { if (IS_PROD) {
config.externals = externals; config.externals = externals;
configObj = { configObj = {
plugins: [new SentryPlugin(SentryConfig), new WebpackCosCdnUploadPlugin()] plugins: [
// plugins: [new WebpackCosCdnUploadPlugin()] new SentryPlugin(SentryConfig),
new webpack.DefinePlugin({
'process.env.SENTRY_ENV': `"${process.env.SENTRY_ENV || ''}"`
}),
new WebpackCosCdnUploadPlugin()
]
}; };
} }
return configObj; return configObj;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment