From 9b9674be2d6c9b14668a5fad38114f9c24e18db0 Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Fri, 17 Mar 2023 10:37:02 -0700 Subject: [PATCH] Track play-pause usage Summary: ^ Reviewed By: aigoncharov Differential Revision: D44169950 fbshipit-source-id: 7a10c6849382680723687a63fd987b9766076af9 --- desktop/plugins/public/ui-debugger/index.tsx | 2 + .../plugins/public/ui-debugger/tracker.tsx | 41 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 desktop/plugins/public/ui-debugger/tracker.tsx diff --git a/desktop/plugins/public/ui-debugger/index.tsx b/desktop/plugins/public/ui-debugger/index.tsx index 2f2b602fd..2c4d5c087 100644 --- a/desktop/plugins/public/ui-debugger/index.tsx +++ b/desktop/plugins/public/ui-debugger/index.tsx @@ -27,6 +27,7 @@ import { } from './types'; import {Draft} from 'immer'; import {QueryClient, setLogger} from 'react-query'; +import {tracker} from './tracker'; type SnapshotInfo = {nodeId: Id; base64Image: Snapshot}; type LiveClientState = { @@ -156,6 +157,7 @@ export function plugin(client: PluginClient) { }); const setPlayPause = (isPaused: boolean) => { + tracker.track('play-pause', {paused: isPaused}); uiState.isPaused.set(isPaused); if (!isPaused) { //When going back to play mode then set the atoms to the live state to rerender the latest diff --git a/desktop/plugins/public/ui-debugger/tracker.tsx b/desktop/plugins/public/ui-debugger/tracker.tsx new file mode 100644 index 000000000..1909f10dc --- /dev/null +++ b/desktop/plugins/public/ui-debugger/tracker.tsx @@ -0,0 +1,41 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + */ + +import {getFlipperLib} from 'flipper-plugin'; + +const UI_DEBUGGER_IDENTIFIER = 'ui-debugger'; + +type TrackerEvents = { + 'play-pause': { + paused: boolean; + }; +}; + +export interface Tracker { + track( + event: Event, + payload: TrackerEvents[Event], + ): void; +} + +class UIDebuggerTracker implements Tracker { + track( + event: Event, + payload: TrackerEvents[Event], + ): void { + getFlipperLib().logger.track( + 'usage', + event, + payload, + UI_DEBUGGER_IDENTIFIER, + ); + } +} + +export const tracker: Tracker = new UIDebuggerTracker();