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

    • 前端
    • Vue
    • Sentry
      categories:
    • 前端
      date: 2019-09-29 13:15:00

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

    • 安装依赖包@sentry/browser

    1. # Using yarn
    2. $ yarn add @sentry/browser
    3. # Using npm
    4. $ npm install @sentry/browser
    • 安装依赖包sentry/integrations
    1. # Using yarn
    2. yarn add @sentry/integrations
    3. # Using npm
    4. npm install @sentry/integrations
    • main.js引入
    1. import Vue from 'vue'
    2. import * as Sentry from '@sentry/browser';
    3. import * as Integrations from '@sentry/integrations';
    4. Sentry.init({
    5. dsn: 'http://d1701e1878654456aa94ce87f894a474:d0f97709732c476a850ca9ffb4f0fc82@127.0.0.1:9000/10',
    6. integrations: [new Integrations.Vue({ Vue, attachProps: true })]
    7. })

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