Skip to content

Commit e51adf0

Browse files
Fix tracking of Node.js version, LiveSync action and user sessions count (#3117)
Fix tracking of LiveSync action - it has been always tracked even when Build is required, so the workflow of user seemed like: - Build - LiveSync - Deploy - LiveSync Now it will be: - Build - Deploy - LiveSync Also update common lib, where the following changes are applied: Fix tracking of Node.js version in Eqatec and user sessions count Whenever a new eqatec monitor is started, we should track the version of Node.js. However, the current code was calling `trackFeatureCore` which always tracks to the Eqatec Analytics projects used for Feature trackings. This way, when any eqatec monitor is started, we've been sending information for Node.js version to the feature tracking projects. Fix this by passing the api key of the project in which we want to track the information. Also fix the user sessions count - whenever `start` method is called, we are constructing analytics settings (which increases the counter of current user sessions with 1) and pass this to `startEqatecMonitor` method. At this point we check if we've already started this monitor and in case not, we do not call start again. However, the values in `user-settings.json` for sessions count remains incorrect. Fix this by adding the check for already started monitor in the beginning of `start` method. Add unit tests to verify tracking in multiple projects. Change some of the already exising verifications to use arrays instead of strings for easier comparison.
1 parent 0579ec7 commit e51adf0

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

lib/services/analytics/analytics-service.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ export class AnalyticsService extends AnalyticsServiceBase {
1717
$analyticsSettingsService: IAnalyticsSettingsService,
1818
$osInfo: IOsInfo,
1919
private $childProcess: IChildProcess,
20-
private $processService: IProcessService,
20+
protected $processService: IProcessService,
2121
private $projectDataService: IProjectDataService,
2222
private $mobileHelper: Mobile.IMobileHelper) {
23-
super($logger, $options, $staticConfig, $prompter, $userSettingsService, $analyticsSettingsService, $osInfo);
23+
super($logger, $options, $staticConfig, $processService, $prompter, $userSettingsService, $analyticsSettingsService, $osInfo);
2424
}
2525

2626
public track(featureName: string, featureValue: string): Promise<void> {
@@ -189,7 +189,11 @@ export class AnalyticsService extends AnalyticsServiceBase {
189189
broker.send(message, resolve);
190190
} catch (err) {
191191
this.$logger.trace("Error while trying to send message to broker:", err);
192+
resolve();
192193
}
194+
} else {
195+
this.$logger.trace("Broker not found or not connected.");
196+
resolve();
193197
}
194198
});
195199
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ export class EqatecAnalyticsProvider extends AnalyticsServiceBase implements IAn
1515

1616
constructor(protected $logger: ILogger,
1717
protected $options: IOptions,
18+
$processService: IProcessService,
1819
$staticConfig: Config.IStaticConfig,
1920
$prompter: IPrompter,
2021
$userSettingsService: UserSettings.IUserSettingsService,
2122
$analyticsSettingsService: IAnalyticsSettingsService,
2223
$osInfo: IOsInfo) {
23-
super($logger, $options, $staticConfig, $prompter, $userSettingsService, $analyticsSettingsService, $osInfo);
24+
super($logger, $options, $staticConfig, $processService, $prompter, $userSettingsService, $analyticsSettingsService, $osInfo);
2425
}
2526

2627
public async trackInformation(data: IFeatureTrackingInformation): Promise<void> {

lib/services/livesync/livesync-service.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -375,14 +375,14 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
375375
pathToBuildItem = await options.deviceBuildInfoDescriptor.buildAction();
376376
options.rebuiltInformation.push({ isEmulator: options.device.isEmulator, platform, pathToBuildItem });
377377
action = LiveSyncTrackActionNames.LIVESYNC_OPERATION_BUILD;
378+
} else {
379+
await this.$analyticsService.trackEventActionInGoogleAnalytics({
380+
action: TrackActionNames.LiveSync,
381+
device: options.device,
382+
projectDir: options.projectData.projectDir
383+
});
378384
}
379385

380-
await this.$analyticsService.trackEventActionInGoogleAnalytics({
381-
action: TrackActionNames.LiveSync,
382-
device: options.device,
383-
projectDir: options.projectData.projectDir
384-
});
385-
386386
await this.trackAction(action, platform, options);
387387

388388
const shouldInstall = await this.$platformService.shouldInstall(options.device, options.projectData, options.deviceBuildInfoDescriptor.outputPath);

0 commit comments

Comments
 (0)