@@ -91,15 +91,8 @@ export abstract class BaseClient<B extends Backend, O extends Options> implement
9191
9292 this . _getBackend ( )
9393 . 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 ) ;
10396 } ) ;
10497
10598 return eventId ;
@@ -110,24 +103,15 @@ export abstract class BaseClient<B extends Backend, O extends Options> implement
110103 */
111104 public captureMessage ( message : string , level ?: Severity , hint ?: EventHint , scope ?: Scope ) : string | undefined {
112105 let eventId : string | undefined = hint && hint . event_id ;
113-
114106 this . _processing = true ;
115107
116108 const promisedEvent = isPrimitive ( message )
117109 ? this . _getBackend ( ) . eventFromMessage ( `${ message } ` , level , hint )
118110 : this . _getBackend ( ) . eventFromException ( message , hint ) ;
119111
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+ } ) ;
131115
132116 return eventId ;
133117 }
@@ -372,6 +356,14 @@ export abstract class BaseClient<B extends Backend, O extends Options> implement
372356 }
373357 }
374358
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+
375367 /**
376368 * Processes an event (either error or message) and sends it to Sentry.
377369 *
@@ -413,7 +405,7 @@ export abstract class BaseClient<B extends Backend, O extends Options> implement
413405 const isInternalException = hint && hint . data && ( hint . data as { [ key : string ] : any } ) . __sentry__ === true ;
414406 // We skip beforeSend in case of transactions
415407 if ( isInternalException || ! beforeSend || isTransaction ) {
416- this . _getBackend ( ) . sendEvent ( finalEvent ) ;
408+ this . _sendEvent ( finalEvent ) ;
417409 resolve ( finalEvent ) ;
418410 return ;
419411 }
@@ -434,7 +426,7 @@ export abstract class BaseClient<B extends Backend, O extends Options> implement
434426 }
435427
436428 // From here on we are really async
437- this . _getBackend ( ) . sendEvent ( finalEvent ) ;
429+ this . _sendEvent ( finalEvent ) ;
438430 resolve ( finalEvent ) ;
439431 }
440432 } )
@@ -467,7 +459,7 @@ export abstract class BaseClient<B extends Backend, O extends Options> implement
467459 return ;
468460 }
469461 // From here on we are really async
470- this . _getBackend ( ) . sendEvent ( processedEvent ) ;
462+ this . _sendEvent ( processedEvent ) ;
471463 resolve ( processedEvent ) ;
472464 } )
473465 . then ( null , e => {
0 commit comments