@@ -583,7 +583,13 @@ 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 logLevel = ( reason as SentryError ) . logLevel || 'warn' ;
590
+ const logee = logLevel === 'log' ? ( reason as SentryError ) . message : reason ;
591
+ logger [ logLevel as 'log' | 'warn' ] ( logee ) ;
592
+ }
587
593
return undefined ;
588
594
} ,
589
595
) ;
@@ -606,7 +612,7 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
606
612
const { beforeSend, sampleRate } = this . getOptions ( ) ;
607
613
608
614
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' ) ) ;
610
616
}
611
617
612
618
const isTransaction = event . type === 'transaction' ;
@@ -618,6 +624,7 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
618
624
return rejectedSyncPromise (
619
625
new SentryError (
620
626
`Discarding event because it's not included in the random sample (sampling rate = ${ sampleRate } )` ,
627
+ 'log' ,
621
628
) ,
622
629
) ;
623
630
}
@@ -626,7 +633,7 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
626
633
. then ( prepared => {
627
634
if ( prepared === null ) {
628
635
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' ) ;
630
637
}
631
638
632
639
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> {
640
647
. then ( processedEvent => {
641
648
if ( processedEvent === null ) {
642
649
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' ) ;
644
651
}
645
652
646
653
const session = scope && scope . getSession ( ) ;
0 commit comments