@@ -23,11 +23,23 @@ export class AnalyticsService extends AnalyticsServiceBase implements IAnalytics
23
23
}
24
24
25
25
public track ( featureName : string , featureValue : string ) : Promise < void > {
26
- return this . sendDataForTracking ( featureName , featureValue ) ;
26
+ const data : IFeatureTrackingInformation = {
27
+ type : TrackingTypes . Feature ,
28
+ featureName : featureName ,
29
+ featureValue : featureValue
30
+ } ;
31
+
32
+ return this . sendInfoForTracking ( data , this . $staticConfig . TRACK_FEATURE_USAGE_SETTING_NAME ) ;
27
33
}
28
34
29
35
public trackException ( exception : any , message : string ) : Promise < void > {
30
- return this . sendExceptionForTracking ( exception , message ) ;
36
+ const data : IExceptionsTrackingInformation = {
37
+ type : TrackingTypes . Exception ,
38
+ exception,
39
+ message
40
+ } ;
41
+
42
+ return this . sendInfoForTracking ( data , this . $staticConfig . ERROR_REPORT_SETTING_NAME ) ;
31
43
}
32
44
33
45
public async trackAcceptFeatureUsage ( settings : { acceptTrackFeatureUsage : boolean } ) : Promise < void > {
@@ -137,44 +149,25 @@ export class AnalyticsService extends AnalyticsServiceBase implements IAnalytics
137
149
138
150
if ( ! isSettled ) {
139
151
isSettled = true ;
152
+
153
+ this . $processService . attachToProcessExitSignals ( this , ( ) => {
154
+ broker . send ( {
155
+ type : TrackingTypes . Finish
156
+ } ) ;
157
+ } ) ;
158
+
140
159
resolve ( broker ) ;
141
160
}
142
161
}
143
162
} ) ;
144
-
145
- this . $processService . attachToProcessExitSignals ( this , ( ) => {
146
- broker . send ( {
147
- type : TrackingTypes . Finish
148
- } ) ;
149
- } ) ;
150
163
} ) ;
151
164
}
152
165
153
- private async sendDataForTracking ( featureName : string , featureValue : string ) : Promise < void > {
154
- await this . initAnalyticsStatuses ( ) ;
155
-
156
- if ( ! this . $staticConfig . disableAnalytics && this . analyticsStatuses [ this . $staticConfig . TRACK_FEATURE_USAGE_SETTING_NAME ] === AnalyticsStatus . enabled ) {
157
- return this . sendMessageToBroker (
158
- < IFeatureTrackingInformation > {
159
- type : TrackingTypes . Feature ,
160
- featureName : featureName ,
161
- featureValue : featureValue
162
- }
163
- ) ;
164
- }
165
- }
166
-
167
- private async sendExceptionForTracking ( exception : Error , message : string ) : Promise < void > {
166
+ private async sendInfoForTracking ( trackingInfo : ITrackingInformation , settingName : string ) : Promise < void > {
168
167
await this . initAnalyticsStatuses ( ) ;
169
168
170
- if ( ! this . $staticConfig . disableAnalytics && this . analyticsStatuses [ this . $staticConfig . ERROR_REPORT_SETTING_NAME ] === AnalyticsStatus . enabled ) {
171
- return this . sendMessageToBroker (
172
- < IExceptionsTrackingInformation > {
173
- type : TrackingTypes . Exception ,
174
- exception,
175
- message
176
- }
177
- ) ;
169
+ if ( ! this . $staticConfig . disableAnalytics && this . analyticsStatuses [ settingName ] === AnalyticsStatus . enabled ) {
170
+ return this . sendMessageToBroker ( trackingInfo ) ;
178
171
}
179
172
}
180
173
0 commit comments