Skip to content

Commit

Permalink
add telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 committed Feb 19, 2020
1 parent 1311b22 commit a03f3d5
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import { IUserDataSyncEnablementService, ResourceKey, ALL_RESOURCE_KEYS } from '
import { Disposable } from 'vs/base/common/lifecycle';
import { Emitter, Event } from 'vs/base/common/event';
import { IStorageService, IWorkspaceStorageChangeEvent, StorageScope } from 'vs/platform/storage/common/storage';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';

type SyncEnablementClassification = {
enabled?: { classification: 'SystemMetaData', purpose: 'FeatureInsight', isMeasurement: true };
};

const enablementKey = 'sync.enable';
function getEnablementKey(resourceKey: ResourceKey) { return `${enablementKey}.${resourceKey}`; }
Expand All @@ -22,7 +27,8 @@ export class UserDataSyncEnablementService extends Disposable implements IUserDa
readonly onDidChangeResourceEnablement: Event<[ResourceKey, boolean]> = this._onDidChangeResourceEnablement.event;

constructor(
@IStorageService private readonly storageService: IStorageService
@IStorageService private readonly storageService: IStorageService,
@ITelemetryService private readonly telemetryService: ITelemetryService,
) {
super();
this._register(storageService.onDidChangeStorage(e => this.onDidStorageChange(e)));
Expand All @@ -34,6 +40,7 @@ export class UserDataSyncEnablementService extends Disposable implements IUserDa

setEnablement(enabled: boolean): void {
if (this.isEnabled() !== enabled) {
this.telemetryService.publicLog2<{ enabled: boolean }, SyncEnablementClassification>(enablementKey, { enabled });
this.storageService.store(enablementKey, enabled, StorageScope.GLOBAL);
}
}
Expand All @@ -44,7 +51,9 @@ export class UserDataSyncEnablementService extends Disposable implements IUserDa

setResourceEnablement(resourceKey: ResourceKey, enabled: boolean): void {
if (this.isResourceEnabled(resourceKey) !== enabled) {
this.storageService.store(getEnablementKey(resourceKey), enabled, StorageScope.GLOBAL);
const resourceEnablementKey = getEnablementKey(resourceKey);
this.telemetryService.publicLog2<{ enabled: boolean }, SyncEnablementClassification>(resourceEnablementKey, { enabled });
this.storageService.store(resourceEnablementKey, enabled, StorageScope.GLOBAL);
}
}

Expand Down

0 comments on commit a03f3d5

Please sign in to comment.