@@ -10,14 +10,13 @@ import { IWorkbenchContributionsRegistry, IWorkbenchContribution, Extensions as
1010import { Registry } from 'vs/platform/registry/common/platform' ;
1111import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry' ;
1212import { 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' ;
1614import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle' ;
1715import { Severity , INotificationService } from 'vs/platform/notification/common/notification' ;
1816import { ITextFileService , StateChange } from 'vs/workbench/services/textfile/common/textfiles' ;
1917import { IOpenerService } from 'vs/platform/opener/common/opener' ;
2018import { URI } from 'vs/base/common/uri' ;
19+ import { platform } from 'vs/base/common/process' ;
2120
2221class 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}
0 commit comments