Add request context to Sentry errors

This commit is contained in:
Jonathan Cremin 2020-04-28 19:54:02 +01:00
parent 5ba3016557
commit 78df53d569

7
app.js
View file

@ -38,9 +38,14 @@ if (process.env.NODE_ENV === 'production') {
app.proxy = true; app.proxy = true;
} }
app.on('error', (err) => { app.on('error', (err, ctx) => {
if (!err.status || err.status >= 500) { if (!err.status || err.status >= 500) {
Sentry.withScope(function(scope) {
scope.addEventProcessor(function(event) {
return Sentry.Handlers.parseRequest(event, ctx.request);
});
Sentry.captureException(err); Sentry.captureException(err);
});
} }
}); });