Skip to content

Commit c2513cb

Browse files
Track the amount and device type of builds and livesync operations (#2690) (#2696)
* 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 cb14f6c commit c2513cb

File tree

4 files changed

+62
-5
lines changed

4 files changed

+62
-5
lines changed

lib/definitions/platform.d.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,13 @@ interface IPlatformService extends NodeJS.EventEmitter {
192192
* @returns {Promise<void>}
193193
*/
194194
trackProjectType(projectData: IProjectData): Promise<void>;
195+
196+
/**
197+
* Sends information to analytics for specific platform related action, for example Build, LiveSync, etc.
198+
* @param {ITrackPlatformAction} actionData The data describing current action.
199+
* @returns {Promise<void>}
200+
*/
201+
trackActionForPlatform(actionData: ITrackPlatformAction): Promise<void>;
195202
}
196203

197204
/**
@@ -209,6 +216,31 @@ interface IPlatformSpecificData {
209216
sdk: string;
210217
}
211218

219+
/**
220+
* Describes information that will be tracked for specific action related for platforms - build, livesync, etc.
221+
*/
222+
interface ITrackPlatformAction {
223+
/**
224+
* Name of the action.
225+
*/
226+
action: string;
227+
228+
/**
229+
* Platform for which the action will be executed.
230+
*/
231+
platform: string;
232+
233+
/**
234+
* Defines if the action is for device or emulator.
235+
*/
236+
isForDevice: boolean;
237+
238+
/**
239+
* Defines the OS version of the device for which the action will be executed.
240+
*/
241+
deviceOsVersion?: string;
242+
}
243+
212244
interface IPlatformData {
213245
frameworkPackageName: string;
214246
platformProjectService: IPlatformProjectService;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ export abstract class PlatformLiveSyncServiceBase implements IPlatformLiveSyncSe
3434
let projectFilesPath = this.liveSyncData.projectFilesPath;
3535
let canExecute = this.getCanExecuteAction(platform, appIdentifier);
3636
let action = async (device: Mobile.IDevice): Promise<void> => {
37+
await this.$platformService.trackActionForPlatform({ action: "LiveSync", platform, isForDevice: !device.isEmulator, deviceOsVersion: device.deviceInfo.version });
38+
3739
let deviceAppData = this.$deviceAppDataFactory.create(appIdentifier, this.$mobileHelper.normalizePlatformName(platform), device);
3840
let localToDevicePaths: Mobile.ILocalToDevicePathData[] = null;
3941
if (await this.shouldTransferAllFiles(platform, deviceAppData, projectData)) {

lib/services/platform-service.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export class PlatformService extends EventEmitter implements IPlatformService {
6868
}
6969
}
7070

71-
private getCurrentPlatformVersion(platform: string, projectData: IProjectData) : string {
71+
private getCurrentPlatformVersion(platform: string, projectData: IProjectData): string {
7272
let platformData = this.$platformsData.getPlatformData(platform, projectData);
7373
let currentPlatformData: any = this.$projectDataService.getNSValue(projectData.projectDir, platformData.frameworkPackageName);
7474
let version: string;
@@ -393,10 +393,27 @@ export class PlatformService extends EventEmitter implements IPlatformService {
393393
}
394394
}
395395

396+
public async trackActionForPlatform(actionData: ITrackPlatformAction): Promise<void> {
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+
await this.$analyticsService.track(actionData.action, featureValue);
405+
406+
if (actionData.deviceOsVersion) {
407+
await this.$analyticsService.track(`Device OS version`, `${normalizePlatformName}_${actionData.deviceOsVersion}`);
408+
}
409+
}
410+
396411
public async buildPlatform(platform: string, buildConfig: IBuildConfig, projectData: IProjectData): Promise<void> {
397412
this.$logger.out("Building project...");
398413

399414
await this.trackProjectType(projectData);
415+
const isForDevice = this.$mobileHelper.isAndroidPlatform(platform) ? null : buildConfig && buildConfig.buildForDevice;
416+
await this.trackActionForPlatform({ action: "Build", platform, isForDevice });
400417

401418
let platformData = this.$platformsData.getPlatformData(platform, projectData);
402419
platformData.platformProjectService.on(constants.BUILD_OUTPUT_EVENT_NAME, (data: any) => {
@@ -482,6 +499,8 @@ export class PlatformService extends EventEmitter implements IPlatformService {
482499
} else {
483500
this.$logger.out("Skipping install.");
484501
}
502+
503+
await this.trackActionForPlatform({ action: "Deploy", platform: device.deviceInfo.platform, isForDevice: !device.isEmulator, deviceOsVersion: device.deviceInfo.version });
485504
};
486505

487506
await this.$devicesService.execute(action, this.getCanExecuteAction(platform, deployOptions));

test/stubs.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ export class PlatformsDataStub extends EventEmitter implements IPlatformsData {
255255
normalizedPlatformName: "",
256256
appDestinationDirectoryPath: "",
257257
deviceBuildOutputPath: "",
258-
getValidPackageNames: (buildOptions: {isForDevice?: boolean, isReleaseBuild?: boolean}) => [],
258+
getValidPackageNames: (buildOptions: { isForDevice?: boolean, isReleaseBuild?: boolean }) => [],
259259
frameworkFilesExtensions: [],
260260
relativeToFrameworkConfigurationFilePath: "",
261261
fastLivesyncFileExtensions: []
@@ -276,7 +276,7 @@ export class PlatformProjectServiceStub extends EventEmitter implements IPlatfor
276276
emulatorServices: undefined,
277277
projectRoot: "",
278278
deviceBuildOutputPath: "",
279-
getValidPackageNames: (buildOptions: {isForDevice?: boolean, isReleaseBuild?: boolean}) => [],
279+
getValidPackageNames: (buildOptions: { isForDevice?: boolean, isReleaseBuild?: boolean }) => [],
280280
frameworkFilesExtensions: [],
281281
appDestinationDirectoryPath: "",
282282
relativeToFrameworkConfigurationFilePath: "",
@@ -302,7 +302,7 @@ export class PlatformProjectServiceStub extends EventEmitter implements IPlatfor
302302
return Promise.resolve();
303303
}
304304
interpolateConfigurationFile(): void {
305-
return ;
305+
return;
306306
}
307307
afterCreateProject(projectRoot: string): void {
308308
return null;
@@ -350,7 +350,7 @@ export class PlatformProjectServiceStub extends EventEmitter implements IPlatfor
350350
return null;
351351
}
352352
async stopServices(): Promise<ISpawnResult> {
353-
return Promise.resolve({stderr: "", stdout: "", exitCode: 0});
353+
return Promise.resolve({ stderr: "", stdout: "", exitCode: 0 });
354354
}
355355
async cleanProject(projectRoot: string, projectData: IProjectData): Promise<void> {
356356
return Promise.resolve();
@@ -682,6 +682,10 @@ export class PlatformServiceStub extends EventEmitter implements IPlatformServic
682682
public async trackProjectType(): Promise<void> {
683683
return null;
684684
}
685+
686+
public async trackActionForPlatform(actionData: ITrackPlatformAction): Promise<void> {
687+
return null;
688+
}
685689
}
686690

687691
export class EmulatorPlatformService implements IEmulatorPlatformService {

0 commit comments

Comments
 (0)