Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1b68720

Browse files
[metrics] surface user agent and original error timestamp (#18803)
1 parent 6c5d102 commit 1b68720

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

‎components/dashboard/src/service/service.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ function testPublicAPI(service: any): void {
157157
backoff = BASE_BACKOFF;
158158
}
159159
} catch (e) {
160-
if (ConnectError.from(e).code === Code.Canceled) {
160+
if (einstanceofConnectError&&e.code === Code.DeadlineExceeded) {
161161
// timeout is expected, continue as usual
162162
backoff = BASE_BACKOFF;
163163
} else {

‎components/public-api/typescript/src/metrics.ts‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,9 @@ export class MetricsReporter {
271271
},
272272
) {
273273
this.metricsHost = `ide.${new URL(options.gitpodUrl).hostname}`;
274+
if (typeof window !== "undefined") {
275+
this.options.commonErrorDetails["userAgent"] = window.navigator.userAgent
276+
}
274277
}
275278

276279
updateCommonErrorDetails(update: { [key: string]: string | undefined }) {
@@ -305,6 +308,9 @@ export class MetricsReporter {
305308
if (!enabled) {
306309
return;
307310
}
311+
if (typeof window !== undefined && !window.navigator.onLine) {
312+
return;
313+
}
308314

309315
const metrics = await register.getMetricsAsJSON();
310316
register.resetMetrics();
@@ -404,9 +410,14 @@ export class MetricsReporter {
404410
return;
405411
}
406412
const properties = { ...data, ...this.options.commonErrorDetails };
413+
properties["error_timestamp"] = new Date().toISOString();
407414
properties["error_name"] = error.name;
408415
properties["error_message"] = error.message;
409416

417+
if (typeof window !== undefined) {
418+
properties["onLine"] = String(window.navigator.onLine);
419+
}
420+
410421
const workspaceId = properties["workspaceId"];
411422
const instanceId = properties["instanceId"];
412423
const userId = properties["userId"];
@@ -456,7 +467,11 @@ export class MetricsReporter {
456467

457468
private async send(request: MetricsRequest | undefined): Promise<void> {
458469
if (!request) {
459-
return request;
470+
return;
471+
}
472+
if (typeof window !== undefined && !window.navigator.onLine) {
473+
this.push(request);
474+
return;
460475
}
461476
this.sendQueue = this.sendQueue.then(async () => {
462477
try {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /