Sentry now provides official Koa integration: https://sentry.io/for/koa/.
raven middleware for koa.
$ npm i koa-raven --save
raven(DSN[, opts])
const raven = require('koa-raven')
const Koa = require('koa')
const app = new Koa()
app.use(raven('DSN', opts))
app.use((ctx) => {
throw new Error('test')
})
app.listen(3000)
or:
const raven = require('koa-raven')
const Koa = require('koa')
const app = new Koa()
app.use(raven('DSN', opts))
app.use((ctx) => {
try {
throw new Error('test')
} catch (e) {
ctx.raven.captureException(e, { extra: { name: 'tom' } })
ctx.status = 500
ctx.body = e.stack
}
})
app.listen(3000)
see: https://docs.sentry.io/clients/node/config/.
MIT