import winstonTransport from 'winston-transport'; import * as Sentry from '@sentry/node'; export class SentryWinston extends winstonTransport { private levelMap = { error: 'error', warn: 'warning', info: 'info', verbose: 'debug', debug: 'debug', silly: 'debug', }; constructor(opts: any) { super(opts); // eslint-disable-next-line no-param-reassign opts.environment = process.env.NODE_ENV; Sentry.init(opts); } log(info, callback) { setImmediate(() => { this.emit('logged', info); }); Sentry.captureEvent(info); callback(); } }