@@ -127,7 +127,7 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
127127 if ( options . dsn ) {
128128 this . _dsn = makeDsn ( options . dsn ) ;
129129 } else {
130- __DEBUG_BUILD__ && logger . warn ( 'No DSN provided, client will not do anything .' ) ;
130+ __DEBUG_BUILD__ && logger . warn ( 'No DSN provided, client will not send events .' ) ;
131131 }
132132
133133 if ( this . _dsn ) {
@@ -216,11 +216,6 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
216216 * @inheritDoc
217217 */
218218 public captureSession ( session : Session ) : void {
219- if ( ! this . _isEnabled ( ) ) {
220- __DEBUG_BUILD__ && logger . warn ( 'SDK not enabled, will not capture session.' ) ;
221- return ;
222- }
223-
224219 if ( ! ( typeof session . release === 'string' ) ) {
225220 __DEBUG_BUILD__ && logger . warn ( 'Discarded session because of missing or non-string release' ) ;
226221 } else {
@@ -297,8 +292,8 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
297292 /**
298293 * Sets up the integrations
299294 */
300- public setupIntegrations ( ) : void {
301- if ( this . _isEnabled ( ) && ! this . _integrationsInitialized ) {
295+ public setupIntegrations ( forceInitialize ?: boolean ) : void {
296+ if ( ( forceInitialize && ! this . _integrationsInitialized ) || ( this . _isEnabled ( ) && ! this . _integrationsInitialized ) ) {
302297 this . _integrations = setupIntegrations ( this , this . _options . integrations ) ;
303298 this . _integrationsInitialized = true ;
304299 }
@@ -338,34 +333,30 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
338333 public sendEvent ( event : Event , hint : EventHint = { } ) : void {
339334 this . emit ( 'beforeSendEvent' , event , hint ) ;
340335
341- if ( this . _dsn ) {
342- let env = createEventEnvelope ( event , this . _dsn , this . _options . _metadata , this . _options . tunnel ) ;
343-
344- for ( const attachment of hint . attachments || [ ] ) {
345- env = addItemToEnvelope (
346- env ,
347- createAttachmentEnvelopeItem (
348- attachment ,
349- this . _options . transportOptions && this . _options . transportOptions . textEncoder ,
350- ) ,
351- ) ;
352- }
336+ let env = createEventEnvelope ( event , this . _dsn , this . _options . _metadata , this . _options . tunnel ) ;
353337
354- const promise = this . _sendEnvelope ( env ) ;
355- if ( promise ) {
356- promise . then ( sendResponse => this . emit ( 'afterSendEvent' , event , sendResponse ) , null ) ;
357- }
338+ for ( const attachment of hint . attachments || [ ] ) {
339+ env = addItemToEnvelope (
340+ env ,
341+ createAttachmentEnvelopeItem (
342+ attachment ,
343+ this . _options . transportOptions && this . _options . transportOptions . textEncoder ,
344+ ) ,
345+ ) ;
346+ }
347+
348+ const promise = this . _sendEnvelope ( env ) ;
349+ if ( promise ) {
350+ promise . then ( sendResponse => this . emit ( 'afterSendEvent' , event , sendResponse ) , null ) ;
358351 }
359352 }
360353
361354 /**
362355 * @inheritDoc
363356 */
364357 public sendSession ( session : Session | SessionAggregates ) : void {
365- if ( this . _dsn ) {
366- const env = createSessionEnvelope ( session , this . _dsn , this . _options . _metadata , this . _options . tunnel ) ;
367- void this . _sendEnvelope ( env ) ;
368- }
358+ const env = createSessionEnvelope ( session , this . _dsn , this . _options . _metadata , this . _options . tunnel ) ;
359+ void this . _sendEnvelope ( env ) ;
369360 }
370361
371362 /**
@@ -531,9 +522,9 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
531522 } ) ;
532523 }
533524
534- /** Determines whether this SDK is enabled and a valid Dsn is present. */
525+ /** Determines whether this SDK is enabled and a transport is present. */
535526 protected _isEnabled ( ) : boolean {
536- return this . getOptions ( ) . enabled !== false && this . _dsn !== undefined ;
527+ return this . getOptions ( ) . enabled !== false && this . _transport !== undefined ;
537528 }
538529
539530 /**
@@ -635,10 +626,6 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
635626 const options = this . getOptions ( ) ;
636627 const { sampleRate } = options ;
637628
638- if ( ! this . _isEnabled ( ) ) {
639- return rejectedSyncPromise ( new SentryError ( 'SDK not enabled, will not capture event.' , 'log' ) ) ;
640- }
641-
642629 const isTransaction = isTransactionEvent ( event ) ;
643630 const isError = isErrorEvent ( event ) ;
644631 const eventType = event . type || 'error' ;
@@ -738,9 +725,9 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
738725 * @inheritdoc
739726 */
740727 protected _sendEnvelope ( envelope : Envelope ) : PromiseLike < void | TransportMakeRequestResponse > | void {
741- if ( this . _transport && this . _dsn ) {
742- this . emit ( 'beforeEnvelope' , envelope ) ;
728+ this . emit ( 'beforeEnvelope' , envelope ) ;
743729
730+ if ( this . _isEnabled ( ) && this . _transport ) {
744731 return this . _transport . send ( envelope ) . then ( null , reason => {
745732 __DEBUG_BUILD__ && logger . error ( 'Error while sending event:' , reason ) ;
746733 } ) ;
0 commit comments