@@ -117,12 +117,21 @@ export class ExceptionlessClient {
117
117
* @param callback
118
118
*/
119
119
public submitEvent ( event :IEvent , pluginContextData ?:ContextData , callback ?:( context :EventPluginContext ) => void ) : void {
120
+ function cancelled ( ) {
121
+ if ( ! ! context ) {
122
+ context . cancelled = true ;
123
+ }
124
+
125
+ return ! ! callback && callback ( context ) ;
126
+ }
127
+
120
128
if ( ! event ) {
121
- return ;
129
+ return cancelled ( ) ;
122
130
}
123
131
124
132
if ( ! this . config . enabled ) {
125
- return this . config . log . info ( 'Event submission is currently disabled.' ) ;
133
+ this . config . log . info ( 'Event submission is currently disabled.' ) ;
134
+ return cancelled ( ) ;
126
135
}
127
136
128
137
if ( ! event . data ) {
@@ -155,9 +164,7 @@ export class ExceptionlessClient {
155
164
}
156
165
}
157
166
158
- if ( ! ! callback ) {
159
- callback ( context ) ;
160
- }
167
+ ! ! callback && callback ( context ) ;
161
168
} ) ;
162
169
}
163
170
@@ -168,23 +175,17 @@ export class ExceptionlessClient {
168
175
* @param description The user's description of the event.
169
176
*/
170
177
public updateUserEmailAndDescription ( referenceId :string , email :string , description :string , callback ?:( response :SubmissionResponse ) => void ) {
171
- if ( ! referenceId || ! email || ! description ) {
172
- return ;
178
+ if ( ! referenceId || ! email || ! description || ! this . config . enabled ) {
179
+ return ! ! callback && callback ( new SubmissionResponse ( 500 , 'cancelled' ) ) ;
173
180
}
174
181
175
- if ( ! this . config . enabled ) {
176
- return this . config . log . info ( 'Configuration is disabled. The event will not be updated with the user email and description.' ) ;
177
- }
178
-
179
- var description :IUserDescription = { email : email , description : description } ;
180
- var response = this . config . submissionClient . postUserDescription ( referenceId , description , this . config , ( response :SubmissionResponse ) => {
182
+ var userDescription :IUserDescription = { email_address : email , description : description } ;
183
+ var response = this . config . submissionClient . postUserDescription ( referenceId , userDescription , this . config , ( response :SubmissionResponse ) => {
181
184
if ( ! response . success ) {
182
185
this . config . log . error ( `Failed to submit user email and description for event '${ referenceId } ': ${ response . statusCode } ${ response . message } ` )
183
186
}
184
187
185
- if ( ! ! callback ) {
186
- callback ( response ) ;
187
- }
188
+ ! ! callback && callback ( response ) ;
188
189
} ) ;
189
190
}
190
191
@@ -201,6 +202,7 @@ export class ExceptionlessClient {
201
202
if ( ExceptionlessClient . _instance === null ) {
202
203
ExceptionlessClient . _instance = new ExceptionlessClient ( null ) ;
203
204
}
205
+
204
206
return ExceptionlessClient . _instance ;
205
207
}
206
208
}
0 commit comments