From 87cb9bd77ab3a9ce78a2e8db02c4f2ab1b87be25 Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Thu, 2 Nov 2023 10:42:15 -0700 Subject: [PATCH] Track state changes Summary: Track server connectivity state changes, queries will follow. Reviewed By: antonk52 Differential Revision: D50928297 fbshipit-source-id: 9f3a3b799481556bab7339d710736448fed6004c --- desktop/flipper-ui-browser/src/index.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/desktop/flipper-ui-browser/src/index.tsx b/desktop/flipper-ui-browser/src/index.tsx index fbbf974e4..d6c4b018e 100644 --- a/desktop/flipper-ui-browser/src/index.tsx +++ b/desktop/flipper-ui-browser/src/index.tsx @@ -97,11 +97,18 @@ async function start() { getLogger().info('[flipper-client][ui-browser] Create WS client'); + let lastStateChangeMS = performance.now(); const flipperServer = await createFlipperServer( location.hostname, parseInt(location.port, 10), tokenProvider, (state: FlipperServerState) => { + const timestamp = performance.now(); + getLogger().track('usage', 'browser-server-state-changed', { + state, + timeElapsedMS: timestamp - lastStateChangeMS, + }); + lastStateChangeMS = timestamp; switch (state) { case FlipperServerState.CONNECTING: getLogger().info('[flipper-client] Connecting to server');