Vue项目集成Sentry错误跟踪平台

  • 去搭建好的Sentry上,新建一个项目

  • 安装依赖包@sentry/browser

1
2
3
4
5
# Using yarn
$ yarn add @sentry/browser

# Using npm
$ npm install @sentry/browser
  • 安装依赖包sentry/integrations
1
2
3
4
5
# Using yarn
yarn add @sentry/integrations

# Using npm
npm install @sentry/integrations
  • main.js引入
1
2
3
4
5
6
7
8
import Vue from 'vue'
import * as Sentry from '@sentry/browser';
import * as Integrations from '@sentry/integrations';

Sentry.init({
dsn: 'http://d1701e1878654456aa94ce87f894a474:d0f97709732c476a850ca9ffb4f0fc82@127.0.0.1:9000/10',
integrations: [new Integrations.Vue({ Vue, attachProps: true })]
})

注意:dsn格式是:{PROTOCOL}://{PUBLIC_KEY}:{SECRET_KEY}@{HOST}/{PATH}{PROJECT_ID},别搞错。

推荐文章