@@ -21,19 +21,12 @@ export class AnalyticsService extends AnalyticsServiceBase implements IAnalytics
21
21
super ( $logger , $options , $staticConfig , $prompter , $userSettingsService , $analyticsSettingsService , $progressIndicator , $osInfo ) ;
22
22
}
23
23
24
- public async track ( featureName : string , featureValue : string ) : Promise < void > {
25
- await this . sendDataForTracking ( featureName , featureValue ) ;
24
+ public track ( featureName : string , featureValue : string ) : Promise < void > {
25
+ return this . sendDataForTracking ( featureName , featureValue ) ;
26
26
}
27
27
28
- public async trackException ( exception : any , message : string ) : Promise < void > {
29
- await this . sendExceptionForTracking ( exception , message ) ;
30
- }
31
-
32
- public async trackFeature ( featureValue : string ) : Promise < void > {
33
- const featureName = this . $options . analyticsClient ||
34
- ( helpers . isInteractive ( ) ? "CLI" : "Non-interactive" ) ;
35
-
36
- await this . sendDataForTracking ( featureName , featureValue ) ;
28
+ public trackException ( exception : any , message : string ) : Promise < void > {
29
+ return this . sendExceptionForTracking ( exception , message ) ;
37
30
}
38
31
39
32
protected async checkConsentCore ( trackFeatureUsage : boolean ) : Promise < void > {
@@ -93,56 +86,41 @@ export class AnalyticsService extends AnalyticsServiceBase implements IAnalytics
93
86
type : TrackingTypes . Finish
94
87
} ) ;
95
88
} ) ;
96
-
97
89
} ) ;
98
-
99
90
}
100
91
101
92
private async sendDataForTracking ( featureName : string , featureValue : string ) : Promise < void > {
102
93
await this . initAnalyticsStatuses ( ) ;
103
94
104
95
if ( this . analyticsStatuses [ this . $staticConfig . TRACK_FEATURE_USAGE_SETTING_NAME ] === AnalyticsStatus . enabled ) {
105
- const broker = await this . getAnalyticsBroker ( ) ;
106
-
107
- return new Promise < void > ( ( resolve , reject ) => {
108
- broker . send (
109
- {
110
- type : TrackingTypes . Feature ,
111
- featureName : featureName ,
112
- featureValue : featureValue
113
- } ,
114
- ( ) => {
115
- resolve ( ) ;
116
- } ) ;
117
- } ) ;
118
-
96
+ return this . sendMessageToBroker (
97
+ {
98
+ type : TrackingTypes . Feature ,
99
+ featureName : featureName ,
100
+ featureValue : featureValue
101
+ }
102
+ ) ;
119
103
}
120
-
121
104
}
122
105
123
106
private async sendExceptionForTracking ( exception : Error , message : string ) : Promise < void > {
124
107
await this . initAnalyticsStatuses ( ) ;
125
108
126
109
if ( this . analyticsStatuses [ this . $staticConfig . ERROR_REPORT_SETTING_NAME ] === AnalyticsStatus . enabled ) {
127
- const broker = await this . getAnalyticsBroker ( ) ;
128
-
129
- return new Promise < void > ( ( resolve , reject ) => {
130
- broker . send (
131
- {
132
- type : TrackingTypes . Exception ,
133
- exception,
134
- message
135
- } ,
136
- ( ) => {
137
- resolve ( ) ;
138
- } ) ;
139
-
140
- } ) ;
141
-
110
+ return this . sendMessageToBroker (
111
+ {
112
+ type : TrackingTypes . Exception ,
113
+ exception,
114
+ message
115
+ }
116
+ ) ;
142
117
}
143
-
144
118
}
145
119
120
+ private async sendMessageToBroker ( message : any ) : Promise < void > {
121
+ const broker = await this . getAnalyticsBroker ( ) ;
122
+ return new Promise < void > ( ( resolve , reject ) => broker . send ( message , resolve ) ) ;
123
+ }
146
124
}
147
125
148
126
$injector . register ( "analyticsService" , AnalyticsService ) ;
0 commit comments