1+ /// <reference path="typings/tsd.d.ts" />
12
23// TODO: We'll need a poly fill for promises.
34module Exceptionless {
@@ -94,6 +95,7 @@ module Exceptionless {
9495 return ;
9596 }
9697
98+ var key = '${this.queuePath()}-${new Date().toJSON()}-${Math.floor(Math.random() * 9007199254740992)}' ;
9799 return this . _config . storage . save ( key , event ) ;
98100 }
99101
@@ -112,6 +114,7 @@ module Exceptionless {
112114
113115 try {
114116 var events = this . _config . storage . get ( this . queuePath ( ) , this . _config . submissionBatchSize ) ;
117+ this . _config . submissionClient . submit ( events , this . _config )
115118 . then < any > ( ( response :SubmissionResponse ) => {
116119 if ( response . success ) {
117120 this . _config . log . info ( 'Sent ' + events . length + ' events to "' + this . _config . serverUrl + '".' ) ;
@@ -167,6 +170,7 @@ module Exceptionless {
167170 durationInMinutes = 5 ;
168171 }
169172
173+ this . _config . log . info ( 'Suspending processing for ${durationInMinutes}minutes.' ) ;
170174 this . _suspendProcessingUntil = new Date ( new Date ( ) . getTime ( ) + ( durationInMinutes * 60000 ) ) ;
171175 //_queueTimer.Change(duration.Value, _processQueueInterval);
172176
@@ -209,26 +213,34 @@ module Exceptionless {
209213 }
210214
211215 export interface ISubmissionClient {
216+ submit ( events :ExceptionlessEvent [ ] , config :Configuration ) : Promise < SubmissionResponse > ;
217+ submitDescription ( referenceId :string , description :UserDescription , config :Configuration ) : Promise < SubmissionResponse > ;
212218 getSettings ( config :Configuration ) : Promise < SettingsResponse > ;
213219 }
214220
215221 export class SubmissionClient implements ISubmissionClient {
222+ public submit ( events :ExceptionlessEvent [ ] , config :Configuration ) : Promise < SubmissionResponse > {
223+ var url = '${config.serverUrl}/events?access_token=${encodeURIComponent(config.apiKey)}' ;
216224 return this . sendRequest ( 'POST' , url , JSON . stringify ( events ) ) . then (
217225 xhr => { return new SubmissionResponse ( xhr . status , this . getResponseMessage ( xhr ) ) ; } ,
218226 xhr => { return new SubmissionResponse ( xhr . status || 500 , this . getResponseMessage ( xhr ) ) ; }
219227 ) ;
220228 }
221229
230+ public submitDescription ( referenceId :string , description :UserDescription , config :Configuration ) : Promise < SubmissionResponse > {
231+ var url = '${config.serverUrl}/events/by-ref/${encodeURIComponent(referenceId)}/user-description?access_token=${encodeURIComponent(config.apiKey)}' ;
222232 return this . sendRequest ( 'POST' , url , JSON . stringify ( description ) ) . then (
223233 xhr => { return new SubmissionResponse ( xhr . status , this . getResponseMessage ( xhr ) ) ; } ,
224234 xhr => { return new SubmissionResponse ( xhr . status || 500 , this . getResponseMessage ( xhr ) ) ; }
225235 ) ;
226236 }
227237
228238 public getSettings ( config :Configuration ) : Promise < SettingsResponse > {
239+ var url = '${config.serverUrl}/projects/config?access_token=${encodeURIComponent(config.apiKey)}' ;
229240 return this . sendRequest ( 'GET' , url ) . then (
230241 xhr => {
231242 if ( xhr . status !== 200 ) {
243+ return new SettingsResponse ( false , null , - 1 , null , 'Unable to retrieve configuration settings: ${this.getResponseMessage(xhr)}' ) ;
232244 }
233245
234246 var settings = JSON . parse ( xhr . responseText ) ;
0 commit comments