@@ -117,12 +117,21 @@ export class ExceptionlessClient {
117117 * @param callback
118118 */
119119 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+
120128 if ( ! event ) {
121- return ;
129+ return cancelled ( ) ;
122130 }
123131
124132 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 ( ) ;
126135 }
127136
128137 if ( ! event . data ) {
@@ -155,9 +164,7 @@ export class ExceptionlessClient {
155164 }
156165 }
157166
158- if ( ! ! callback ) {
159- callback ( context ) ;
160- }
167+ ! ! callback && callback ( context ) ;
161168 } ) ;
162169 }
163170
@@ -168,23 +175,17 @@ export class ExceptionlessClient {
168175 * @param description The user's description of the event.
169176 */
170177 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' ) ) ;
173180 }
174181
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 ) => {
181184 if ( ! response . success ) {
182185 this . config . log . error ( `Failed to submit user email and description for event '${ referenceId } ': ${ response . statusCode } ${ response . message } ` )
183186 }
184187
185- if ( ! ! callback ) {
186- callback ( response ) ;
187- }
188+ ! ! callback && callback ( response ) ;
188189 } ) ;
189190 }
190191
@@ -201,6 +202,7 @@ export class ExceptionlessClient {
201202 if ( ExceptionlessClient . _instance === null ) {
202203 ExceptionlessClient . _instance = new ExceptionlessClient ( null ) ;
203204 }
205+
204206 return ExceptionlessClient . _instance ;
205207 }
206208}
0 commit comments