Skip to content

Commit fbe9938

Browse files
PR Comments 1
1 parent b2898fb commit fbe9938

File tree

4 files changed

+25
-49
lines changed

4 files changed

+25
-49
lines changed

lib/services/analytics/analytics-service.ts

Lines changed: 22 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,12 @@ export class AnalyticsService extends AnalyticsServiceBase implements IAnalytics
2121
super($logger, $options, $staticConfig, $prompter, $userSettingsService, $analyticsSettingsService, $progressIndicator, $osInfo);
2222
}
2323

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);
2626
}
2727

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);
3730
}
3831

3932
protected async checkConsentCore(trackFeatureUsage: boolean): Promise<void> {
@@ -93,56 +86,41 @@ export class AnalyticsService extends AnalyticsServiceBase implements IAnalytics
9386
type: TrackingTypes.Finish
9487
});
9588
});
96-
9789
});
98-
9990
}
10091

10192
private async sendDataForTracking(featureName: string, featureValue: string): Promise<void> {
10293
await this.initAnalyticsStatuses();
10394

10495
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+
);
119103
}
120-
121104
}
122105

123106
private async sendExceptionForTracking(exception: Error, message: string): Promise<void> {
124107
await this.initAnalyticsStatuses();
125108

126109
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+
);
142117
}
143-
144118
}
145119

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+
}
146124
}
147125

148126
$injector.register("analyticsService", AnalyticsService);

lib/services/analytics/eqatec-analytics-process.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const stopAnalyticsProcess = async () => {
3030
eqatecAnalyticsService = null;
3131
process.disconnect();
3232
} catch (err) {
33-
process.exit(0);
33+
process.exit(ErrorCodes.FAILED_EQATEC_ANALYTICS_PROCESS);
3434
}
3535
};
3636

lib/services/analytics/eqatec-analytics-provider.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@ export class EqatecAnalyticsProvider implements IAnalyticsProvider {
1818
return this._eqatecFeatureChildProcesses;
1919
}
2020

21-
@cache()
2221
private get _eqatecFeatureProjectAPIKeys(): string[] {
2322
return [
2423
this.$staticConfig.ANALYTICS_API_KEY,
2524
EqatecAnalyticsProvider.NEW_PROJECT_ANALYTICS_API_KEY
2625
];
2726
}
2827

29-
@cache()
3028
private get _eqatecExceptionProjectAPIKey(): string {
3129
return this.$staticConfig.ANALYTICS_EXCEPTIONS_API_KEY;
3230
}

lib/services/analytics/eqatec-analytics.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class EqatectAnalyticsService extends AnalyticsServiceBase {
2424
await this.waitForSending();
2525
}
2626
} catch (e) {
27-
this.$logger.trace("Analytics exception: '%s'", e.toString());
27+
this.$logger.trace(`Analytics exception: ${e}`);
2828
}
2929
}
3030

@@ -37,7 +37,7 @@ export class EqatectAnalyticsService extends AnalyticsServiceBase {
3737
await this.waitForSending();
3838
}
3939
} catch (e) {
40-
this.$logger.trace("Analytics exception: '%s'", e.toString());
40+
this.$logger.trace(`Analytics exception: ${e}`);
4141
}
4242
}
4343

0 commit comments

Comments
 (0)