import * as Sentry from '@sentry/node' ; import { TransformableInfo } from 'logform' ; const TransportStream = require ( 'winston-transport' ) ; export class SentryTransport extends TransportStream { constructor ( ) { super ( { level : 'error' } ) ; } log ( info , next ) { if ( Sentry . getCurrentHub ( ) ?. getClient ( ) ) { if ( info . extra ) { Object . keys ( info . extra ) . forEach ( ( key ) => { Sentry . setExtra ( key , info . extra [ key ] ) ; } ) ; } Sentry . captureMessage ( info . message ) ; } next ( ) ; } }