@@ -30,8 +30,8 @@ export class ExceptionlessClient {
3030 return this . createEvent ( pluginContextData ) . setType ( 'error' ) ;
3131 }
3232
33- public submitException ( exception :Error ) : void {
34- this . createException ( exception ) . submit ( ) ;
33+ public submitException ( exception :Error , callback ?: ( context : EventPluginContext ) => void ) : void {
34+ this . createException ( exception ) . submit ( callback ) ;
3535 }
3636
3737 public createUnhandledException ( exception :Error , submissionMethod ?:string ) : EventBuilder {
@@ -42,16 +42,16 @@ export class ExceptionlessClient {
4242 return builder ;
4343 }
4444
45- public submitUnhandledException ( exception :Error , submissionMethod ?:string ) {
46- this . createUnhandledException ( exception , submissionMethod ) . submit ( ) ;
45+ public submitUnhandledException ( exception :Error , submissionMethod ?:string , callback ?: ( context : EventPluginContext ) => void ) {
46+ this . createUnhandledException ( exception , submissionMethod ) . submit ( callback ) ;
4747 }
4848
4949 public createFeatureUsage ( feature :string ) : EventBuilder {
5050 return this . createEvent ( ) . setType ( 'usage' ) . setSource ( feature ) ;
5151 }
5252
53- public submitFeatureUsage ( feature :string ) : void {
54- this . createFeatureUsage ( feature ) . submit ( ) ;
53+ public submitFeatureUsage ( feature :string , callback ?: ( context : EventPluginContext ) => void ) : void {
54+ this . createFeatureUsage ( feature ) . submit ( callback ) ;
5555 }
5656
5757 public createLog ( message :string ) : EventBuilder ;
@@ -75,40 +75,40 @@ export class ExceptionlessClient {
7575
7676 public submitLog ( message :string ) : void ;
7777 public submitLog ( source :string , message :string ) : void ;
78- public submitLog ( source :string , message :string , level :string ) : void ;
79- public submitLog ( sourceOrMessage :string , message ?:string , level ?:string ) : void {
80- this . createLog ( sourceOrMessage , message , level ) . submit ( ) ;
78+ public submitLog ( source :string , message :string , level :string , callback ?: ( context : EventPluginContext ) => void ) : void ;
79+ public submitLog ( sourceOrMessage :string , message ?:string , level ?:string , callback ?: ( context : EventPluginContext ) => void ) : void {
80+ this . createLog ( sourceOrMessage , message , level ) . submit ( callback ) ;
8181 }
8282
8383 public createNotFound ( resource :string ) : EventBuilder {
8484 return this . createEvent ( ) . setType ( '404' ) . setSource ( resource ) ;
8585 }
8686
87- public submitNotFound ( resource :string ) : void {
88- this . createNotFound ( resource ) . submit ( ) ;
87+ public submitNotFound ( resource :string , callback ?: ( context : EventPluginContext ) => void ) : void {
88+ this . createNotFound ( resource ) . submit ( callback ) ;
8989 }
9090
9191 public createSessionStart ( sessionId :string ) : EventBuilder {
9292 return this . createEvent ( ) . setType ( 'start' ) . setSessionId ( sessionId ) ;
9393 }
9494
95- public submitSessionStart ( sessionId :string ) : void {
96- this . createSessionStart ( sessionId ) . submit ( ) ;
95+ public submitSessionStart ( sessionId :string , callback ?: ( context : EventPluginContext ) => void ) : void {
96+ this . createSessionStart ( sessionId ) . submit ( callback ) ;
9797 }
9898
9999 public createSessionEnd ( sessionId :string ) : EventBuilder {
100100 return this . createEvent ( ) . setType ( 'end' ) . setSessionId ( sessionId ) ;
101101 }
102102
103- public submitSessionEnd ( sessionId :string ) : void {
104- this . createSessionEnd ( sessionId ) . submit ( ) ;
103+ public submitSessionEnd ( sessionId :string , callback ?: ( context : EventPluginContext ) => void ) : void {
104+ this . createSessionEnd ( sessionId ) . submit ( callback ) ;
105105 }
106106
107107 public createEvent ( pluginContextData ?:ContextData ) : EventBuilder {
108108 return new EventBuilder ( { date : new Date ( ) } , this , pluginContextData ) ;
109109 }
110110
111- public submitEvent ( event :IEvent , pluginContextData ?:ContextData ) : void {
111+ public submitEvent ( event :IEvent , pluginContextData ?:ContextData , callback ?: ( context : EventPluginContext ) => void ) : void {
112112 if ( ! event ) {
113113 return ;
114114 }
@@ -126,21 +126,27 @@ export class ExceptionlessClient {
126126 }
127127
128128 var context = new EventPluginContext ( this , event , pluginContextData ) ;
129- return EventPluginManager . run ( context , ( ) => {
130- // ensure all required data
131- if ( ! event . type || event . type . length === 0 ) {
132- event . type = 'log' ;
129+ return EventPluginManager . run ( context , ( context :EventPluginContext ) => {
130+ if ( ! context . cancelled ) {
131+ // ensure all required data
132+ if ( ! event . type || event . type . length === 0 ) {
133+ event . type = 'log' ;
134+ }
135+
136+ if ( ! event . date ) {
137+ event . date = new Date ( ) ;
138+ }
139+
140+ this . config . queue . enqueue ( event ) ;
141+
142+ if ( event . reference_id && event . reference_id . length > 0 ) {
143+ this . config . log . info ( `Setting last reference id '${ event . reference_id } '` ) ;
144+ this . config . lastReferenceIdManager . setLast ( event . reference_id ) ;
145+ }
133146 }
134147
135- if ( ! event . date ) {
136- event . date = new Date ( ) ;
137- }
138-
139- this . config . queue . enqueue ( event ) ;
140-
141- if ( event . reference_id && event . reference_id . length > 0 ) {
142- this . config . log . info ( `Setting last reference id '${ event . reference_id } '` ) ;
143- this . config . lastReferenceIdManager . setLast ( event . reference_id ) ;
148+ if ( ! ! callback ) {
149+ callback ( context ) ;
144150 }
145151 } ) ;
146152 }
0 commit comments