@@ -583,7 +583,16 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
583
583
return finalEvent . event_id ;
584
584
} ,
585
585
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
+ }
587
596
return undefined ;
588
597
} ,
589
598
) ;
@@ -606,7 +615,7 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
606
615
const { beforeSend, sampleRate } = this . getOptions ( ) ;
607
616
608
617
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' ) ) ;
610
619
}
611
620
612
621
const isTransaction = event . type === 'transaction' ;
@@ -618,6 +627,7 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
618
627
return rejectedSyncPromise (
619
628
new SentryError (
620
629
`Discarding event because it's not included in the random sample (sampling rate = ${ sampleRate } )` ,
630
+ 'log' ,
621
631
) ,
622
632
) ;
623
633
}
@@ -626,7 +636,7 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
626
636
. then ( prepared => {
627
637
if ( prepared === null ) {
628
638
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' ) ;
630
640
}
631
641
632
642
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> {
640
650
. then ( processedEvent => {
641
651
if ( processedEvent === null ) {
642
652
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' ) ;
644
654
}
645
655
646
656
const session = scope && scope . getSession ( ) ;
0 commit comments