@@ -91,15 +91,8 @@ export abstract class BaseClient<B extends Backend, O extends Options> implement
91
91
92
92
this . _getBackend ( )
93
93
. eventFromException ( exception , hint )
94
- . then ( event => this . _processEvent ( event , hint , scope ) )
95
- . then ( finalEvent => {
96
- // We need to check for finalEvent in case beforeSend returned null
97
- eventId = finalEvent && finalEvent . event_id ;
98
- this . _processing = false ;
99
- } )
100
- . then ( null , reason => {
101
- logger . error ( reason ) ;
102
- this . _processing = false ;
94
+ . then ( event => {
95
+ eventId = this . captureEvent ( event , hint , scope ) ;
103
96
} ) ;
104
97
105
98
return eventId ;
@@ -110,24 +103,15 @@ export abstract class BaseClient<B extends Backend, O extends Options> implement
110
103
*/
111
104
public captureMessage ( message : string , level ?: Severity , hint ?: EventHint , scope ?: Scope ) : string | undefined {
112
105
let eventId : string | undefined = hint && hint . event_id ;
113
-
114
106
this . _processing = true ;
115
107
116
108
const promisedEvent = isPrimitive ( message )
117
109
? this . _getBackend ( ) . eventFromMessage ( `${ message } ` , level , hint )
118
110
: this . _getBackend ( ) . eventFromException ( message , hint ) ;
119
111
120
- promisedEvent
121
- . then ( event => this . _processEvent ( event , hint , scope ) )
122
- . then ( finalEvent => {
123
- // We need to check for finalEvent in case beforeSend returned null
124
- eventId = finalEvent && finalEvent . event_id ;
125
- this . _processing = false ;
126
- } )
127
- . then ( null , reason => {
128
- logger . error ( reason ) ;
129
- this . _processing = false ;
130
- } ) ;
112
+ promisedEvent . then ( event => {
113
+ eventId = this . captureEvent ( event , hint , scope ) ;
114
+ } ) ;
131
115
132
116
return eventId ;
133
117
}
@@ -372,6 +356,14 @@ export abstract class BaseClient<B extends Backend, O extends Options> implement
372
356
}
373
357
}
374
358
359
+ /**
360
+ * Tells the backend to send this event
361
+ * @param event The Sentry event to send
362
+ */
363
+ protected _sendEvent ( event : Event ) : void {
364
+ this . _getBackend ( ) . sendEvent ( event ) ;
365
+ }
366
+
375
367
/**
376
368
* Processes an event (either error or message) and sends it to Sentry.
377
369
*
@@ -413,7 +405,7 @@ export abstract class BaseClient<B extends Backend, O extends Options> implement
413
405
const isInternalException = hint && hint . data && ( hint . data as { [ key : string ] : any } ) . __sentry__ === true ;
414
406
// We skip beforeSend in case of transactions
415
407
if ( isInternalException || ! beforeSend || isTransaction ) {
416
- this . _getBackend ( ) . sendEvent ( finalEvent ) ;
408
+ this . _sendEvent ( finalEvent ) ;
417
409
resolve ( finalEvent ) ;
418
410
return ;
419
411
}
@@ -434,7 +426,7 @@ export abstract class BaseClient<B extends Backend, O extends Options> implement
434
426
}
435
427
436
428
// From here on we are really async
437
- this . _getBackend ( ) . sendEvent ( finalEvent ) ;
429
+ this . _sendEvent ( finalEvent ) ;
438
430
resolve ( finalEvent ) ;
439
431
}
440
432
} )
@@ -467,7 +459,7 @@ export abstract class BaseClient<B extends Backend, O extends Options> implement
467
459
return ;
468
460
}
469
461
// From here on we are really async
470
- this . _getBackend ( ) . sendEvent ( processedEvent ) ;
462
+ this . _sendEvent ( processedEvent ) ;
471
463
resolve ( processedEvent ) ;
472
464
} )
473
465
. then ( null , e => {
0 commit comments