From f6e00136ba16b51bc0d36532dbd6b9836df5f6a0 Mon Sep 17 00:00:00 2001 From: Pritesh Nandgaonkar Date: Thu, 31 Oct 2019 09:39:28 -0700 Subject: [PATCH] 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 --- src/fb-interfaces/Logger.tsx | 6 +++++- src/utils/exportData.tsx | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/fb-interfaces/Logger.tsx b/src/fb-interfaces/Logger.tsx index 8015d6914..83c687878 100644 --- a/src/fb-interfaces/Logger.tsx +++ b/src/fb-interfaces/Logger.tsx @@ -23,7 +23,11 @@ export type Args = { export interface Logger { 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; diff --git a/src/utils/exportData.tsx b/src/utils/exportData.tsx index 679600e8e..2e9991916 100644 --- a/src/utils/exportData.tsx +++ b/src/utils/exportData.tsx @@ -34,6 +34,7 @@ import promiseTimeout from './promiseTimeout'; import {Idler} from './Idler'; export const IMPORT_FLIPPER_TRACE_EVENT = 'import-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 = { [pluginKey: string]: string; @@ -499,6 +500,7 @@ export function exportStore( ): Promise<{serializedString: string; errorArray: Array}> { getLogger().track('usage', EXPORT_FLIPPER_TRACE_EVENT); return new Promise(async (resolve, reject) => { + performance.mark(EXPORT_FLIPPER_TRACE_TIME_EVENT); try { statusUpdate && statusUpdate('Preparing to export Flipper data...'); const {exportData, errorArray} = await getStoreExport( @@ -512,6 +514,13 @@ export function exportStore( if (serializedString.length <= 0) { 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}); } else { console.error('Make sure a device is connected');