@@ -9,10 +9,12 @@ export class PlatformEnvironmentRequirements implements IPlatformEnvironmentRequ
99 private $logger : ILogger ,
1010 private $nativeScriptCloudExtensionService : INativeScriptCloudExtensionService ,
1111 private $prompter : IPrompter ,
12- private $staticConfig : IStaticConfig ) { }
12+ private $staticConfig : IStaticConfig ,
13+ private $analyticsService : IAnalyticsService ) { }
1314
1415 public static CLOUD_SETUP_OPTION_NAME = "Configure for Cloud Builds" ;
1516 public static LOCAL_SETUP_OPTION_NAME = "Configure for Local Builds" ;
17+ public static TRY_CLOUD_OPERATION_OPTION_NAME = "Try Cloud Operation" ;
1618 public static MANUALLY_SETUP_OPTION_NAME = "Skip Step and Configure Manually" ;
1719 private static BOTH_CLOUD_SETUP_AND_LOCAL_SETUP_OPTION_NAME = "Configure for Both Local and Cloud Builds" ;
1820 private static CHOOSE_OPTIONS_MESSAGE = "To continue, choose one of the following options: " ;
@@ -27,14 +29,24 @@ export class PlatformEnvironmentRequirements implements IPlatformEnvironmentRequ
2729 "deploy" : "tns cloud deploy"
2830 } ;
2931
30- public async checkEnvironmentRequirements ( platform : string ) : Promise < boolean > {
32+ public async checkEnvironmentRequirements ( platform : string , projectDir : string ) : Promise < boolean > {
3133 if ( process . env . NS_SKIP_ENV_CHECK ) {
34+ await this . $analyticsService . trackEventActionInGoogleAnalytics ( {
35+ action : "Check Environment Requirements" ,
36+ additionalData : "Skipped:NS_SKIP_ENV_CHECK is set" ,
37+ projectDir
38+ } ) ;
3239 return true ;
3340 }
3441
3542 const canExecute = await this . $doctorService . canExecuteLocalBuild ( platform ) ;
3643 if ( ! canExecute ) {
3744 if ( ! isInteractive ( ) ) {
45+ await this . $analyticsService . trackEventActionInGoogleAnalytics ( {
46+ action : "Check Environment Requirements" ,
47+ additionalData : "Non-interactive terminal, unable to execute local builds." ,
48+ projectDir
49+ } ) ;
3850 this . fail ( this . getNonInteractiveConsoleMessage ( platform ) ) ;
3951 }
4052
@@ -74,6 +86,11 @@ export class PlatformEnvironmentRequirements implements IPlatformEnvironmentRequ
7486
7587 this . processManuallySetup ( platform ) ;
7688 }
89+
90+ if ( selectedOption === PlatformEnvironmentRequirements . TRY_CLOUD_OPERATION_OPTION_NAME ) {
91+ const message = `You can use ${ _ . lowerFirst ( this . getCloudBuildsMessage ( platform ) ) } ` ;
92+ this . fail ( message ) ;
93+ }
7794 }
7895
7996 return true ;
@@ -166,18 +183,25 @@ export class PlatformEnvironmentRequirements implements IPlatformEnvironmentRequ
166183 ] ) ;
167184 }
168185
169- private promptForChoice ( ) : Promise < string > {
186+ private async promptForChoice ( ) : Promise < string > {
170187 const choices = this . $nativeScriptCloudExtensionService . isInstalled ( ) ? [
188+ PlatformEnvironmentRequirements . TRY_CLOUD_OPERATION_OPTION_NAME ,
171189 PlatformEnvironmentRequirements . LOCAL_SETUP_OPTION_NAME ,
172190 PlatformEnvironmentRequirements . MANUALLY_SETUP_OPTION_NAME ,
173191 ] : [
174- PlatformEnvironmentRequirements . CLOUD_SETUP_OPTION_NAME ,
175- PlatformEnvironmentRequirements . LOCAL_SETUP_OPTION_NAME ,
176- PlatformEnvironmentRequirements . BOTH_CLOUD_SETUP_AND_LOCAL_SETUP_OPTION_NAME ,
177- PlatformEnvironmentRequirements . MANUALLY_SETUP_OPTION_NAME ,
178- ] ;
179-
180- return this . $prompter . promptForChoice ( PlatformEnvironmentRequirements . CHOOSE_OPTIONS_MESSAGE , choices ) ;
192+ PlatformEnvironmentRequirements . CLOUD_SETUP_OPTION_NAME ,
193+ PlatformEnvironmentRequirements . LOCAL_SETUP_OPTION_NAME ,
194+ PlatformEnvironmentRequirements . BOTH_CLOUD_SETUP_AND_LOCAL_SETUP_OPTION_NAME ,
195+ PlatformEnvironmentRequirements . MANUALLY_SETUP_OPTION_NAME ,
196+ ] ;
197+
198+ const selection = await this . $prompter . promptForChoice ( PlatformEnvironmentRequirements . CHOOSE_OPTIONS_MESSAGE , choices ) ;
199+ await this . $analyticsService . trackEventActionInGoogleAnalytics ( {
200+ action : "Check Environment Requirements" ,
201+ additionalData : `User selected: ${ selection } `
202+ // consider passing projectDir here
203+ } ) ;
204+ return selection ;
181205 }
182206
183207 private getEnvVerificationMessage ( ) {
0 commit comments