Skip to content

Commit 307fdff

Browse files
Track the amount and device type of builds and livesync operations (#2690)
* Track the amount and device type of builds and livesync operations In order to unsderstand the workflow of our users, we need to track how many builds they are executing, how many livesync operations, etc. We also need to know if the operation is for device or emulator (iOSSimulator). This will allow us to focus the development and provide better features in the future. * Track information for deploy and for device OS Track information for deploy operations. Introduce new method in platformService, that tracks the action. Track the device OS version as well. * Track Android only for build operations Track only Android platform for build operation. We do not need to track Android.emulator and Android.device for build operations as they are both the same actions.
1 parent 924952b commit 307fdff

File tree

4 files changed

+60
-1
lines changed

4 files changed

+60
-1
lines changed

lib/definitions/platform.d.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ interface IPlatformService {
131131
* @param {{isForDevice: boolean}} settings Defines if the searched artifact should be for simulator.
132132
* @returns {void}
133133
*/
134-
copyLastOutput(platform: string, targetPath: string, settings: {isForDevice: boolean}): void;
134+
copyLastOutput(platform: string, targetPath: string, settings: { isForDevice: boolean }): void;
135135

136136
lastOutputPath(platform: string, settings: { isForDevice: boolean }): string;
137137

@@ -150,6 +150,38 @@ interface IPlatformService {
150150
* @returns {IFuture<void>}
151151
*/
152152
trackProjectType(): IFuture<void>;
153+
154+
/**
155+
* Sends information to analytics for specific platform related action, for example Build, LiveSync, etc.
156+
* @param {ITrackPlatformAction} actionData The data describing current action.
157+
* @returns {IFuture<void>}
158+
*/
159+
trackActionForPlatform(actionData: ITrackPlatformAction): IFuture<void>;
160+
}
161+
162+
/**
163+
* Describes information that will be tracked for specific action related for platforms - build, livesync, etc.
164+
*/
165+
interface ITrackPlatformAction {
166+
/**
167+
* Name of the action.
168+
*/
169+
action: string;
170+
171+
/**
172+
* Platform for which the action will be executed.
173+
*/
174+
platform: string;
175+
176+
/**
177+
* Defines if the action is for device or emulator.
178+
*/
179+
isForDevice: boolean;
180+
181+
/**
182+
* Defines the OS version of the device for which the action will be executed.
183+
*/
184+
deviceOsVersion?: string;
153185
}
154186

155187
interface IPlatformData {

lib/services/livesync/platform-livesync-service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ export abstract class PlatformLiveSyncServiceBase implements IPlatformLiveSyncSe
3939
let canExecute = this.getCanExecuteAction(platform, appIdentifier);
4040
let action = (device: Mobile.IDevice): IFuture<void> => {
4141
return (() => {
42+
this.$platformService.trackActionForPlatform({ action: "LiveSync", platform, isForDevice: !device.isEmulator, deviceOsVersion: device.deviceInfo.version }).wait();
43+
4244
let deviceAppData = this.$deviceAppDataFactory.create(appIdentifier, this.$mobileHelper.normalizePlatformName(platform), device);
4345
let localToDevicePaths: Mobile.ILocalToDevicePathData[] = null;
4446
if (this.shouldTransferAllFiles(platform, deviceAppData)) {

lib/services/platform-service.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,11 +392,30 @@ export class PlatformService implements IPlatformService {
392392
}).future<void>()();
393393
}
394394

395+
public trackActionForPlatform(actionData: ITrackPlatformAction): IFuture<void> {
396+
return (() => {
397+
const normalizePlatformName = this.$mobileHelper.normalizePlatformName(actionData.platform);
398+
let featureValue = normalizePlatformName;
399+
if (actionData.isForDevice !== null) {
400+
const deviceType = actionData.isForDevice ? "device" : "emulator";
401+
featureValue += `.${deviceType}`;
402+
}
403+
404+
this.$analyticsService.track(actionData.action, featureValue).wait();
405+
406+
if (actionData.deviceOsVersion) {
407+
this.$analyticsService.track(`Device OS version`, `${normalizePlatformName}_${actionData.deviceOsVersion}`).wait();
408+
}
409+
}).future<void>()();
410+
}
411+
395412
public buildPlatform(platform: string, buildConfig?: IBuildConfig): IFuture<void> {
396413
return (() => {
397414
this.$logger.out("Building project...");
398415

399416
this.trackProjectType().wait();
417+
const isForDevice = this.$mobileHelper.isAndroidPlatform(platform) ? null : (this.$options.forDevice || (buildConfig && buildConfig.buildForDevice));
418+
this.trackActionForPlatform({ action: "Build", platform, isForDevice }).wait();
400419

401420
let platformData = this.$platformsData.getPlatformData(platform);
402421
platformData.platformProjectService.buildProject(platformData.projectRoot, buildConfig).wait();
@@ -464,6 +483,8 @@ export class PlatformService implements IPlatformService {
464483
} else {
465484
this.$logger.out("Skipping install.");
466485
}
486+
487+
this.trackActionForPlatform({ action: "Deploy", platform: device.deviceInfo.platform, isForDevice: !device.isEmulator, deviceOsVersion: device.deviceInfo.version }).wait();
467488
}).future<void>()();
468489
};
469490
this.$devicesService.execute(action, this.getCanExecuteAction(platform)).wait();

test/stubs.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,10 @@ export class PlatformServiceStub implements IPlatformService {
679679
public trackProjectType(): IFuture<void> {
680680
return Future.fromResult();
681681
}
682+
683+
public trackActionForPlatform(actionData: ITrackPlatformAction): IFuture<void> {
684+
return Future.fromResult();
685+
}
682686
}
683687

684688
export class EmulatorPlatformService implements IEmulatorPlatformService {

0 commit comments

Comments
 (0)