1
1
import * as os from 'os' ;
2
+ import * as vscode from 'vscode' ;
2
3
import { Version } from '../../common/Version' ;
3
4
import { GUAService } from './GUAService' ;
5
+ import { TelerikAnalyticsService } from './TelerikAnalyticsService' ;
4
6
import { AnalyticsBaseInfo , OperatingSystem } from './AnalyticsBaseInfo' ;
5
7
import { ExtensionVersionInfo } from '../ExtensionVersionInfo' ;
6
8
import * as ns from '../NsCliService' ;
@@ -10,6 +12,8 @@ export class AnalyticsService {
10
12
11
13
private _baseInfo : AnalyticsBaseInfo ;
12
14
private _gua : GUAService ;
15
+ private _ta : TelerikAnalyticsService ;
16
+ private _analyticsEnabled : boolean ;
13
17
14
18
public static getInstance ( ) : AnalyticsService {
15
19
if ( ! this . _instance ) {
@@ -34,6 +38,7 @@ export class AnalyticsService {
34
38
}
35
39
36
40
constructor ( ) {
41
+ this . _analyticsEnabled = vscode . workspace . getConfiguration ( 'nativescript' ) . get ( 'analytics.enabled' ) as boolean ;
37
42
let operatingSystem = OperatingSystem . Other ;
38
43
switch ( process . platform ) {
39
44
case 'win32' : { operatingSystem = OperatingSystem . Windows ; break ; }
@@ -46,22 +51,36 @@ export class AnalyticsService {
46
51
cliVersion : Version . stringify ( ns . CliVersionInfo . getInstalledCliVersion ( ) ) ,
47
52
extensionVersion : Version . stringify ( ExtensionVersionInfo . getExtensionVersion ( ) ) ,
48
53
operatingSystem : operatingSystem ,
49
- userId : AnalyticsService . generateMachineId ( ) ,
50
- hostname : 'ns-vs-extension.org'
54
+ userId : AnalyticsService . generateMachineId ( )
51
55
} ;
52
56
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
+ }
54
61
}
55
62
56
63
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 ( ) ;
60
73
}
61
74
62
75
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 ( ) ;
66
85
}
67
86
}
0 commit comments