diff --git a/components/dashboard/src/service/service.tsx b/components/dashboard/src/service/service.tsx index 530f6d3dac2462..b7e9f909d42219 100644 --- a/components/dashboard/src/service/service.tsx +++ b/components/dashboard/src/service/service.tsx @@ -157,7 +157,7 @@ function testPublicAPI(service: any): void { backoff = BASE_BACKOFF; } } catch (e) { - if (ConnectError.from(e).code === Code.Canceled) { + if (e instanceof ConnectError && e.code === Code.DeadlineExceeded) { // timeout is expected, continue as usual backoff = BASE_BACKOFF; } else { diff --git a/components/public-api/typescript/src/metrics.ts b/components/public-api/typescript/src/metrics.ts index b18e9e3cab893c..20c41f14fd347e 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 }) { @@ -305,6 +308,9 @@ export class MetricsReporter { if (!enabled) { return; } + if (typeof window !== undefined && !window.navigator.onLine) { + return; + } const metrics = await register.getMetricsAsJSON(); register.resetMetrics(); @@ -404,9 +410,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"]; @@ -456,7 +467,11 @@ export class MetricsReporter { private async send(request: MetricsRequest | undefined): Promise { if (!request) { - return request; + return; + } + if (typeof window !== undefined && !window.navigator.onLine) { + this.push(request); + return; } this.sendQueue = this.sendQueue.then(async () => { try {