Vue & Sentry

config.errorHandler

https://cn.vuejs.org/v2/api/#errorHandler


Vue.config.errorHandler = function (err, vm, info) {
// handle error
// `info` 是 Vue 特定的错误信息,比如错误所在的生命周期钩子
// 只在 2.2.0+ 可用
}

demo

https://sentry.xgqfrms.xyz/sentry/vue-web-app/getting-started/javascript-vue/

https://sentry.xgqfrms.xyz/settings/sentry/projects/vue-web-app/keys/

To use Sentry with your Vue application, you will need to use Sentry’s browser JavaScript SDK: @sentry/browser.

Using yarn

$ yarn add @sentry/browser

Using npm

$ npm install @sentry/browser

sentry vue

https://docs.sentry.io/platforms/javascript/guides/vue/


$ yarn add @sentry/vue
  1. sentry 只上报 js 错误,不处理 vue 本身的错误!

On its own, @sentry/vue will report any uncaught exceptions triggered by your application.


import Vue from "vue";
import * as Sentry from '@sentry/vue'; Sentry.init({
Vue: Vue,
dsn: '__PUBLIC_DSN__',// keys
});
  1. 使用 Vue’s config.errorHandler hook,处理 vue 本身的错误!

Additionally, the SDK will capture the name and props state of the active component where the error was thrown. This is reported via Vue’s config.errorHandler hook.


import Vue from "vue";
import App from "./App.vue";
import { ErrorService } from "./Services/ErrorService";
import store from "./store"; Vue.config.productionTip = false; // Handle all Vue errors
Vue.config.errorHandler = (error) => ErrorService.onError(error); new Vue({
store,
render: (h) => h(App),
}).$mount("#app");

区别

  1. @sentry/vue

On its own, @sentry/vue will report any uncaught exceptions triggered by your application.

Additionally, the SDK will capture the name and props state of the active component where the error was thrown.

This is reported via Vue’s config.errorHandler hook.

  1. @sentry/browser & @sentry/integrations

On its own, @sentry/browser will report any uncaught exceptions triggered by your application.

Additionally, the Vue integration will capture the name and props state of the active component where the error was thrown.

This is reported via Vue’s config.errorHandler hook.

Starting with version 5.x our Vue integration lives in its own package @sentry/integrations.

refs

https://blog.logrocket.com/error-handling-debugging-and-tracing-in-vue-js/

https://juejin.cn/post/6844903860121632782

https://segmentfault.com/a/1190000018606181



xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


Vue & Sentry的更多相关文章

  1. Vue & Sentry & ErrorHandler

    Vue & Sentry & ErrorHandler import * as Sentry from '@sentry/browser'; import { Vue as VueIn ...

  2. Vue & Sentry sourcemaps All In One

    Vue & Sentry sourcemaps All In One vue & sentry & sourcemaps https://docs.sentry.io/plat ...

  3. vue+sentry 前端异常日志监控

    敲代码最糟心不过遇到自己和测试的环境都OK, 客户使用有各种各样还复现不了的问题,被逼无奈只能走到这一步:前端异常日志监控! vue官方文档如下推荐: 就是说, vue有错误机制处理errorHand ...

  4. Sentry项目监控工具结合vue的安装与使用(前端)

    一.官网:https://sentry.io/welcome/ 二.介绍 Sentry 是一个开源的实时错误报告工具,支持 web 前后端.移动应用以及游戏,支持 Python.OC.Java.Go. ...

  5. [转] vue前端异常监控sentry实践

    1. 监控原理 1.1 onerror 传统的前端监控原理分为异常捕获和异常上报.一般使用onerror捕获前端错误: window.onerror = (msg, url, line, col, e ...

  6. 05-Vue入门系列之Vue实例详解与生命周期

    Vue的实例是Vue框架的入口,其实也就是前端的ViewModel,它包含了页面中的业务逻辑处理.数据模型等,当然它也有自己的一系列的生命周期的事件钩子,辅助我们进行对整个Vue实例生成.编译.挂着. ...

  7. Vue.2.0.5-生产环境部署

    删除警告 为了减少文件大小,Vue 精简独立版本已经删除了所有警告,但是当你使用 Webpack 或 Browserify 等工具时,你需要一些额外的配置实现这点. Webpack 使用 Webpac ...

  8. 前端开发:如何写一手漂亮的 Vue

    前几日听到一句生猛与激励并存,可怕与尴尬同在,最无奈也无解的话:"90后,你的中年危机已经杀到".这令我很受触动.显然,这有些夸张了,但就目前这日复一日的庸碌下去,眨眼的功夫,那情 ...

  9. vue 开发2017年变化回顾及2018年展望

    vue.js 变化 从 github 的发布记录我们可以看到2017年 vue.js 的第一个发布为 v2.1.9,最后一个为 v2.5.13,主要发布小版本 2.2~2.5.这些发布提升了vue 与 ...

随机推荐

  1. 转 8 jmeter之集合点

    8 jmeter之集合点   集合点:集合点用以同步虚拟用户,以便恰好在同一时刻执行任务.在测试计划中,可能会要求系统能够承受1000 人同时提交数据,在LoadRunner 中可以通过在提交数据操作 ...

  2. 电脑微信电脑PC 多开/防撤回 补丁

    简介 经常使用微信电脑版的用户都会发现一个蛋疼的事情,那就是微信PC版不支持多开,也就是不能同时登陆多个账号,这对于需要在电脑上登陆多个微信账号的朋友来说肯定是极其的不方便.另外有的时候别人撤回了一些 ...

  3. Python学习【第8篇】:python中的函数

    1.python中函数定义方法 def test(x): "This istest" y = x*2+1 return y vaule = test(2)print(vaule)运 ...

  4. 线性DP总结(studying

    写在前面 虽然都说线性DP是入门,但我还是今天才开始学 线性DP就是珂以通过线性处理得出答案的一种DP 每一种状态都可以从前面推得,并且推导过程是呈线性的 参考题单(本人现在主要用luogu,所以这些 ...

  5. (19)ln命令:在文件之间建立链接(硬链接和软链接)

    1.ext 文件系统(Linux 文件系统)是如何工作的. 我们在前面讲解了分区的格式化就是写入文件系统,而 Linux 目前使用的是 ext4 文件系统.如果用一张示意图来描述 ext4 文件系统 ...

  6. 当 .NET 5 遇上OpenTelemetry,会碰撞出怎样的火花?

    OpenTelemetry 介绍 我在之前的几篇文章都介绍了 OpenTelemetry, 你可以在这里找到 OpenTelemetry - 云原生下可观测性的新标准 深入研究 .NET 5 的开放式 ...

  7. 学习一下 SpringCloud (四)-- 服务降级、熔断 Hystrix、Sentinel

    (1) 相关博文地址: 学习一下 SpringCloud (一)-- 从单体架构到微服务架构.代码拆分(maven 聚合): https://www.cnblogs.com/l-y-h/p/14105 ...

  8. 深入理解Js中的this

    深入理解Js中的this JavaScript作用域为静态作用域static scope,但是在Js中的this却是一个例外,this的指向问题就类似于动态作用域,其并不关心函数和作用域是如何声明以及 ...

  9. 翻译:《实用的Python编程》01_Introduction_00_Overview

    目录 | 下一节 (2 处理数据) 1. Python 简介 本章是第一章,将会从头开始介绍 Python 基础知识,让你从零开始,学会怎么编写.运行.调试一个简单的程序.最后,你可以运用这些 Pyt ...

  10. [NC13331]城市网络

    传送门 题意: 思路: 对于每组查询,我们直接从$u$往上搜到$v$,复杂度$O(nq)$,显然不可取(不过这题开始的数据很弱,暴力就过了) #include<bits/stdc++.h> ...