Skip to content

Commit 1d072c6

Browse files
author
Benjamin Pasero
committed
web - move surveys to browser
1 parent e81ee53 commit 1d072c6

4 files changed

Lines changed: 34 additions & 24 deletions

File tree

src/vs/workbench/contrib/surveys/electron-browser/languageSurveys.contribution.ts renamed to src/vs/workbench/contrib/surveys/browser/languageSurveys.contribution.ts

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@ 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 pkg from 'vs/platform/product/node/package';
14-
import product from 'vs/platform/product/node/product';
15-
import { ISurveyData } from 'vs/platform/product/common/product';
13+
import { ISurveyData, IProductService } from 'vs/platform/product/common/product';
1614
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
1715
import { Severity, INotificationService } from 'vs/platform/notification/common/notification';
1816
import { ITextFileService, StateChange } from 'vs/workbench/services/textfile/common/textfiles';
1917
import { IOpenerService } from 'vs/platform/opener/common/opener';
2018
import { URI } from 'vs/base/common/uri';
19+
import { platform } from 'vs/base/common/process';
2120

2221
class LanguageSurvey {
2322

@@ -28,7 +27,8 @@ class LanguageSurvey {
2827
telemetryService: ITelemetryService,
2928
modelService: IModelService,
3029
textFileService: ITextFileService,
31-
openerService: IOpenerService
30+
openerService: IOpenerService,
31+
productService: IProductService
3232
) {
3333
const SESSION_COUNT_KEY = `${data.surveyId}.sessionCount`;
3434
const LAST_SESSION_DATE_KEY = `${data.surveyId}.lastSessionDate`;
@@ -82,7 +82,7 @@ class LanguageSurvey {
8282
storageService.store(IS_CANDIDATE_KEY, isCandidate, StorageScope.GLOBAL);
8383

8484
if (!isCandidate) {
85-
storageService.store(SKIP_VERSION_KEY, pkg.version, StorageScope.GLOBAL);
85+
storageService.store(SKIP_VERSION_KEY, productService.version, StorageScope.GLOBAL);
8686
return;
8787
}
8888

@@ -97,9 +97,9 @@ class LanguageSurvey {
9797
run: () => {
9898
telemetryService.publicLog(`${data.surveyId}.survey/takeShortSurvey`);
9999
telemetryService.getTelemetryInfo().then(info => {
100-
openerService.open(URI.parse(`${data.surveyUrl}?o=${encodeURIComponent(process.platform)}&v=${encodeURIComponent(pkg.version)}&m=${encodeURIComponent(info.machineId)}`));
100+
openerService.open(URI.parse(`${data.surveyUrl}?o=${encodeURIComponent(platform)}&v=${encodeURIComponent(productService.version)}&m=${encodeURIComponent(info.machineId)}`));
101101
storageService.store(IS_CANDIDATE_KEY, false, StorageScope.GLOBAL);
102-
storageService.store(SKIP_VERSION_KEY, pkg.version, StorageScope.GLOBAL);
102+
storageService.store(SKIP_VERSION_KEY, productService.version, StorageScope.GLOBAL);
103103
});
104104
}
105105
}, {
@@ -114,7 +114,7 @@ class LanguageSurvey {
114114
run: () => {
115115
telemetryService.publicLog(`${data.surveyId}.survey/dontShowAgain`);
116116
storageService.store(IS_CANDIDATE_KEY, false, StorageScope.GLOBAL);
117-
storageService.store(SKIP_VERSION_KEY, pkg.version, StorageScope.GLOBAL);
117+
storageService.store(SKIP_VERSION_KEY, productService.version, StorageScope.GLOBAL);
118118
}
119119
}],
120120
{ sticky: true }
@@ -130,15 +130,20 @@ class LanguageSurveysContribution implements IWorkbenchContribution {
130130
@ITelemetryService telemetryService: ITelemetryService,
131131
@IModelService modelService: IModelService,
132132
@ITextFileService textFileService: ITextFileService,
133-
@IOpenerService openerService: IOpenerService
133+
@IOpenerService openerService: IOpenerService,
134+
@IProductService productService: IProductService
134135
) {
135-
product.surveys!
136+
if (!productService.surveys) {
137+
return;
138+
}
139+
140+
productService.surveys
136141
.filter(surveyData => surveyData.surveyId && surveyData.editCount && surveyData.languageId && surveyData.surveyUrl && surveyData.userProbability)
137-
.map(surveyData => new LanguageSurvey(surveyData, storageService, notificationService, telemetryService, modelService, textFileService, openerService));
142+
.map(surveyData => new LanguageSurvey(surveyData, storageService, notificationService, telemetryService, modelService, textFileService, openerService, productService));
138143
}
139144
}
140145

141-
if (language === 'en' && product.surveys && product.surveys.length) {
146+
if (language === 'en') {
142147
const workbenchRegistry = Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench);
143148
workbenchRegistry.registerWorkbenchContribution(LanguageSurveysContribution, LifecyclePhase.Restored);
144149
}

src/vs/workbench/contrib/surveys/electron-browser/nps.contribution.ts renamed to src/vs/workbench/contrib/surveys/browser/nps.contribution.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ 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 pkg from 'vs/platform/product/node/package';
13-
import product from 'vs/platform/product/node/product';
12+
import { IProductService } from 'vs/platform/product/common/product';
1413
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
1514
import { Severity, INotificationService } from 'vs/platform/notification/common/notification';
1615
import { IOpenerService } from 'vs/platform/opener/common/opener';
1716
import { URI } from 'vs/base/common/uri';
17+
import { platform } from 'vs/base/common/process';
1818

1919
const PROBABILITY = 0.15;
2020
const SESSION_COUNT_KEY = 'nps/sessionCount';
@@ -28,8 +28,13 @@ class NPSContribution implements IWorkbenchContribution {
2828
@IStorageService storageService: IStorageService,
2929
@INotificationService notificationService: INotificationService,
3030
@ITelemetryService telemetryService: ITelemetryService,
31-
@IOpenerService openerService: IOpenerService
31+
@IOpenerService openerService: IOpenerService,
32+
@IProductService productService: IProductService
3233
) {
34+
if (!productService.npsSurveyUrl) {
35+
return;
36+
}
37+
3338
const skipVersion = storageService.get(SKIP_VERSION_KEY, StorageScope.GLOBAL, '');
3439
if (skipVersion) {
3540
return;
@@ -56,7 +61,7 @@ class NPSContribution implements IWorkbenchContribution {
5661
storageService.store(IS_CANDIDATE_KEY, isCandidate, StorageScope.GLOBAL);
5762

5863
if (!isCandidate) {
59-
storageService.store(SKIP_VERSION_KEY, pkg.version, StorageScope.GLOBAL);
64+
storageService.store(SKIP_VERSION_KEY, productService.version, StorageScope.GLOBAL);
6065
return;
6166
}
6267

@@ -67,9 +72,9 @@ class NPSContribution implements IWorkbenchContribution {
6772
label: nls.localize('takeSurvey', "Take Survey"),
6873
run: () => {
6974
telemetryService.getTelemetryInfo().then(info => {
70-
openerService.open(URI.parse(`${product.npsSurveyUrl}?o=${encodeURIComponent(process.platform)}&v=${encodeURIComponent(pkg.version)}&m=${encodeURIComponent(info.machineId)}`));
75+
openerService.open(URI.parse(`${productService.npsSurveyUrl}?o=${encodeURIComponent(platform)}&v=${encodeURIComponent(productService.version)}&m=${encodeURIComponent(info.machineId)}`));
7176
storageService.store(IS_CANDIDATE_KEY, false, StorageScope.GLOBAL);
72-
storageService.store(SKIP_VERSION_KEY, pkg.version, StorageScope.GLOBAL);
77+
storageService.store(SKIP_VERSION_KEY, productService.version, StorageScope.GLOBAL);
7378
});
7479
}
7580
}, {
@@ -79,15 +84,15 @@ class NPSContribution implements IWorkbenchContribution {
7984
label: nls.localize('neverAgain', "Don't Show Again"),
8085
run: () => {
8186
storageService.store(IS_CANDIDATE_KEY, false, StorageScope.GLOBAL);
82-
storageService.store(SKIP_VERSION_KEY, pkg.version, StorageScope.GLOBAL);
87+
storageService.store(SKIP_VERSION_KEY, productService.version, StorageScope.GLOBAL);
8388
}
8489
}],
8590
{ sticky: true }
8691
);
8792
}
8893
}
8994

90-
if (language === 'en' && product.npsSurveyUrl) {
95+
if (language === 'en') {
9196
const workbenchRegistry = Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench);
9297
workbenchRegistry.registerWorkbenchContribution(NPSContribution, LifecyclePhase.Restored);
9398
}

src/vs/workbench/workbench.common.main.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,10 @@ import 'vs/workbench/contrib/update/browser/update.contribution';
229229
// Watermark
230230
import 'vs/workbench/contrib/watermark/browser/watermark';
231231

232+
// Surveys
233+
import 'vs/workbench/contrib/surveys/browser/nps.contribution';
234+
import 'vs/workbench/contrib/surveys/browser/languageSurveys.contribution';
235+
232236
// Welcome
233237
import 'vs/workbench/contrib/welcome/overlay/browser/welcomeOverlay';
234238
import 'vs/workbench/contrib/welcome/page/browser/welcomePage.contribution';

src/vs/workbench/workbench.desktop.main.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,6 @@ import 'vs/workbench/contrib/externalTerminal/node/externalTerminalService';
121121
// Update
122122
import 'vs/workbench/contrib/update/electron-browser/update.contribution';
123123

124-
// Surveys
125-
import 'vs/workbench/contrib/surveys/electron-browser/nps.contribution';
126-
import 'vs/workbench/contrib/surveys/electron-browser/languageSurveys.contribution';
127-
128124
// Performance
129125
import 'vs/workbench/contrib/performance/electron-browser/performance.contribution';
130126

0 commit comments

Comments
 (0)