@@ -88,7 +88,7 @@ export class Telemetry {
8888
8989 public async close ( ) : Promise < void > {
9090 this . deviceIdAbortController . abort ( ) ;
91- await this . flush ( this . eventCache . getEvents ( ) ) ;
91+ await this . flush ( ) ;
9292 }
9393
9494 /**
@@ -175,22 +175,22 @@ export class Telemetry {
175175 * Attempts to flush events through authenticated and unauthenticated clients
176176 * Falls back to caching if both attempts fail
177177 */
178- private async flush ( events : BaseEvent [ ] ) : Promise < void > {
178+ public async flush ( events ? : BaseEvent [ ] ) : Promise < void > {
179179 if ( ! this . isTelemetryEnabled ( ) ) {
180180 logger . info ( LogId . telemetryEmitFailure , "telemetry" , `Telemetry is disabled.` ) ;
181181 return ;
182182 }
183183
184184 if ( this . flushing ) {
185- this . eventCache . appendEvents ( events ) ;
185+ this . eventCache . appendEvents ( events ?? [ ] ) ;
186186 return ;
187187 }
188188
189189 this . flushing = true ;
190190
191191 try {
192192 const cachedEvents = this . eventCache . getEvents ( ) ;
193- const allEvents = [ ...cachedEvents , ...events ] ;
193+ const allEvents = [ ...cachedEvents , ...( events ?? [ ] ) ] ;
194194
195195 logger . debug (
196196 LogId . telemetryEmitStart ,
@@ -211,7 +211,7 @@ export class Telemetry {
211211 "telemetry" ,
212212 `Error sending event to client: ${ error instanceof Error ? error . message : String ( error ) } `
213213 ) ;
214- this . eventCache . appendEvents ( events ) ;
214+ this . eventCache . appendEvents ( events ?? [ ] ) ;
215215 }
216216
217217 this . flushing = false ;
0 commit comments