Add request context to sentry exceptions

This commit is contained in:
Jonathan Cremin 2020-04-28 20:31:46 +01:00
parent 20fcbe40ac
commit 2fab9866f7

9
app.js
View file

@ -66,11 +66,14 @@ app.use(web.prefix('').routes());
app.ws.use(redis.middleware());
app.ws.use(ws.prefix('/api').routes());
app.on('error', (err) => {
app.on('error', (err, ctx) => {
if (err.statusCode === 404) return;
if (process.env.SENTRY_DSN) {
Sentry.captureException(err, (_err, eventId) => {
debug('Reported error', eventId);
Sentry.withScope(function(scope) {
scope.addEventProcessor(function(event) {
return Sentry.Handlers.parseRequest(event, ctx.request);
});
Sentry.captureException(err);
});
}
});