From 65d3450b1d93b4a74a987aabf950830ce424472c Mon Sep 17 00:00:00 2001 From: Anton Kosyakov Date: Tue, 26 Sep 2023 09:22:30 +0000 Subject: [PATCH] [metrics] surface user agent and original error timestamp --- components/public-api/typescript/src/metrics.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/components/public-api/typescript/src/metrics.ts b/components/public-api/typescript/src/metrics.ts index b18e9e3cab893c..53d471029c5606 100644 --- a/components/public-api/typescript/src/metrics.ts +++ b/components/public-api/typescript/src/metrics.ts @@ -271,6 +271,9 @@ export class MetricsReporter { }, ) { this.metricsHost = `ide.${new URL(options.gitpodUrl).hostname}`; + if (typeof window !== "undefined") { + this.options.commonErrorDetails["userAgent"] = window.navigator.userAgent + } } updateCommonErrorDetails(update: { [key: string]: string | undefined }) { @@ -404,9 +407,14 @@ export class MetricsReporter { return; } const properties = { ...data, ...this.options.commonErrorDetails }; + properties["error_timestamp"] = new Date().toISOString(); properties["error_name"] = error.name; properties["error_message"] = error.message; + if (typeof window !== undefined) { + properties["onLine"] = String(window.navigator.onLine); + } + const workspaceId = properties["workspaceId"]; const instanceId = properties["instanceId"]; const userId = properties["userId"]; @@ -458,6 +466,9 @@ export class MetricsReporter { if (!request) { return request; } + if (typeof window !== undefined && !window.navigator.onLine) { + this.push(request); + } this.sendQueue = this.sendQueue.then(async () => { try { const response = await fetch(request.url, request);