in projects/user-telemetry-client/src/TelemetryService.ts [30:64]
private async sendEvents(): Promise<void> {
const [firstChunk, ...subsequentChunks] = chunk(this.eventBuffer, this.postEventLimit);
if (!firstChunk) {
return Promise.resolve();
}
const jsonEventBuffer = JSON.stringify(firstChunk);
// Push the remaining events back into the buffer
this.eventBuffer = subsequentChunks.flat();
let requestInit: RequestInit = {
method: "POST",
mode: "cors",
headers: new Headers({
"Content-Type": "application/json"
}),
body: jsonEventBuffer
}
const requestInitWithAuthentication = this.authenticators.reduce((request, middleware) => {
return middleware(request);
}, requestInit);
const response = await fetch(`${this.telemetryUrl}/event`, requestInitWithAuthentication);
if (!response.ok) {
this.eventBuffer = this.eventBuffer.concat(firstChunk);
}
if (this.eventBuffer.length) {
this.throttledSendEvents();
}
}