11import * as os from 'os' ;
2+ import * as vscode from 'vscode' ;
23import { Version } from '../../common/Version' ;
34import { GUAService } from './GUAService' ;
5+ import { TelerikAnalyticsService } from './TelerikAnalyticsService' ;
46import { AnalyticsBaseInfo , OperatingSystem } from './AnalyticsBaseInfo' ;
57import { ExtensionVersionInfo } from '../ExtensionVersionInfo' ;
68import * as ns from '../NsCliService' ;
@@ -10,6 +12,8 @@ export class AnalyticsService {
1012
1113 private _baseInfo : AnalyticsBaseInfo ;
1214 private _gua : GUAService ;
15+ private _ta : TelerikAnalyticsService ;
16+ private _analyticsEnabled : boolean ;
1317
1418 public static getInstance ( ) : AnalyticsService {
1519 if ( ! this . _instance ) {
@@ -34,6 +38,7 @@ export class AnalyticsService {
3438 }
3539
3640 constructor ( ) {
41+ this . _analyticsEnabled = vscode . workspace . getConfiguration ( 'nativescript' ) . get ( 'analytics.enabled' ) as boolean ;
3742 let operatingSystem = OperatingSystem . Other ;
3843 switch ( process . platform ) {
3944 case 'win32' : { operatingSystem = OperatingSystem . Windows ; break ; }
@@ -46,22 +51,36 @@ export class AnalyticsService {
4651 cliVersion : Version . stringify ( ns . CliVersionInfo . getInstalledCliVersion ( ) ) ,
4752 extensionVersion : Version . stringify ( ExtensionVersionInfo . getExtensionVersion ( ) ) ,
4853 operatingSystem : operatingSystem ,
49- userId : AnalyticsService . generateMachineId ( ) ,
50- hostname : 'ns-vs-extension.org'
54+ userId : AnalyticsService . generateMachineId ( )
5155 } ;
5256
53- this . _gua = new GUAService ( 'UA-111455-29' , this . _baseInfo ) ;
57+ if ( this . _analyticsEnabled ) {
58+ this . _gua = new GUAService ( 'UA-111455-29' , this . _baseInfo ) ;
59+ this . _ta = new TelerikAnalyticsService ( 'b8b2e51f188f43e9b0dfb899f7b71cc6' , this . _baseInfo ) ;
60+ }
5461 }
5562
5663 public launchDebugger ( request : string , platform : string , emulator : boolean ) : Promise < any > {
57- try {
58- return this . _gua . launchDebugger ( request , platform , emulator ) ;
59- } catch ( e ) { }
64+ if ( this . _analyticsEnabled ) {
65+ try {
66+ return Promise . all ( [
67+ this . _gua . launchDebugger ( request , platform , emulator ) ,
68+ this . _ta . launchDebugger ( request , platform , emulator )
69+ ] ) ;
70+ } catch ( e ) { }
71+ }
72+ return Promise . resolve ( ) ;
6073 }
6174
6275 public runRunCommand ( platform : string , emulator : boolean ) : Promise < any > {
63- try {
64- return this . _gua . runRunCommand ( platform , emulator ) ;
65- } catch ( e ) { }
76+ if ( this . _analyticsEnabled ) {
77+ try {
78+ return Promise . all ( [
79+ this . _gua . runRunCommand ( platform , emulator ) ,
80+ this . _ta . runRunCommand ( platform , emulator )
81+ ] ) ;
82+ } catch ( e ) { }
83+ }
84+ return Promise . resolve ( ) ;
6685 }
6786}
0 commit comments