Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add telemetry for account entitlement #196772

Merged
merged 2 commits into from Oct 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -29,6 +29,18 @@ import { IDialogService } from 'vs/platform/dialogs/common/dialogs';

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

type EntitlementEnablementClassification = {
enabled: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; isMeasurement: true; comment: 'Flag indicating if the account entitlement is enabled' };
owner: 'bhavyaus';
comment: 'Reporting when the account entitlement is shown';
};

type EntitlementActionClassification = {
command: { classification: 'PublicNonPersonalData'; purpose: 'FeatureInsight'; comment: 'The command being executed by the entitlement action' };
owner: 'bhavyaus';
comment: 'Reporting the account entitlement action';
};

class AccountsEntitlement extends Disposable implements IWorkbenchContribution {
private isInitialized = false;
private contextKey = new RawContextKey<boolean>(configurationKey, true).bindTo(this.contextService);
Expand Down Expand Up @@ -136,15 +148,17 @@ class AccountsEntitlement extends Disposable implements IWorkbenchContribution {
return;
}

const accountsMenuBadgeDisposable = this._register(new MutableDisposable());

this.contextKey.set(true);
const badge = new NumberBadge(1, () => menuTitle);
accountsMenuBadgeDisposable.value = this.activityService.showAccountsActivity({ badge, });
this.telemetryService.publicLog2<{ enabled: boolean }, EntitlementEnablementClassification>(configurationKey, { enabled: true });

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

const badge = new NumberBadge(1, () => menuTitle);
const accountsMenuBadgeDisposable = this._register(new MutableDisposable());
accountsMenuBadgeDisposable.value = this.activityService.showAccountsActivity({ badge, });


registerAction2(class extends Action2 {
constructor() {
super({
Expand All @@ -167,6 +181,7 @@ class AccountsEntitlement extends Disposable implements IWorkbenchContribution {
const contextKeyService = accessor.get(IContextKeyService);
const storageService = accessor.get(IStorageService);
const dialogService = accessor.get(IDialogService);
const telemetryService = accessor.get(ITelemetryService);

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

if (confirmation.confirmed) {
commandService.executeCommand(productService.gitHubEntitlement!.command.action, productService.gitHubEntitlement!.extensionId!);
telemetryService.publicLog2<{ command: string }, EntitlementActionClassification>('accountsEntitlements.action', {
command: productService.gitHubEntitlement!.command.action,
});
} else {
telemetryService.publicLog2<{ command: string }, EntitlementActionClassification>('accountsEntitlements.action', {
command: productService.gitHubEntitlement!.command.action + '-dismissed',
});
}

accountsMenuBadgeDisposable.clear();
Expand Down