koa-atlas-sentry
TypeScript icon, indicating that this package has built-in type declarations

1.2.3 • Public • Published

koa-atlas-sentry

用于 koa 集成 sentry,当前可以使用 issues 和 performance

QuickStart

// npm
npm i koa-atlas-sentry
// yarn
yarn add koa-atlas-sentry

.env

需要在根目录下创建.env 文件,内容如下

SENTRY_DSN=you sentry dsn
SENTRY_ENABLE_ISSUES=true // 默认为false
SENTRY_ENABLE_PERFORMANCE=true // 默认为false
SENTRY_TRACES_SAMPLE_RATE=0.1

启用

import sentryInit from "koa-atlas-sentry";
sentryInit(app);

注意事项

  • sentry issues 是通过 on("error")实现的,所以一定要确定 error 被全局异常处理器处理的情况下,需要手动将异常 emit 出去
  • 一定要注意 koa 中间件的顺序,顺序不同将会导致收集不到数据,尽量将 sentryInit 放到所有中间件之前
// 手动emit异常
ctx.app.emit("error", err, ctx);

Package Sidebar

Install

npm i koa-atlas-sentry

Weekly Downloads

70

Version

1.2.3

License

ISC

Unpacked Size

63.8 kB

Total Files

14

Last publish

Collaborators

  • jy