@@ -30,8 +30,8 @@ export class ExceptionlessClient {
30
30
return this . createEvent ( pluginContextData ) . setType ( 'error' ) ;
31
31
}
32
32
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 ) ;
35
35
}
36
36
37
37
public createUnhandledException ( exception :Error , submissionMethod ?:string ) : EventBuilder {
@@ -42,16 +42,16 @@ export class ExceptionlessClient {
42
42
return builder ;
43
43
}
44
44
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 ) ;
47
47
}
48
48
49
49
public createFeatureUsage ( feature :string ) : EventBuilder {
50
50
return this . createEvent ( ) . setType ( 'usage' ) . setSource ( feature ) ;
51
51
}
52
52
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 ) ;
55
55
}
56
56
57
57
public createLog ( message :string ) : EventBuilder ;
@@ -75,40 +75,40 @@ export class ExceptionlessClient {
75
75
76
76
public submitLog ( message :string ) : void ;
77
77
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 ) ;
81
81
}
82
82
83
83
public createNotFound ( resource :string ) : EventBuilder {
84
84
return this . createEvent ( ) . setType ( '404' ) . setSource ( resource ) ;
85
85
}
86
86
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 ) ;
89
89
}
90
90
91
91
public createSessionStart ( sessionId :string ) : EventBuilder {
92
92
return this . createEvent ( ) . setType ( 'start' ) . setSessionId ( sessionId ) ;
93
93
}
94
94
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 ) ;
97
97
}
98
98
99
99
public createSessionEnd ( sessionId :string ) : EventBuilder {
100
100
return this . createEvent ( ) . setType ( 'end' ) . setSessionId ( sessionId ) ;
101
101
}
102
102
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 ) ;
105
105
}
106
106
107
107
public createEvent ( pluginContextData ?:ContextData ) : EventBuilder {
108
108
return new EventBuilder ( { date : new Date ( ) } , this , pluginContextData ) ;
109
109
}
110
110
111
- public submitEvent ( event :IEvent , pluginContextData ?:ContextData ) : void {
111
+ public submitEvent ( event :IEvent , pluginContextData ?:ContextData , callback ?: ( context : EventPluginContext ) => void ) : void {
112
112
if ( ! event ) {
113
113
return ;
114
114
}
@@ -126,21 +126,27 @@ export class ExceptionlessClient {
126
126
}
127
127
128
128
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
+ }
133
146
}
134
147
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 ) ;
144
150
}
145
151
} ) ;
146
152
}
0 commit comments