@@ -583,7 +583,16 @@ 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 sentryError = reason as SentryError ;
590+ if ( sentryError . logLevel === 'log' ) {
591+ logger . log ( sentryError . message ) ;
592+ } else {
593+ logger . warn ( sentryError ) ;
594+ }
595+ }
587596 return undefined ;
588597 } ,
589598 ) ;
@@ -606,7 +615,7 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
606615 const { beforeSend, sampleRate } = this . getOptions ( ) ;
607616
608617 if ( ! this . _isEnabled ( ) ) {
609- return rejectedSyncPromise ( new SentryError ( 'SDK not enabled, will not capture event.' ) ) ;
618+ return rejectedSyncPromise ( new SentryError ( 'SDK not enabled, will not capture event.' , 'log' ) ) ;
610619 }
611620
612621 const isTransaction = event . type === 'transaction' ;
@@ -618,6 +627,7 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
618627 return rejectedSyncPromise (
619628 new SentryError (
620629 `Discarding event because it's not included in the random sample (sampling rate = ${ sampleRate } )` ,
630+ 'log' ,
621631 ) ,
622632 ) ;
623633 }
@@ -626,7 +636,7 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
626636 . then ( prepared => {
627637 if ( prepared === null ) {
628638 this . recordDroppedEvent ( 'event_processor' , event . type || 'error' ) ;
629- throw new SentryError ( 'An event processor returned null, will not send event.' ) ;
639+ throw new SentryError ( 'An event processor returned null, will not send event.' , 'log' ) ;
630640 }
631641
632642 const isInternalException = hint . data && ( hint . data as { __sentry__ : boolean } ) . __sentry__ === true ;
@@ -640,7 +650,7 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
640650 . then ( processedEvent => {
641651 if ( processedEvent === null ) {
642652 this . recordDroppedEvent ( 'before_send' , event . type || 'error' ) ;
643- throw new SentryError ( '`beforeSend` returned `null`, will not send event.' ) ;
653+ throw new SentryError ( '`beforeSend` returned `null`, will not send event.' , 'log' ) ;
644654 }
645655
646656 const session = scope && scope . getSession ( ) ;
0 commit comments