Sentry 开发者贡献指南 - JavaScript SDK Minimal

简介

Sentry JavaScript SDK Minimal

站在用户的角度思考问题,与客户深入沟通,找到栖霞网站设计与栖霞网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:做网站、成都网站设计、企业官网、英文网站、手机端网站、网站推广、域名申请网站空间、企业邮箱。业务覆盖栖霞地区。

  • ​​https://github.com/getsentry/sentry-javascript/tree/master/packages/minimal​​

用法

要使用 ​​minimal​​​,您不必初始化 ​​SDK​​​。这应该由您库的用户处理。而是直接使用 ​​@sentry/minimal​​ 的导出函数添加面包屑或捕获事件:

import * as Sentry from '@sentry/minimal';

// 为未来的事件添加面包屑
Sentry.addBreadcrumb({
message: 'My Breadcrumb',
// ...
});

// 捕获异常、消息或手动事件
Sentry.captureMessage('Hello, world!');
Sentry.captureException(new Error('Good bye'));
Sentry.captureEvent({
message: 'Manual',
stacktrace: [
// ...
],
});

请注意,虽然严格可行,但不鼓励干扰事件上下文。如果由于某种原因您的库需要注入上下文信息,请注意这可能会覆盖用户的上下文值:

// 设置用户信息、标签和其他附加信息
Sentry.configureScope(scope => {
scope.setExtra('battery', 0.7);
scope.setTag('user_mode', 'admin');
scope.setUser({ id: '4711' });
// scope.clear();
});

测试用例

PASS  test/lib/minimal.test.ts
Minimal
Clear Scope (1ms)
returns undefined before binding a client (1ms)
returns the bound client (1ms)
Calls function on the client (1ms)
does not throw an error when pushing different clients (1ms)
does not throw an error when pushing same clients
custom carrier (1ms)
withScope (2ms)
setExtras (1ms)
setTags (1ms)
setExtra (1ms)
setTag
setUser (1ms)
setContext (1ms)
Capture
Return an event_id (4ms)
Exception (1ms)
Exception with explicit scope (1ms)
Message (1ms)
Message with explicit scope (1ms)
Message with custom level (2ms)
Event (1ms)
configureScope
User Context (2ms)
Extra Context (1ms)
Tags Context (1ms)
Fingerprint
Level (1ms)

网站标题:Sentry 开发者贡献指南 - JavaScript SDK Minimal
本文路径:http://gydahua.com/article/dpdodij.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流