杨新春

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

具体见 : https://blog.csdn.net/weixin_49192390/article/details/113989218?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522168178969316800197063528%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=168178969316800197063528&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduend~default-1-113989218-null-null.142^v84^control_2,239^v2^insert_chatgpt&utm_term=uniapp%20sentry&spm=1018.2226.3001.4187

另外需要注意以下三个文件

 vue.config.js 代码

const SentryWebpackPlugin = require('@sentry/webpack-plugin')

module.exports = {
  // other configuration
  configureWebpack: {
    plugins: [
      new SentryWebpackPlugin({
        // 这个是APIkey
        authToken: '08e34b496845413bbfb6cd0d67b273026c2fa0d34ad647b7acee3da9c0057ad6',
        // 组织
        org: '52f9e454b69c',
        // 项目
        project: 'javascript-vue',
         configFile: './sentryclirc', //配置文件地址,这个一定要有,踩坑在这里,忘了写导致一直无法实现上传sourcemap
        include: './dist/build/h5/', // 这里一定要注意目录层级别搞错了
        ignore: ['node_modules', 'vue.config.js'],
        // 这个是版本号  要与main.js里面的版本号一致
        release: 'test005',
      }),
    ],

    // 这个可就厉害了 不加这个uni-app不会生成soucemap文件
    devtool: 'source-map',
  },
 

}

main.js 代码 

import App from './App.vue'

const host = 'https://unidemo.dcloud.net.cn/';

import Vue from 'vue'
import Router from "vue-router";
import * as Sentry from "@sentry/vue";
Vue.use(Router);
const router = new Router({
  // ...
});
Sentry.init({
  Vue,
  dsn: "https://985637f9fc0b489889b497183a1fdbf0@o1260705.ingest.sentry.io/4505016043241472",
  integrations: [
    new Sentry.BrowserTracing({
      routingInstrumentation: Sentry.vueRouterInstrumentation(router),
      tracePropagationTargets: ["localhost", "my-site-url.com", /^\//],
    }),
  ],
  // Set tracesSampleRate to 1.0 to capture 100%
  // of transactions for performance monitoring.
  // We recommend adjusting this value in production
 tracesSampleRate: 1.0,
   release: 'test005', // 版本号,每次都npm run build上传都修改版本号
});

App.mpType = 'app'
new Vue({
  router,
  render: h => h(App),
}).$mount("#app");

 

注意红色的要一致 

package.json 

{
  "name": "my-project3",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "npm run dev:h5",
    "build": "npm run build:h5",
    "build:app-plus": "cross-env NODE_ENV=production UNI_PLATFORM=app-plus vue-cli-service uni-build",
    "build:custom": "cross-env NODE_ENV=production uniapp-cli custom",
    "build:h5": "cross-env NODE_ENV=production UNI_PLATFORM=h5 vue-cli-service uni-build && rm -rf ./dist/build/h5/static/js/*.map",
    
  },
  "dependencies": {
    "core-js": "^3.8.3",
    "flyio": "^0.6.2",
    "vue": ">= 2.6.14 < 2.7",
    "vuex": "^3.2.0"
  },
  "devDependencies": {"vue-template-compiler": ">= 2.6.14 < 2.7"
  },
  "browserslist": [
    "Android >= 4.4",
    "ios >= 9"
  ],
  "uni-app": {
    "scripts": {}
  }
}

以上红色防止sourcemap上传到生产上面,这里只添加即可,整个代码仅为示例

 

posted on 2023-04-18 17:15  杨新春  阅读(865)  评论(0编辑  收藏  举报