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

9
app.js
View file

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