Skip to content

Commit

Permalink
[metrics] surface user agent and original error timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
akosyakov committed Sep 26, 2023
1 parent d4e5e0a commit 65d3450
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions components/public-api/typescript/src/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) {
Expand Down Expand Up @@ -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"];
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 65d3450

Please sign in to comment.