@@ -23,11 +23,23 @@ export class AnalyticsService extends AnalyticsServiceBase implements IAnalytics
2323 }
2424
2525 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 ) ;
2733 }
2834
2935 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 ) ;
3143 }
3244
3345 public async trackAcceptFeatureUsage ( settings : { acceptTrackFeatureUsage : boolean } ) : Promise < void > {
@@ -137,44 +149,25 @@ export class AnalyticsService extends AnalyticsServiceBase implements IAnalytics
137149
138150 if ( ! isSettled ) {
139151 isSettled = true ;
152+
153+ this . $processService . attachToProcessExitSignals ( this , ( ) => {
154+ broker . send ( {
155+ type : TrackingTypes . Finish
156+ } ) ;
157+ } ) ;
158+
140159 resolve ( broker ) ;
141160 }
142161 }
143162 } ) ;
144-
145- this . $processService . attachToProcessExitSignals ( this , ( ) => {
146- broker . send ( {
147- type : TrackingTypes . Finish
148- } ) ;
149- } ) ;
150163 } ) ;
151164 }
152165
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 > {
168167 await this . initAnalyticsStatuses ( ) ;
169168
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 ) ;
178171 }
179172 }
180173
0 commit comments