Skip to content

Commit 754b44f

Browse files
committed
💄
1 parent f57dcfd commit 754b44f

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

src/vs/gitpod/browser/gitpodInsightsAppender.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,16 @@ export class GitpodInsightsAppender implements ITelemetryAppender {
109109
instanceId: gitpodWsInfo.instanceId,
110110
errorStack: error.callstack,
111111
userId: '',
112-
component: 'vscode-workbench',
113-
version: this._baseProperties.appName + '-' + this._baseProperties.version, // Align to https://github.com/gitpod-io/gitpod/blob/fe26d2613df2f85667829c9de86bbeb187dc81cf/components/ide/code/leeway.Dockerfile#L75
112+
component: 'vscode-web',
113+
version: this._baseProperties.version,
114114
properties: {
115115
error_name: error.uncaught_error_name,
116116
error_message: error.msg,
117117
...this._baseProperties,
118118
}
119119
};
120120
if (this.devMode && this.productService.gitpodPreview?.log?.errorReports) {
121-
console.log('Gitpod Metrics: ', JSON.stringify(params, undefined, 2));
121+
console.log('Gitpod Error Reports: ', JSON.stringify(params, undefined, 2));
122122
}
123123
const doSend = await this.getSendErrorReports();
124124
if (doSend) {
@@ -156,13 +156,6 @@ export class GitpodInsightsAppender implements ITelemetryAppender {
156156
if (this._gitpodWsInfo) {
157157
return this._gitpodWsInfo;
158158
}
159-
if (this.devMode) {
160-
return this._gitpodWsInfo = (async () => ({
161-
gitpodHost: this.productService.gitpodPreview?.host ?? 'gitpod-staging.com',
162-
workspaceId: 'fake-workspace-id',
163-
instanceId: 'fake-instance-id',
164-
}))();
165-
}
166159
return this._gitpodWsInfo = (async () => {
167160
const infoResponse = await fetch(window.location.protocol + '//' + window.location.host + '/_supervisor/v1/info/workspace', {
168161
credentials: 'include'
@@ -172,7 +165,7 @@ export class GitpodInsightsAppender implements ITelemetryAppender {
172165
}
173166
const info: SupervisorWorkspaceInfo = await infoResponse.json();
174167
return {
175-
gitpodHost: new URL(info.gitpodHost).host,
168+
gitpodHost: this.devMode ? this.productService.gitpodPreview?.host ?? 'gitpod-staging.com' : new URL(info.gitpodHost).host,
176169
instanceId: info.instanceId,
177170
workspaceId: info.workspaceId
178171
};

src/vs/gitpod/node/gitpodInsightsAppender.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class SupervisorConnection {
4646
}
4747

4848
type GitpodConnection = Omit<GitpodServiceImpl<GitpodClient, GitpodServer>, 'server'> & {
49-
server: Pick<GitpodServer, 'trackEvent'>;
49+
server: Pick<GitpodServer, 'trackEvent' | 'getLoggedInUser'>;
5050
};
5151

5252
export class GitpodInsightsAppender implements ITelemetryAppender {
@@ -56,6 +56,7 @@ export class GitpodInsightsAppender implements ITelemetryAppender {
5656
private _baseProperties: { appName: string; uiKind: 'web'; version: string };
5757
private readonly supervisor = new SupervisorConnection();
5858
private readonly devMode = this.productName.endsWith(' Dev');
59+
private gitpodUserId: string | undefined;
5960

6061
constructor(private productName: string, private productVersion: string, private readonly gitpodPreview?: IGitpodPreviewConfiguration) {
6162
this._asyncAIClient = null;
@@ -64,9 +65,12 @@ export class GitpodInsightsAppender implements ITelemetryAppender {
6465
uiKind: 'web',
6566
version: productVersion,
6667
};
68+
this._withAIClient(async (client) => {
69+
this.gitpodUserId = (await client.getLoggedInUser()).id;
70+
});
6771
}
6872

69-
private _withAIClient(callback: (aiClient: Pick<GitpodServer, 'trackEvent'>) => void): void {
73+
private _withAIClient(callback: (aiClient: Pick<GitpodServer, 'trackEvent' | 'getLoggedInUser'>) => void): void {
7074
if (!this._asyncAIClient) {
7175
this._asyncAIClient = this.getSupervisorData().then(
7276
(supervisorData) => {
@@ -151,8 +155,11 @@ export class GitpodInsightsAppender implements ITelemetryAppender {
151155
req.setWorkspaceId(this._defaultData['workspaceId']);
152156
req.setInstanceId(this._defaultData['instanceId']);
153157
req.setErrorStack(error.callstack);
154-
req.setComponent('vscode-workbench');
155-
req.setVersion(this.productName + '-' + this.productVersion); // Align to https://github.com/gitpod-io/gitpod/blob/fe26d2613df2f85667829c9de86bbeb187dc81cf/components/ide/code/leeway.Dockerfile#L75
158+
if (this.gitpodUserId) {
159+
req.setUserId(this.gitpodUserId);
160+
}
161+
req.setComponent('vscode-server');
162+
req.setVersion(this.productVersion);
156163
req.getPropertiesMap().set('error_name', error.uncaught_error_name || '');
157164
req.getPropertiesMap().set('error_message', error.msg || '');
158165
req.getPropertiesMap().set('appName', this._baseProperties.appName);
@@ -241,6 +248,7 @@ export class GitpodInsightsAppender implements ITelemetryAppender {
241248
getTokenRequest.setKind('gitpod');
242249
getTokenRequest.setHost(gitpodApiHost);
243250
getTokenRequest.addScope('function:trackEvent');
251+
getTokenRequest.addScope('function:getLoggedInUser');
244252

245253

246254
const supervisor = this.supervisor;

0 commit comments

Comments
 (0)