11import { BaseClient , Scope , SDK_VERSION } from '@sentry/core' ;
22import { SessionFlusher } from '@sentry/hub' ;
3- import { Event , EventHint } from '@sentry/types' ;
4- import { logger } from '@sentry/utils' ;
3+ import { Event , EventHint , SeverityLevel , Transport , TransportOptions } from '@sentry/types' ;
4+ import { Dsn , logger } from '@sentry/utils' ;
55
6- import { NodeBackend } from './backend' ;
6+ import { eventFromException , eventFromMessage } from './eventbuilder' ;
7+ import { HTTPSTransport , HTTPTransport } from './transports' ;
78import { NodeOptions } from './types' ;
89
910/**
@@ -12,7 +13,7 @@ import { NodeOptions } from './types';
1213 * @see NodeOptions for documentation on configuration options.
1314 * @see SentryClient for usage documentation.
1415 */
15- export class NodeClient extends BaseClient < NodeBackend , NodeOptions > {
16+ export class NodeClient extends BaseClient < NodeOptions > {
1617 protected _sessionFlusher : SessionFlusher | undefined ;
1718
1819 /**
@@ -32,7 +33,7 @@ export class NodeClient extends BaseClient<NodeBackend, NodeOptions> {
3233 version : SDK_VERSION ,
3334 } ;
3435
35- super ( NodeBackend , options ) ;
36+ super ( options ) ;
3637 }
3738
3839 /**
@@ -127,4 +128,49 @@ export class NodeClient extends BaseClient<NodeBackend, NodeOptions> {
127128 this . _sessionFlusher . incrementSessionStatusCount ( ) ;
128129 }
129130 }
131+
132+ /**
133+ * @inheritDoc
134+ */
135+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
136+ protected _eventFromException ( exception : any , hint ?: EventHint ) : PromiseLike < Event > {
137+ return eventFromException ( this . _options , exception , hint ) ;
138+ }
139+
140+ /**
141+ * @inheritDoc
142+ */
143+ protected _eventFromMessage ( message : string , level : SeverityLevel = 'info' , hint ?: EventHint ) : PromiseLike < Event > {
144+ return eventFromMessage ( this . _options , message , level , hint ) ;
145+ }
146+
147+ /**
148+ * @inheritDoc
149+ */
150+ protected _setupTransport ( ) : Transport {
151+ if ( ! this . _options . dsn ) {
152+ // We return the noop transport here in case there is no Dsn.
153+ return super . _setupTransport ( ) ;
154+ }
155+
156+ const dsn = new Dsn ( this . _options . dsn ) ;
157+
158+ const transportOptions : TransportOptions = {
159+ ...this . _options . transportOptions ,
160+ ...( this . _options . httpProxy && { httpProxy : this . _options . httpProxy } ) ,
161+ ...( this . _options . httpsProxy && { httpsProxy : this . _options . httpsProxy } ) ,
162+ ...( this . _options . caCerts && { caCerts : this . _options . caCerts } ) ,
163+ dsn : this . _options . dsn ,
164+ tunnel : this . _options . tunnel ,
165+ _metadata : this . _options . _metadata ,
166+ } ;
167+
168+ if ( this . _options . transport ) {
169+ return new this . _options . transport ( transportOptions ) ;
170+ }
171+ if ( dsn . protocol === 'http' ) {
172+ return new HTTPTransport ( transportOptions ) ;
173+ }
174+ return new HTTPSTransport ( transportOptions ) ;
175+ }
130176}
0 commit comments