@@ -3,9 +3,11 @@ import { Configuration } from './configuration/Configuration';
33import { EventBuilder } from './EventBuilder' ;
44import { IEvent } from './models/IEvent' ;
55import { IError } from './models/IError' ;
6+ import { IUserDescription } from './models/IUserDescription' ;
67import { EventPluginContext } from './plugins/EventPluginContext' ;
78import { EventPluginManager } from './plugins/EventPluginManager' ;
89import { ContextData } from './plugins/ContextData' ;
10+ import { SubmissionResponse } from './submission/SubmissionResponse' ;
911
1012export class ExceptionlessClient {
1113 public config :Configuration ;
@@ -108,6 +110,12 @@ export class ExceptionlessClient {
108110 return new EventBuilder ( { date : new Date ( ) } , this , pluginContextData ) ;
109111 }
110112
113+ /**
114+ * Submits the event to be sent to the server.
115+ * @param event The event data.
116+ * @param pluginContextData Any contextual data objects to be used by Exceptionless plugins to gather default information for inclusion in the report information.
117+ * @param callback
118+ */
111119 public submitEvent ( event :IEvent , pluginContextData ?:ContextData , callback ?:( context :EventPluginContext ) => void ) : void {
112120 if ( ! event ) {
113121 return ;
@@ -153,6 +161,37 @@ export class ExceptionlessClient {
153161 } ) ;
154162 }
155163
164+ /**
165+ * Updates the user's email address and description of an event for the specified reference id.
166+ * @param referenceId The reference id of the event to update.
167+ * @param email The user's email address to set on the event.
168+ * @param description The user's description of the event.
169+ */
170+ public updateUserEmailAndDescription ( referenceId :string , email :string , description :string , callback ?:( response :SubmissionResponse ) => void ) {
171+ if ( ! referenceId || ! email || ! description ) {
172+ return ;
173+ }
174+
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 ) => {
181+ if ( ! response . success ) {
182+ this . config . log . error ( `Failed to submit user email and description for event '${ referenceId } ': ${ response . statusCode } ${ response . message } ` )
183+ }
184+
185+ if ( ! ! callback ) {
186+ callback ( response ) ;
187+ }
188+ } ) ;
189+ }
190+
191+ /**
192+ * Gets the last event client id that was submitted to the server.
193+ * @returns {string } The event client id.
194+ */
156195 public getLastReferenceId ( ) : string {
157196 return this . config . lastReferenceIdManager . getLast ( ) ;
158197 }
0 commit comments