@@ -3,9 +3,11 @@ import { Configuration } from './configuration/Configuration';
3
3
import { EventBuilder } from './EventBuilder' ;
4
4
import { IEvent } from './models/IEvent' ;
5
5
import { IError } from './models/IError' ;
6
+ import { IUserDescription } from './models/IUserDescription' ;
6
7
import { EventPluginContext } from './plugins/EventPluginContext' ;
7
8
import { EventPluginManager } from './plugins/EventPluginManager' ;
8
9
import { ContextData } from './plugins/ContextData' ;
10
+ import { SubmissionResponse } from './submission/SubmissionResponse' ;
9
11
10
12
export class ExceptionlessClient {
11
13
public config :Configuration ;
@@ -108,6 +110,12 @@ export class ExceptionlessClient {
108
110
return new EventBuilder ( { date : new Date ( ) } , this , pluginContextData ) ;
109
111
}
110
112
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
+ */
111
119
public submitEvent ( event :IEvent , pluginContextData ?:ContextData , callback ?:( context :EventPluginContext ) => void ) : void {
112
120
if ( ! event ) {
113
121
return ;
@@ -153,6 +161,37 @@ export class ExceptionlessClient {
153
161
} ) ;
154
162
}
155
163
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
+ */
156
195
public getLastReferenceId ( ) : string {
157
196
return this . config . lastReferenceIdManager . getLast ( ) ;
158
197
}
0 commit comments