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

简介

嵌入到应用程序中时使用配置 ​​client​​​ 的最小 ​​Sentry SDK​​​。它允许​​库作者​​​添加对 ​​Sentry SDK​​ 的支持,而无需捆绑整个 ​​SDK​​​ 或依赖于特定平台。简单来说,它是 ​​@sentry/node​​​ 或 ​​@sentry/browser​​ 等特定于平台的 SDK 库的高防服务器公共基础部分。

Sentry JavaScript SDK Minimal

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

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

用法

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

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

import * as Sentry from @sentry/minimal;

Sentry 开发者贡献指南 - JavaScript SDK 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)

系统运维
上一篇:打开https://www.aizhan.com/输入自己想要查询的域名然后按回车键,如果做过网站都会有数据显示出来
下一篇:比较短的域名方便用户记忆和传播,它带来的好处往往会超过其他类型的域名,如果你非要域名短而且还要包含关键词,那么往往会事与愿违,现在这种域名基本上是可遇而不可求的。