@@ -12,6 +12,7 @@ let clui = require("clui");
12
12
const buildInfoFileName = ".nsbuildinfo" ;
13
13
14
14
export class PlatformService implements IPlatformService {
15
+ private _trackedProjectFilePath : string = null ;
15
16
16
17
constructor ( private $devicesService : Mobile . IDevicesService ,
17
18
private $errors : IErrors ,
@@ -38,7 +39,8 @@ export class PlatformService implements IPlatformService {
38
39
private $deviceAppDataFactory : Mobile . IDeviceAppDataFactory ,
39
40
private $projectChangesService : IProjectChangesService ,
40
41
private $emulatorPlatformService : IEmulatorPlatformService ,
41
- private $childProcess : IChildProcess ) { }
42
+ private $childProcess : IChildProcess ,
43
+ private $analyticsService : IAnalyticsService ) { }
42
44
43
45
public addPlatforms ( platforms : string [ ] ) : IFuture < void > {
44
46
return ( ( ) => {
@@ -196,6 +198,8 @@ export class PlatformService implements IPlatformService {
196
198
return ( ( ) => {
197
199
this . validatePlatform ( platform ) ;
198
200
201
+ this . trackProjectType ( ) . wait ( ) ;
202
+
199
203
//We need dev-dependencies here, so before-prepare hooks will be executed correctly.
200
204
try {
201
205
this . $pluginsService . ensureAllDependenciesAreInstalled ( ) . wait ( ) ;
@@ -348,7 +352,7 @@ export class PlatformService implements IPlatformService {
348
352
}
349
353
let platformData = this . $platformsData . getPlatformData ( platform ) ;
350
354
let forDevice = ! buildConfig || buildConfig . buildForDevice ;
351
- let outputPath = forDevice ? platformData . deviceBuildOutputPath : platformData . emulatorBuildOutputPath ;
355
+ let outputPath = forDevice ? platformData . deviceBuildOutputPath : platformData . emulatorBuildOutputPath ;
352
356
if ( ! this . $fs . exists ( outputPath ) ) {
353
357
return true ;
354
358
}
@@ -372,9 +376,24 @@ export class PlatformService implements IPlatformService {
372
376
} ) . future < boolean > ( ) ( ) ;
373
377
}
374
378
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 ) ;
387
+ }
388
+ } ) . future < void > ( ) ( ) ;
389
+ }
390
+
375
391
public buildPlatform ( platform : string , buildConfig ?: IBuildConfig ) : IFuture < void > {
376
392
return ( ( ) => {
377
393
this . $logger . out ( "Building project..." ) ;
394
+
395
+ this . trackProjectType ( ) . wait ( ) ;
396
+
378
397
let platformData = this . $platformsData . getPlatformData ( platform ) ;
379
398
platformData . platformProjectService . buildProject ( platformData . projectRoot , buildConfig ) . wait ( ) ;
380
399
let prepareInfo = this . $projectChangesService . getPrepareInfo ( platform ) ;
@@ -449,6 +468,8 @@ export class PlatformService implements IPlatformService {
449
468
450
469
public runPlatform ( platform : string ) : IFuture < void > {
451
470
return ( ( ) => {
471
+ this . trackProjectType ( ) . wait ( ) ;
472
+
452
473
if ( this . $options . justlaunch ) {
453
474
this . $options . watch = false ;
454
475
}
@@ -484,7 +505,7 @@ export class PlatformService implements IPlatformService {
484
505
this . $devicesService . initialize ( { platform : platform , deviceId : this . $options . device } ) . wait ( ) ;
485
506
let found : Mobile . IDeviceInfo [ ] = [ ] ;
486
507
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 ) ;
488
509
}
489
510
if ( found . length === 0 ) {
490
511
this . $errors . fail ( "Cannot find device with name: %s" , this . $options . device ) ;
@@ -514,7 +535,7 @@ export class PlatformService implements IPlatformService {
514
535
let deviceFilePath = this . getDeviceBuildInfoFilePath ( device ) ;
515
536
try {
516
537
return JSON . parse ( this . readFile ( device , deviceFilePath ) . wait ( ) ) ;
517
- } catch ( e ) {
538
+ } catch ( e ) {
518
539
return null ;
519
540
} ;
520
541
} ) . future < IBuildInfo > ( ) ( ) ;
@@ -527,7 +548,7 @@ export class PlatformService implements IPlatformService {
527
548
try {
528
549
let buildInfoTime = this . $fs . readJson ( buildInfoFile ) ;
529
550
return buildInfoTime ;
530
- } catch ( e ) {
551
+ } catch ( e ) {
531
552
return null ;
532
553
}
533
554
}
0 commit comments