Add telemetry for export time and selected plugins

Summary: Adds telemetry for the export time and also logs the selected plugins.

Reviewed By: jknoxville

Differential Revision: D18244843

fbshipit-source-id: 36a3e8b9b456b59187918d19075a2c1ea0caef25
This commit is contained in:
Pritesh Nandgaonkar
2019-10-31 09:39:28 -07:00
committed by Facebook Github Bot
parent ce7e13ce54
commit f6e00136ba
2 changed files with 14 additions and 1 deletions

View File

@@ -23,7 +23,11 @@ export type Args = {
export interface Logger { export interface Logger {
track(type: TrackType, event: string, data?: any, plugin?: string): void; track(type: TrackType, event: string, data?: any, plugin?: string): void;
trackTimeSince(mark: string, eventName?: string | null | undefined): void; trackTimeSince(
mark: string,
eventName?: string | null | undefined,
data?: any,
): void;
info(data: any, category: string): void; info(data: any, category: string): void;

View File

@@ -34,6 +34,7 @@ import promiseTimeout from './promiseTimeout';
import {Idler} from './Idler'; import {Idler} from './Idler';
export const IMPORT_FLIPPER_TRACE_EVENT = 'import-flipper-trace'; export const IMPORT_FLIPPER_TRACE_EVENT = 'import-flipper-trace';
export const EXPORT_FLIPPER_TRACE_EVENT = 'export-flipper-trace'; export const EXPORT_FLIPPER_TRACE_EVENT = 'export-flipper-trace';
export const EXPORT_FLIPPER_TRACE_TIME_EVENT = 'export-flipper-trace-time';
export type PluginStatesExportState = { export type PluginStatesExportState = {
[pluginKey: string]: string; [pluginKey: string]: string;
@@ -499,6 +500,7 @@ export function exportStore(
): Promise<{serializedString: string; errorArray: Array<Error>}> { ): Promise<{serializedString: string; errorArray: Array<Error>}> {
getLogger().track('usage', EXPORT_FLIPPER_TRACE_EVENT); getLogger().track('usage', EXPORT_FLIPPER_TRACE_EVENT);
return new Promise(async (resolve, reject) => { return new Promise(async (resolve, reject) => {
performance.mark(EXPORT_FLIPPER_TRACE_TIME_EVENT);
try { try {
statusUpdate && statusUpdate('Preparing to export Flipper data...'); statusUpdate && statusUpdate('Preparing to export Flipper data...');
const {exportData, errorArray} = await getStoreExport( const {exportData, errorArray} = await getStoreExport(
@@ -512,6 +514,13 @@ export function exportStore(
if (serializedString.length <= 0) { if (serializedString.length <= 0) {
reject(new Error('Serialize function returned empty string')); reject(new Error('Serialize function returned empty string'));
} }
getLogger().trackTimeSince(
EXPORT_FLIPPER_TRACE_TIME_EVENT,
EXPORT_FLIPPER_TRACE_TIME_EVENT,
{
plugins: store.getState().plugins.selectedPlugins,
},
);
resolve({serializedString, errorArray}); resolve({serializedString, errorArray});
} else { } else {
console.error('Make sure a device is connected'); console.error('Make sure a device is connected');