Skip to content

Commit 5e2ae87

Browse files
authored
Opt in syncing global state (microsoft#96662)
Fixes microsoft#93332
1 parent 0476956 commit 5e2ae87

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

src/vs/workbench/contrib/surveys/browser/languageSurveys.contribution.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { IWorkbenchContributionsRegistry, IWorkbenchContribution, Extensions as
1010
import { Registry } from 'vs/platform/registry/common/platform';
1111
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
1212
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
13+
import { IStorageKeysSyncRegistryService } from 'vs/platform/userDataSync/common/storageKeys';
1314
import { ISurveyData, IProductService } from 'vs/platform/product/common/productService';
1415
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
1516
import { Severity, INotificationService } from 'vs/platform/notification/common/notification';
@@ -25,6 +26,7 @@ class LanguageSurvey extends Disposable {
2526
constructor(
2627
data: ISurveyData,
2728
storageService: IStorageService,
29+
storageKeysSyncRegistryService: IStorageKeysSyncRegistryService,
2830
notificationService: INotificationService,
2931
telemetryService: ITelemetryService,
3032
modelService: IModelService,
@@ -41,6 +43,14 @@ class LanguageSurvey extends Disposable {
4143
const EDITED_LANGUAGE_COUNT_KEY = `${data.surveyId}.editedCount`;
4244
const EDITED_LANGUAGE_DATE_KEY = `${data.surveyId}.editedDate`;
4345

46+
// opt-in to syncing
47+
storageKeysSyncRegistryService.registerStorageKey({ key: SESSION_COUNT_KEY, version: 1 });
48+
storageKeysSyncRegistryService.registerStorageKey({ key: LAST_SESSION_DATE_KEY, version: 1 });
49+
storageKeysSyncRegistryService.registerStorageKey({ key: SKIP_VERSION_KEY, version: 1 });
50+
storageKeysSyncRegistryService.registerStorageKey({ key: IS_CANDIDATE_KEY, version: 1 });
51+
storageKeysSyncRegistryService.registerStorageKey({ key: EDITED_LANGUAGE_COUNT_KEY, version: 1 });
52+
storageKeysSyncRegistryService.registerStorageKey({ key: EDITED_LANGUAGE_DATE_KEY, version: 1 });
53+
4454
const skipVersion = storageService.get(SKIP_VERSION_KEY, StorageScope.GLOBAL, '');
4555
if (skipVersion) {
4656
return;
@@ -131,6 +141,7 @@ class LanguageSurveysContribution implements IWorkbenchContribution {
131141

132142
constructor(
133143
@IStorageService storageService: IStorageService,
144+
@IStorageKeysSyncRegistryService storageKeysSyncRegistryService: IStorageKeysSyncRegistryService,
134145
@INotificationService notificationService: INotificationService,
135146
@ITelemetryService telemetryService: ITelemetryService,
136147
@IModelService modelService: IModelService,
@@ -144,7 +155,7 @@ class LanguageSurveysContribution implements IWorkbenchContribution {
144155

145156
productService.surveys
146157
.filter(surveyData => surveyData.surveyId && surveyData.editCount && surveyData.languageId && surveyData.surveyUrl && surveyData.userProbability)
147-
.map(surveyData => new LanguageSurvey(surveyData, storageService, notificationService, telemetryService, modelService, textFileService, openerService, productService));
158+
.map(surveyData => new LanguageSurvey(surveyData, storageService, storageKeysSyncRegistryService, notificationService, telemetryService, modelService, textFileService, openerService, productService));
148159
}
149160
}
150161

src/vs/workbench/contrib/surveys/browser/nps.contribution.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { IWorkbenchContributionsRegistry, IWorkbenchContribution, Extensions as
99
import { Registry } from 'vs/platform/registry/common/platform';
1010
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
1111
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
12+
import { IStorageKeysSyncRegistryService } from 'vs/platform/userDataSync/common/storageKeys';
1213
import { IProductService } from 'vs/platform/product/common/productService';
1314
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
1415
import { Severity, INotificationService } from 'vs/platform/notification/common/notification';
@@ -26,6 +27,7 @@ class NPSContribution implements IWorkbenchContribution {
2627

2728
constructor(
2829
@IStorageService storageService: IStorageService,
30+
@IStorageKeysSyncRegistryService storageKeysSyncRegistryService: IStorageKeysSyncRegistryService,
2931
@INotificationService notificationService: INotificationService,
3032
@ITelemetryService telemetryService: ITelemetryService,
3133
@IOpenerService openerService: IOpenerService,
@@ -35,6 +37,12 @@ class NPSContribution implements IWorkbenchContribution {
3537
return;
3638
}
3739

40+
// opt-in to syncing
41+
storageKeysSyncRegistryService.registerStorageKey({ key: SESSION_COUNT_KEY, version: 1 });
42+
storageKeysSyncRegistryService.registerStorageKey({ key: LAST_SESSION_DATE_KEY, version: 1 });
43+
storageKeysSyncRegistryService.registerStorageKey({ key: SKIP_VERSION_KEY, version: 1 });
44+
storageKeysSyncRegistryService.registerStorageKey({ key: IS_CANDIDATE_KEY, version: 1 });
45+
3846
const skipVersion = storageService.get(SKIP_VERSION_KEY, StorageScope.GLOBAL, '');
3947
if (skipVersion) {
4048
return;

0 commit comments

Comments
 (0)