Sentry-JS-SDK-Browser 官方示例最佳实践

系列
SDK 开发
- 顶级开源项目 Sentry 20.x JS-SDK 设计艺术(理念与设计原则篇)
- 顶级开源项目 Sentry 20.x JS-SDK 设计艺术(开发基础篇)
- 顶级开源项目 Sentry 20.x JS-SDK 设计艺术(概述篇)
- 顶级开源项目 Sentry 20.x JS-SDK 设计艺术(Unified API篇)
系列
- Snuba:Sentry 新的搜索基础设施(基于 ClickHouse 之上)
- Sentry 10 K8S 云原生架构探索,Vue App 1 分钟快速接入
- Sentry(v20.x)玩转前/后端监控与事件日志大数据分析,使用 Helm 部署到 K8S 集群
- Sentry(v20.x) JavaScript SDK 三种安装加载方式
- Sentry(v20.x) JavaScript SDK 配置详解
- Sentry(v20.x) JavaScript SDK 手动捕获事件基本用法
- Sentry(v20.x) JavaScript SDK Source Maps详解
- Sentry(v20.x) JavaScript SDK 故障排除
- Sentry(v20.x) JavaScript SDK 1分钟上手性能监控
- Sentry(v20.x) JavaScript SDK 性能监控之管理 Transactions
- Sentry(v20.x) JavaScript SDK 性能监控之采样 Transactions
- Sentry(v20.x) JavaScript SDK Enriching Events(丰富事件信息)
- Sentry(v20.x) JavaScript SDK Data Management(问题分组篇)
Sentry-Javascript
@sentry/browser
相关示例
denyUrlsallowUrlsignoreError messageignoreError typeregularExceptioncaptureExceptioncaptureMessageduplicated exceptionduplicated messageintegrationevent hintsbreadcrumb hints
实践
快速运行示例
# sentry-javascript 项目
yarn
yarn build
cd packages/browser/examples/
python -m SimpleHTTPServer # Mac 自带的,也可以用你自己喜欢的 http server
# Serving HTTP on 0.0.0.0 port 8000 ...

示例配置详解
Sentry.init({
// Client's DSN.
dsn: 'https://363a337c11a64611be4845ad6e24f3ac@sentry.io/297378',
// An array of strings or regexps that'll be used to ignore specific errors based on their type/message
ignoreErrors: [/PickleRick_\d\d/, 'RangeError'],
// An array of strings or regexps that'll be used to ignore specific errors based on their origin url
denyUrls: ['external-lib.js'],
// An array of strings or regexps that'll be used to allow specific errors based on their origin url
allowUrls: ['http://localhost:5000', 'https://browser.sentry-cdn'],
// Debug mode with valuable initialization/lifecycle informations.
debug: true,
// Whether SDK should be enabled or not.
enabled: true,
// Custom integrations callback
integrations(integrations) {
return [new HappyIntegration(), ...integrations];
},
// A release identifier.
release: '1537345109360',
// An environment identifier.
environment: 'staging',
// Custom event transport that will be used to send things to Sentry
transport: HappyTransport,
// Method called for every captured event
async beforeSend(event, hint) {
// Because beforeSend and beforeBreadcrumb are async, user can fetch some data
// return a promise, or whatever he wants
// Our CustomError defined in errors.js has `someMethodAttachedToOurCustomError`
// which can mimick something like a network request to grab more detailed error info or something.
// hint is original exception that was triggered, so we check for our CustomError name
if (hint.originalException.name === 'CustomError') {
const serverData = await hint.originalException.someMethodAttachedToOurCustomError();
event.extra = {
...event.extra,
serverData,
};
}
console.log(event);
return event;
},
// Method called for every captured breadcrumb
beforeBreadcrumb(breadcrumb, hint) {
// We ignore our own logger and rest of the buttons just for presentation purposes
if (breadcrumb.message.startsWith('Sentry Logger')) return null;
if (breadcrumb.category !== 'ui.click' || hint.event.target.id !== 'breadcrumb-hint') return null;
// If we have a `ui.click` type of breadcrumb, eg. clicking on a button we defined in index.html
// We will extract a `data-label` attribute from it and use it as a part of the message
if (breadcrumb.category === 'ui.click') {
const label = hint.event.target.dataset.label;
if (label) {
breadcrumb.message = `User clicked on a button with label "${label}"`;
}
}
console.log(breadcrumb);
return breadcrumb;
},
});
dsn:客户端的DSNignoreErrors:字符串或正则表达式数组,用于根据其type/message忽略特定错误denyUrls:字符串或正则表达式数组,将用于根据origin url忽略特定错误allowUrls:字符串或正则表达式数组,将用于允许基于其origin url的特定错误debug:使用有价值的初始化(initialization)/生命周期(lifecycle)信息的调试模式enabled:是否应该启用SDKintegrations:自定义集成回调release:发布版本标识符environment:发布环境标识符transport:自定义事件传输,将用于将事物发送到SentrybeforeSend:针对每个捕获的事件调用的方法beforeBreadcrumb:针对每个捕获的面包屑调用的方法
我是为少
微信:uuhells123
公众号:黑客下午茶
加我微信(互相学习交流),关注公众号(获取更多学习资料~)
Sentry-JS-SDK-Browser 官方示例最佳实践的更多相关文章
- 【云计算】使用supervisor管理Docker多进程-ntpd+uwsgi+nginx示例最佳实践
supervisor安装启动: apt-get install supervisor -y # start supervisord nodaemon /usr/bin/supervisord --no ...
- Open Xml SDK Word模板开发最佳实践(Best Practice)
1.概述 由于前面的引文已经对Open Xml SDK做了一个简要的介绍. 这次来点实际的——Word模板操作. 从本质上来讲,本文的操作都是基于模板替换思想的,即,我们通过替换Word模板中指定元素 ...
- 微信JS SDK Demo 官方案例[转]
摘要: 微信JS-SDK是微信公众平台面向网页开发者提供的基于微信内的网页开发工具包. 通过使用微信JS-SDK,网页开发者可借助微信高效地使用拍照.选图.语音.位置等手机系统的能力,同时可以直接使用 ...
- 微信JS SDK Demo 官方案例
微信JS-SDK是微信公众平台面向网页开发者提供的基于微信内的网页开发工具包. 通过使用微信JS-SDK,网页开发者可借助微信高效地使用拍照.选图.语音.位置等手机系统的能力,同时可以直接使用微信分享 ...
- Vue.js最佳实践--给大量子孙组件传值(provide/inject)
开发中有个需求,有个Parent组件(例如div)下,输入框,下拉框,radiobutton等可编辑的子孙组件几百个,根据某个值统一控制Parent下面的所有控件的disabled状态 类似于这样,给 ...
- Web最佳实践阅读总结(1)
介绍 最近开始刷一些书和题,此系列是介绍在读Web最佳实践的一些收获和体会. web前端发展现状 存在问题: 代码组织混乱 代码格式的问题突出 页面布局随意 网站整体性能差,没有意识到应用诸如缓存,动 ...
- Sentry 后端监控 - 最佳实践(官方教程)
系列 1 分钟快速使用 Docker 上手最新版 Sentry-CLI - 创建版本 快速使用 Docker 上手 Sentry-CLI - 30 秒上手 Source Maps Sentry For ...
- 关于 JS 模块化的最佳实践总结
模块化开发是 JS 项目开发中的必备技能,它如同面向对象.设计模式一样,可以兼顾提升软件项目的可维护性和开发效率. 模块之间通常以全局对象维系通讯.在小游戏中,GameGlobal 是全局对象.在小程 ...
- 《.NET最佳实践》与Ext JS/Touch的团队开发
概述 持续集成 编码规范 测试 小结 概述 有不少开发人员都问过我,Ext JS/Touch是否支持团队开发?对于这个问题,我可以毫不犹豫的回答:支持.原因是在Sencha官网博客中客户示例中,有不少 ...
随机推荐
- C# 数据类型(2)
String char的集合 string name = "John Doe"; 双引号,char是单引号string是不可变的,一旦初始化后就不能变了,每次对已存在的string ...
- mysql(五)--性能优化总结
1 优化思路 作为架构师或者开发人员,说到数据库性能优化,你的思路是什么样的? 或者具体一点,如果在面试的时候遇到这个问题:你会从哪些维度来优化数据库, 你会怎么回答? 我们在第一节课开始的时候讲了, ...
- Redis五大类型及底层实现原理
目录 简单动态字符串链表字典跳跃表整数集合压缩列表对象 对象的类型与编码字符串对象列表对象哈希对象 集合对象有序集合对象类型检查与命令多态内存回收对象共享对象的空转时长 简单动态字符串 导读 Red ...
- 技术分享: CSS3 系列
技术分享: CSS3 系列 css 一键换肤 css 打印样式,媒体查询 css 禁用选择 css 性能优化 css 计算单位 css 3D 特效 refs xgqfrms 2012-2020 www ...
- website i18n and L10n all in one
website i18n and L10n all in one Localization & Internationalization 本地化 & 国际化 https://www.w ...
- Interview Questions All In One
Interview Questions All In One web fullstack System Design Operating System Object-Oriented Design O ...
- node.js & create file
node.js & create file node js create file if not exists https://nodejs.org/api/fs.html#fs_fs_ope ...
- vscode & ignore .idea
vscode & ignore .idea settings.json .vscode & ignore .idea // 将设置放入此文件中以覆盖默认设置 { "files ...
- flutter 插件调用callback函数
dart plugin class TestLib { static MethodChannel _channel = const MethodChannel('test_lib') ..setMet ...
- SVG & gradient & color
SVG & gradient & color https://developer.mozilla.org/zh-CN/docs/Web/SVG/Tutorial/Gradients & ...