Skip to content

Commit 337fd85

Browse files
authored
report profiles telemetry (microsoft#167257)
1 parent 46685b5 commit 337fd85

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

src/vs/workbench/contrib/userDataProfile/browser/userDataProfile.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ import { IFileService } from 'vs/platform/files/common/files';
3030
import { asJson, asText, IRequestService } from 'vs/platform/request/common/request';
3131
import { CancellationToken } from 'vs/base/common/cancellation';
3232
import { URI } from 'vs/base/common/uri';
33+
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
34+
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
35+
import { IWorkspaceTagsService } from 'vs/workbench/contrib/tags/common/workspaceTags';
3336

3437
export class UserDataProfilesWorkbenchContribution extends Disposable implements IWorkbenchContribution {
3538

@@ -42,8 +45,11 @@ export class UserDataProfilesWorkbenchContribution extends Disposable implements
4245
@IUserDataProfilesService private readonly userDataProfilesService: IUserDataProfilesService,
4346
@IUserDataProfileManagementService private readonly userDataProfileManagementService: IUserDataProfileManagementService,
4447
@IProductService private readonly productService: IProductService,
48+
@ITelemetryService private readonly telemetryService: ITelemetryService,
49+
@IWorkspaceContextService private readonly workspaceContextService: IWorkspaceContextService,
50+
@IWorkspaceTagsService private readonly workspaceTagsService: IWorkspaceTagsService,
4551
@IContextKeyService contextKeyService: IContextKeyService,
46-
@ILifecycleService lifecycleService: ILifecycleService,
52+
@ILifecycleService private readonly lifecycleService: ILifecycleService,
4753
) {
4854
super();
4955

@@ -69,6 +75,8 @@ export class UserDataProfilesWorkbenchContribution extends Disposable implements
6975
if (isWeb) {
7076
lifecycleService.when(LifecyclePhase.Eventually).then(() => userDataProfilesService.cleanUp());
7177
}
78+
79+
this.reportWorkspaceProfileInfo();
7280
}
7381

7482
private registerConfiguration(): void {
@@ -422,4 +430,23 @@ export class UserDataProfilesWorkbenchContribution extends Disposable implements
422430
}));
423431
return disposables;
424432
}
433+
434+
private async reportWorkspaceProfileInfo(): Promise<void> {
435+
await this.lifecycleService.when(LifecyclePhase.Eventually);
436+
const workspaceId = await this.workspaceTagsService.getTelemetryWorkspaceId(this.workspaceContextService.getWorkspace(), this.workspaceContextService.getWorkbenchState());
437+
type WorkspaceProfileInfoClassification = {
438+
owner: 'sandy081';
439+
comment: 'Report profile information of the current workspace';
440+
workspaceId: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'A UUID given to a workspace to identify it.' };
441+
defaultProfile: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'Whether the profile of the workspace is default or not.' };
442+
};
443+
type WorkspaceProfileInfoEvent = {
444+
workspaceId: string | undefined;
445+
defaultProfile: boolean;
446+
};
447+
this.telemetryService.publicLog2<WorkspaceProfileInfoEvent, WorkspaceProfileInfoClassification>('workspaceProfileInfo', {
448+
workspaceId,
449+
defaultProfile: this.userDataProfileService.currentProfile.isDefault
450+
});
451+
}
425452
}

src/vs/workbench/services/userDataProfile/browser/userDataProfileManagement.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,24 @@ import { Disposable } from 'vs/base/common/lifecycle';
77
import { localize } from 'vs/nls';
88
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
99
import { InstantiationType, registerSingleton } from 'vs/platform/instantiation/common/extensions';
10+
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
1011
import { DidChangeProfilesEvent, IUserDataProfile, IUserDataProfileOptions, IUserDataProfilesService, IUserDataProfileUpdateOptions, WorkspaceIdentifier } from 'vs/platform/userDataProfile/common/userDataProfile';
1112
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
1213
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
1314
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
1415
import { IHostService } from 'vs/workbench/services/host/browser/host';
1516
import { DidChangeUserDataProfileEvent, IUserDataProfileManagementService, IUserDataProfileService } from 'vs/workbench/services/userDataProfile/common/userDataProfile';
1617

18+
export type ProfileManagementActionExecutedClassification = {
19+
owner: 'sandy081';
20+
comment: 'Logged when profile management action is excuted';
21+
id: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The identifier of the action that was run.' };
22+
};
23+
24+
export type ProfileManagementActionExecutedEvent = {
25+
id: string;
26+
};
27+
1728
export class UserDataProfileManagementService extends Disposable implements IUserDataProfileManagementService {
1829
readonly _serviceBrand: undefined;
1930

@@ -25,6 +36,7 @@ export class UserDataProfileManagementService extends Disposable implements IUse
2536
@IWorkspaceContextService private readonly workspaceContextService: IWorkspaceContextService,
2637
@IExtensionService private readonly extensionService: IExtensionService,
2738
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
39+
@ITelemetryService private readonly telemetryService: ITelemetryService,
2840
) {
2941
super();
3042
this._register(userDataProfilesService.onDidChangeProfiles(e => this.onDidChangeProfiles(e)));
@@ -55,12 +67,14 @@ export class UserDataProfileManagementService extends Disposable implements IUse
5567
async createAndEnterProfile(name: string, options?: IUserDataProfileOptions, fromExisting?: boolean): Promise<IUserDataProfile> {
5668
const profile = await this.userDataProfilesService.createNamedProfile(name, options, this.getWorkspaceIdentifier());
5769
await this.enterProfile(profile, !!fromExisting);
70+
this.telemetryService.publicLog2<ProfileManagementActionExecutedEvent, ProfileManagementActionExecutedClassification>('profileManagementActionExecuted', { id: 'createAndEnterProfile' });
5871
return profile;
5972
}
6073

6174
async createAndEnterTransientProfile(): Promise<IUserDataProfile> {
6275
const profile = await this.userDataProfilesService.createTransientProfile(this.getWorkspaceIdentifier());
6376
await this.enterProfile(profile, false);
77+
this.telemetryService.publicLog2<ProfileManagementActionExecutedEvent, ProfileManagementActionExecutedClassification>('profileManagementActionExecuted', { id: 'createAndEnterTransientProfile' });
6478
return profile;
6579
}
6680

@@ -72,6 +86,7 @@ export class UserDataProfileManagementService extends Disposable implements IUse
7286
throw new Error(localize('cannotRenameDefaultProfile', "Cannot rename the default profile"));
7387
}
7488
await this.userDataProfilesService.updateProfile(profile, updateOptions);
89+
this.telemetryService.publicLog2<ProfileManagementActionExecutedEvent, ProfileManagementActionExecutedClassification>('profileManagementActionExecuted', { id: 'updateProfile' });
7590
}
7691

7792
async removeProfile(profile: IUserDataProfile): Promise<void> {
@@ -82,6 +97,7 @@ export class UserDataProfileManagementService extends Disposable implements IUse
8297
throw new Error(localize('cannotDeleteDefaultProfile', "Cannot delete the default profile"));
8398
}
8499
await this.userDataProfilesService.removeProfile(profile);
100+
this.telemetryService.publicLog2<ProfileManagementActionExecutedEvent, ProfileManagementActionExecutedClassification>('profileManagementActionExecuted', { id: 'removeProfile' });
85101
}
86102

87103
async switchProfile(profile: IUserDataProfile): Promise<void> {
@@ -94,6 +110,7 @@ export class UserDataProfileManagementService extends Disposable implements IUse
94110
}
95111
await this.userDataProfilesService.setProfileForWorkspace(workspaceIdentifier, profile);
96112
await this.enterProfile(profile, false);
113+
this.telemetryService.publicLog2<ProfileManagementActionExecutedEvent, ProfileManagementActionExecutedClassification>('profileManagementActionExecuted', { id: 'switchProfile' });
97114
}
98115

99116
private getWorkspaceIdentifier(): WorkspaceIdentifier {

0 commit comments

Comments
 (0)