Skip to content

Commit e07a642

Browse files
authored
Add telemetry for account entitlement (microsoft#196772)
* Add telemetry for account entitlements * Fix badge display
1 parent e612d4d commit e07a642

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

src/vs/workbench/contrib/accountEntitlements/browser/accountsEntitlements.contribution.ts

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@ import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
2929

3030
const configurationKey = 'workbench.accounts.experimental.showEntitlements';
3131

32+
type EntitlementEnablementClassification = {
33+
enabled: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; isMeasurement: true; comment: 'Flag indicating if the account entitlement is enabled' };
34+
owner: 'bhavyaus';
35+
comment: 'Reporting when the account entitlement is shown';
36+
};
37+
38+
type EntitlementActionClassification = {
39+
command: { classification: 'PublicNonPersonalData'; purpose: 'FeatureInsight'; comment: 'The command being executed by the entitlement action' };
40+
owner: 'bhavyaus';
41+
comment: 'Reporting the account entitlement action';
42+
};
43+
3244
class AccountsEntitlement extends Disposable implements IWorkbenchContribution {
3345
private isInitialized = false;
3446
private contextKey = new RawContextKey<boolean>(configurationKey, true).bindTo(this.contextService);
@@ -136,15 +148,17 @@ class AccountsEntitlement extends Disposable implements IWorkbenchContribution {
136148
return;
137149
}
138150

139-
const accountsMenuBadgeDisposable = this._register(new MutableDisposable());
140-
141151
this.contextKey.set(true);
142-
const badge = new NumberBadge(1, () => menuTitle);
143-
accountsMenuBadgeDisposable.value = this.activityService.showAccountsActivity({ badge, });
152+
this.telemetryService.publicLog2<{ enabled: boolean }, EntitlementEnablementClassification>(configurationKey, { enabled: true });
144153

145154
const orgs = parsedResult['organization_login_list'] as any[];
146155
const menuTitle = orgs ? this.productService.gitHubEntitlement!.command.title.replace('{{org}}', orgs[orgs.length - 1]) : this.productService.gitHubEntitlement!.command.titleWithoutPlaceHolder;
147156

157+
const badge = new NumberBadge(1, () => menuTitle);
158+
const accountsMenuBadgeDisposable = this._register(new MutableDisposable());
159+
accountsMenuBadgeDisposable.value = this.activityService.showAccountsActivity({ badge, });
160+
161+
148162
registerAction2(class extends Action2 {
149163
constructor() {
150164
super({
@@ -167,6 +181,7 @@ class AccountsEntitlement extends Disposable implements IWorkbenchContribution {
167181
const contextKeyService = accessor.get(IContextKeyService);
168182
const storageService = accessor.get(IStorageService);
169183
const dialogService = accessor.get(IDialogService);
184+
const telemetryService = accessor.get(ITelemetryService);
170185

171186
const confirmation = await dialogService.confirm({
172187
type: 'question',
@@ -176,6 +191,13 @@ class AccountsEntitlement extends Disposable implements IWorkbenchContribution {
176191

177192
if (confirmation.confirmed) {
178193
commandService.executeCommand(productService.gitHubEntitlement!.command.action, productService.gitHubEntitlement!.extensionId!);
194+
telemetryService.publicLog2<{ command: string }, EntitlementActionClassification>('accountsEntitlements.action', {
195+
command: productService.gitHubEntitlement!.command.action,
196+
});
197+
} else {
198+
telemetryService.publicLog2<{ command: string }, EntitlementActionClassification>('accountsEntitlements.action', {
199+
command: productService.gitHubEntitlement!.command.action + '-dismissed',
200+
});
179201
}
180202

181203
accountsMenuBadgeDisposable.clear();

0 commit comments

Comments
 (0)