Control use diagnostics
Summary: Current control diagnostics: - Play/Pause - Search - Framework Event Monitoring - Toggle more options Reviewed By: LukeDefeo Differential Revision: D44292835 fbshipit-source-id: c1ef6181141ef47262de8e75abeeb88ffebd4bd6
This commit is contained in:
committed by
Facebook GitHub Bot
parent
784401ae0b
commit
8d83fa2185
@@ -28,6 +28,12 @@ import {
|
|||||||
} from '@ant-design/icons';
|
} from '@ant-design/icons';
|
||||||
import {usePlugin, useValue, Layout} from 'flipper-plugin';
|
import {usePlugin, useValue, Layout} from 'flipper-plugin';
|
||||||
import {FrameworkEventType} from '../types';
|
import {FrameworkEventType} from '../types';
|
||||||
|
import {tracker} from '../tracker';
|
||||||
|
import {debounce} from 'lodash';
|
||||||
|
|
||||||
|
const searchTermUpdated = debounce((searchTerm: string) => {
|
||||||
|
tracker.track('search-term-updated', {searchTerm});
|
||||||
|
}, 250);
|
||||||
|
|
||||||
export const Controls: React.FC = () => {
|
export const Controls: React.FC = () => {
|
||||||
const instance = usePlugin(plugin);
|
const instance = usePlugin(plugin);
|
||||||
@@ -42,6 +48,7 @@ export const Controls: React.FC = () => {
|
|||||||
eventType: FrameworkEventType,
|
eventType: FrameworkEventType,
|
||||||
monitored: boolean,
|
monitored: boolean,
|
||||||
) => void = (eventType: FrameworkEventType, monitored: boolean) => {
|
) => void = (eventType: FrameworkEventType, monitored: boolean) => {
|
||||||
|
tracker.track('framework-event-monitored', {eventType, monitored});
|
||||||
instance.uiState.frameworkEventMonitoring.update((draft) =>
|
instance.uiState.frameworkEventMonitoring.update((draft) =>
|
||||||
draft.set(eventType, monitored),
|
draft.set(eventType, monitored),
|
||||||
);
|
);
|
||||||
@@ -51,14 +58,21 @@ export const Controls: React.FC = () => {
|
|||||||
<Layout.Horizontal pad="small" gap="small">
|
<Layout.Horizontal pad="small" gap="small">
|
||||||
<Input
|
<Input
|
||||||
value={searchTerm}
|
value={searchTerm}
|
||||||
onChange={(e) => instance.uiState.searchTerm.set(e.target.value)}
|
onChange={(e) => {
|
||||||
|
instance.uiState.searchTerm.set(e.target.value);
|
||||||
|
searchTermUpdated(e.target.value);
|
||||||
|
}}
|
||||||
prefix={<SearchOutlined />}
|
prefix={<SearchOutlined />}
|
||||||
placeholder="Search"
|
placeholder="Search"
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
type="default"
|
type="default"
|
||||||
shape="circle"
|
shape="circle"
|
||||||
onClick={() => instance.setPlayPause(!instance.uiState.isPaused.get())}
|
onClick={() => {
|
||||||
|
const isPaused = !instance.uiState.isPaused.get();
|
||||||
|
tracker.track('play-pause-toggled', {paused: isPaused});
|
||||||
|
instance.setPlayPause(isPaused);
|
||||||
|
}}
|
||||||
icon={
|
icon={
|
||||||
<Tooltip
|
<Tooltip
|
||||||
title={isPaused ? 'Resume live updates' : 'Pause incoming updates'}>
|
title={isPaused ? 'Resume live updates' : 'Pause incoming updates'}>
|
||||||
@@ -92,6 +106,7 @@ function MoreOptionsMenu({
|
|||||||
<Menu>
|
<Menu>
|
||||||
<Menu.Item
|
<Menu.Item
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
tracker.track('more-options-opened', {});
|
||||||
setShowFrameworkEventsModal(true);
|
setShowFrameworkEventsModal(true);
|
||||||
}}>
|
}}>
|
||||||
Framework event monitoring
|
Framework event monitoring
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import {
|
|||||||
} from './types';
|
} from './types';
|
||||||
import {Draft} from 'immer';
|
import {Draft} from 'immer';
|
||||||
import {QueryClient, setLogger} from 'react-query';
|
import {QueryClient, setLogger} from 'react-query';
|
||||||
import {tracker} from './tracker';
|
|
||||||
|
|
||||||
type SnapshotInfo = {nodeId: Id; base64Image: Snapshot};
|
type SnapshotInfo = {nodeId: Id; base64Image: Snapshot};
|
||||||
type LiveClientState = {
|
type LiveClientState = {
|
||||||
@@ -157,7 +156,6 @@ export function plugin(client: PluginClient<Events>) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const setPlayPause = (isPaused: boolean) => {
|
const setPlayPause = (isPaused: boolean) => {
|
||||||
tracker.track('play-pause', {paused: isPaused});
|
|
||||||
uiState.isPaused.set(isPaused);
|
uiState.isPaused.set(isPaused);
|
||||||
if (!isPaused) {
|
if (!isPaused) {
|
||||||
//When going back to play mode then set the atoms to the live state to rerender the latest
|
//When going back to play mode then set the atoms to the live state to rerender the latest
|
||||||
|
|||||||
@@ -8,13 +8,22 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {getFlipperLib} from 'flipper-plugin';
|
import {getFlipperLib} from 'flipper-plugin';
|
||||||
|
import {FrameworkEventType} from './types';
|
||||||
|
|
||||||
const UI_DEBUGGER_IDENTIFIER = 'ui-debugger';
|
const UI_DEBUGGER_IDENTIFIER = 'ui-debugger';
|
||||||
|
|
||||||
type TrackerEvents = {
|
type TrackerEvents = {
|
||||||
'play-pause': {
|
'more-options-opened': {};
|
||||||
|
'play-pause-toggled': {
|
||||||
paused: boolean;
|
paused: boolean;
|
||||||
};
|
};
|
||||||
|
'framework-event-monitored': {
|
||||||
|
eventType: FrameworkEventType;
|
||||||
|
monitored: boolean;
|
||||||
|
};
|
||||||
|
'search-term-updated': {
|
||||||
|
searchTerm: string;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface Tracker {
|
export interface Tracker {
|
||||||
@@ -25,7 +34,7 @@ export interface Tracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class UIDebuggerTracker implements Tracker {
|
class UIDebuggerTracker implements Tracker {
|
||||||
track<Event extends 'play-pause'>(
|
track<Event extends keyof TrackerEvents>(
|
||||||
event: Event,
|
event: Event,
|
||||||
payload: TrackerEvents[Event],
|
payload: TrackerEvents[Event],
|
||||||
): void {
|
): void {
|
||||||
|
|||||||
Reference in New Issue
Block a user