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. Redis 实战 —— 07. 复制、处理故障、事务及性能优化

    复制简介 P61 关系型数据库通常会使用一个主服务器 (master) 向多个从服务器 (slave) 发送更新,并使用从服务器来处理所有读请求. Redis 也采用了同样的方法实现自己的复制特性,并 ...

  2. 笔记 | 吴恩达新书《Machine Learning Yearning》

    这本书共112页,内容不多,偏向于工程向,有很多不错的细节,在此记录一下. 0 书籍获取 关注微信公众号"机器学习炼丹术",回复[MLY]获取pdf 1 测试集与训练集的比例 2 ...

  3. 网络流量预测入门(二)之LSTM介绍

    目录 网络流量预测入门(二)之LSTM介绍 LSTM简介 Simple RNN的弊端 LSTM的结构 细胞状态(Cell State) 门(Gate) 遗忘门(Forget Gate) 输入门(Inp ...

  4. Eclipse在线安装FatJar插件失败解决方案

    在线安装fatjar(URL:http://kurucz-grafika.de/fatjar) 快要安装完的时候报错如下: 找了很久解决方法,终于有了下文:很是粗乎意料呃,下载一个eclipse2.0 ...

  5. C++ Primer Plus读书笔记(三)复合类型

    这节主要是介绍数组.结构体.类等概念,以及new delete内存管理. 1.数组 首先普及一下C++中字符串的概念,只有在结尾有 \0 的才叫字符串, cout 输出字符串也以空字符为标记进行结束输 ...

  6. linux文件、目录管理

    系统目录结构 ls(list)ls / 根下面的目录每个用户都有一个家目录创建一个普通用户: useradd xfxing可查看该用户:ls /home/xfxing/ (useradd user1 ...

  7. Spring听课笔记(tg)

    0. 地址:https://www.bilibili.com/video/av21335209 1.综述,Spring主要的复习要点集中在以下几点 -- Spring的整体结构,Maven依赖(环境搭 ...

  8. java 文件转成pdf文件 预览

    一.前端代码 //预览功能 preview: function () { //判断选中状态 var ids =""; var num = 0; $(".checkbox& ...

  9. Spring boot freemarker 配置

    spring: datasource: type: com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.jdbc.Dri ...

  10. python--基础1(pip,虚拟环境、python编写规范)

    python简介 1.Python是一种解释型脚本语言; 2.Python在设计上坚持了清晰划一的风格,这使得Python成为一门易读.易维护,并且被大量用户所欢迎的.用途广泛的语言; 3.pytho ...