Skip to content

Commit d340135

Browse files
Move analytics service registration
We need to create analytics service in the NS CLI to implement the NS specific logic for sending analytics data.
1 parent 2429d03 commit d340135

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

lib/bootstrap.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ $injector.require("androidDebugService", "./services/android-debug-service");
2525

2626
$injector.require("userSettingsService", "./services/user-settings-service");
2727
$injector.require("analyticsSettingsService", "./services/analytics-settings-service");
28+
$injector.require("analyticsService", "./services/analytics-service");
2829

2930
$injector.require("emulatorSettingsService", "./services/emulator-settings-service");
3031

lib/config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export class StaticConfig extends StaticConfigBase implements IStaticConfig {
2525
public CLIENT_NAME = "tns";
2626
public CLIENT_NAME_ALIAS = "NativeScript";
2727
public ANALYTICS_API_KEY = "5752dabccfc54c4ab82aea9626b7338e";
28-
public ANALYTICS_FEATURE_USAGE_TRACKING_API_KEY = "9912cff308334c6d9ad9c33f76a983e3";
2928
public TRACK_FEATURE_USAGE_SETTING_NAME = "TrackFeatureUsage";
3029
public ERROR_REPORT_SETTING_NAME = "TrackExceptions";
3130
public ANALYTICS_INSTALLATION_ID_SETTING_NAME = "AnalyticsInstallationID";

lib/services/analytics-service.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import {AnalyticsServiceBase} from "../common/services/analytics-service-base";
2+
3+
export class AnalyticsService extends AnalyticsServiceBase implements IAnalyticsService {
4+
private static ANALYTICS_FEATURE_USAGE_TRACKING_API_KEY = "9912cff308334c6d9ad9c33f76a983e3";
5+
6+
constructor(protected $logger: ILogger,
7+
protected $options: IOptions,
8+
$staticConfig: Config.IStaticConfig,
9+
$errors: IErrors,
10+
$prompter: IPrompter,
11+
$userSettingsService: UserSettings.IUserSettingsService,
12+
$analyticsSettingsService: IAnalyticsSettingsService,
13+
$progressIndicator: IProgressIndicator) {
14+
super($logger, $options, $staticConfig, $errors, $prompter, $userSettingsService, $analyticsSettingsService, $progressIndicator);
15+
}
16+
17+
protected checkConsentCore(trackFeatureUsage: boolean): IFuture<void> {
18+
return (() => {
19+
this.restartEqatecMonitor(AnalyticsService.ANALYTICS_FEATURE_USAGE_TRACKING_API_KEY).wait();
20+
super.checkConsentCore(trackFeatureUsage).wait();
21+
22+
// Stop the monitor, so correct API_KEY will be used when features are tracked.
23+
this.tryStopEqatecMonitor();
24+
}).future<void>()();
25+
}
26+
}
27+
28+
$injector.register("analyticsService", AnalyticsService);

0 commit comments

Comments
 (0)