chore: Capture event data to error tracker when background jobs fail

This commit is contained in:
Tom Moor
2020-05-25 13:48:50 -07:00
parent 62dd1e41f9
commit 7f07cb57a2

View File

@ -1,4 +1,5 @@
// @flow
import * as Sentry from '@sentry/node';
import { createQueue } from './utils/queue';
import services from './services';
@ -144,7 +145,16 @@ serviceEventsQueue.process(async job => {
const service = services[event.service];
if (service.on) {
service.on(event);
service.on(event).catch(error => {
if (process.env.SENTRY_DSN) {
Sentry.withScope(function(scope) {
scope.setExtra('event', event);
Sentry.captureException(error);
});
} else {
throw error;
}
});
}
});