@@ -12,6 +12,7 @@ let clui = require("clui");
1212const buildInfoFileName = ".nsbuildinfo" ;
1313
1414export class PlatformService implements IPlatformService {
15+ private _trackedProjectFilePath : string = null ;
1516
1617 constructor ( private $devicesService : Mobile . IDevicesService ,
1718 private $errors : IErrors ,
@@ -38,7 +39,8 @@ export class PlatformService implements IPlatformService {
3839 private $deviceAppDataFactory : Mobile . IDeviceAppDataFactory ,
3940 private $projectChangesService : IProjectChangesService ,
4041 private $emulatorPlatformService : IEmulatorPlatformService ,
41- private $childProcess : IChildProcess ) { }
42+ private $childProcess : IChildProcess ,
43+ private $analyticsService : IAnalyticsService ) { }
4244
4345 public addPlatforms ( platforms : string [ ] ) : IFuture < void > {
4446 return ( ( ) => {
@@ -196,6 +198,8 @@ export class PlatformService implements IPlatformService {
196198 return ( ( ) => {
197199 this . validatePlatform ( platform ) ;
198200
201+ this . trackProjectType ( ) . wait ( ) ;
202+
199203 //We need dev-dependencies here, so before-prepare hooks will be executed correctly.
200204 try {
201205 this . $pluginsService . ensureAllDependenciesAreInstalled ( ) . wait ( ) ;
@@ -348,7 +352,7 @@ export class PlatformService implements IPlatformService {
348352 }
349353 let platformData = this . $platformsData . getPlatformData ( platform ) ;
350354 let forDevice = ! buildConfig || buildConfig . buildForDevice ;
351- let outputPath = forDevice ? platformData . deviceBuildOutputPath : platformData . emulatorBuildOutputPath ;
355+ let outputPath = forDevice ? platformData . deviceBuildOutputPath : platformData . emulatorBuildOutputPath ;
352356 if ( ! this . $fs . exists ( outputPath ) ) {
353357 return true ;
354358 }
@@ -372,9 +376,24 @@ export class PlatformService implements IPlatformService {
372376 } ) . future < boolean > ( ) ( ) ;
373377 }
374378
379+ public trackProjectType ( ) : IFuture < void > {
380+ return ( ( ) => {
381+ // Track each project once per process.
382+ // In long living process, where we may work with multiple projects, we would like to track the information for each of them.
383+ if ( this . $projectData && ( this . $projectData . projectFilePath !== this . _trackedProjectFilePath ) ) {
384+ this . _trackedProjectFilePath = this . $projectData . projectFilePath ;
385+
386+ this . $analyticsService . track ( "Working with project type" , this . $projectData . projectType ) . wait ( ) ;
387+ }
388+ } ) . future < void > ( ) ( ) ;
389+ }
390+
375391 public buildPlatform ( platform : string , buildConfig ?: IBuildConfig ) : IFuture < void > {
376392 return ( ( ) => {
377393 this . $logger . out ( "Building project..." ) ;
394+
395+ this . trackProjectType ( ) . wait ( ) ;
396+
378397 let platformData = this . $platformsData . getPlatformData ( platform ) ;
379398 platformData . platformProjectService . buildProject ( platformData . projectRoot , buildConfig ) . wait ( ) ;
380399 let prepareInfo = this . $projectChangesService . getPrepareInfo ( platform ) ;
@@ -449,6 +468,8 @@ export class PlatformService implements IPlatformService {
449468
450469 public runPlatform ( platform : string ) : IFuture < void > {
451470 return ( ( ) => {
471+ this . trackProjectType ( ) . wait ( ) ;
472+
452473 if ( this . $options . justlaunch ) {
453474 this . $options . watch = false ;
454475 }
@@ -484,7 +505,7 @@ export class PlatformService implements IPlatformService {
484505 this . $devicesService . initialize ( { platform : platform , deviceId : this . $options . device } ) . wait ( ) ;
485506 let found : Mobile . IDeviceInfo [ ] = [ ] ;
486507 if ( this . $devicesService . hasDevices ) {
487- found = this . $devicesService . getDevices ( ) . filter ( ( device :Mobile . IDeviceInfo ) => device . identifier === this . $options . device ) ;
508+ found = this . $devicesService . getDevices ( ) . filter ( ( device : Mobile . IDeviceInfo ) => device . identifier === this . $options . device ) ;
488509 }
489510 if ( found . length === 0 ) {
490511 this . $errors . fail ( "Cannot find device with name: %s" , this . $options . device ) ;
@@ -514,7 +535,7 @@ export class PlatformService implements IPlatformService {
514535 let deviceFilePath = this . getDeviceBuildInfoFilePath ( device ) ;
515536 try {
516537 return JSON . parse ( this . readFile ( device , deviceFilePath ) . wait ( ) ) ;
517- } catch ( e ) {
538+ } catch ( e ) {
518539 return null ;
519540 } ;
520541 } ) . future < IBuildInfo > ( ) ( ) ;
@@ -527,7 +548,7 @@ export class PlatformService implements IPlatformService {
527548 try {
528549 let buildInfoTime = this . $fs . readJson ( buildInfoFile ) ;
529550 return buildInfoTime ;
530- } catch ( e ) {
551+ } catch ( e ) {
531552 return null ;
532553 }
533554 }
0 commit comments