@@ -583,7 +583,13 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
583583 return finalEvent . event_id ;
584584 } ,
585585 reason => {
586- __DEBUG_BUILD__ && logger . warn ( reason ) ;
586+ if ( __DEBUG_BUILD__ ) {
587+ // If something's gone wrong, log the error as a warning. If it's just us having used a `SentryError` for
588+ // control flow, log just the message (no stack) as a log-level log.
589+ const logLevel = ( reason as SentryError ) . logLevel || 'warn' ;
590+ const logee = logLevel === 'log' ? ( reason as SentryError ) . message : reason ;
591+ logger [ logLevel as 'log' | 'warn' ] ( logee ) ;
592+ }
587593 return undefined ;
588594 } ,
589595 ) ;
@@ -606,7 +612,7 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
606612 const { beforeSend, sampleRate } = this . getOptions ( ) ;
607613
608614 if ( ! this . _isEnabled ( ) ) {
609- return rejectedSyncPromise ( new SentryError ( 'SDK not enabled, will not capture event.' ) ) ;
615+ return rejectedSyncPromise ( new SentryError ( 'SDK not enabled, will not capture event.' , 'log' ) ) ;
610616 }
611617
612618 const isTransaction = event . type === 'transaction' ;
@@ -618,6 +624,7 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
618624 return rejectedSyncPromise (
619625 new SentryError (
620626 `Discarding event because it's not included in the random sample (sampling rate = ${ sampleRate } )` ,
627+ 'log' ,
621628 ) ,
622629 ) ;
623630 }
@@ -626,7 +633,7 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
626633 . then ( prepared => {
627634 if ( prepared === null ) {
628635 this . recordDroppedEvent ( 'event_processor' , event . type || 'error' ) ;
629- throw new SentryError ( 'An event processor returned null, will not send event.' ) ;
636+ throw new SentryError ( 'An event processor returned null, will not send event.' , 'log' ) ;
630637 }
631638
632639 const isInternalException = hint . data && ( hint . data as { __sentry__ : boolean } ) . __sentry__ === true ;
@@ -640,7 +647,7 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
640647 . then ( processedEvent => {
641648 if ( processedEvent === null ) {
642649 this . recordDroppedEvent ( 'before_send' , event . type || 'error' ) ;
643- throw new SentryError ( '`beforeSend` returned `null`, will not send event.' ) ;
650+ throw new SentryError ( '`beforeSend` returned `null`, will not send event.' , 'log' ) ;
644651 }
645652
646653 const session = scope && scope . getSession ( ) ;
0 commit comments