import { BaseBackend } from '@sentry/core' ; import { Event , EventHint , SeverityLevel , Transport , TransportOptions } from '@sentry/types' ; import { makeDsn } from '@sentry/utils' ; import { eventFromException , eventFromMessage } from './eventbuilder' ; import { HTTPSTransport , HTTPTransport } from './transports' ; import { NodeOptions } from './types' ; hidden export class NodeBackend extends BaseBackend < NodeOptions > { inheritDoc public eventFromException ( exception , hint ? ) { return eventFromException ( this . _options , exception , hint ) ; } inheritDoc public eventFromMessage ( message , level = 'info' , hint ? ) { return eventFromMessage ( this . _options , message , level , hint ) ; } inheritDoc protected _setupTransport ( ) { if ( ! this . _options . dsn ) { return super . _setupTransport ( ) ; } const dsn = makeDsn ( this . _options . dsn ) ; const transportOptions = { ... this . _options . transportOptions , ... ( this . _options . httpProxy && { httpProxy : this . _options . httpProxy } ) , ... ( this . _options . httpsProxy && { httpsProxy : this . _options . httpsProxy } ) , ... ( this . _options . caCerts && { caCerts : this . _options . caCerts } ) , dsn : this . _options . dsn , tunnel : this . _options . tunnel , _metadata : this . _options . _metadata , } ; if ( this . _options . transport ) { return new this . _options . transport ( transportOptions ) ; } if ( dsn . protocol === 'http' ) { return new HTTPTransport ( transportOptions ) ; } return new HTTPSTransport ( transportOptions ) ; } }