Files
flipper/desktop/plugins/public/ui-debugger/tracker.tsx
Lorenzo Blasa c2e41cd095 Copy diagnostics
Summary: Track copy events, both names and inline attributes.

Reviewed By: LukeDefeo

Differential Revision: D44297218

fbshipit-source-id: 5d2b1f2f4fa59d4a86e9e2ae1aa883712ceccb8c
2023-03-22 11:53:54 -07:00

67 lines
1.4 KiB
TypeScript

/**
* 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';
import {FrameworkEventType, Tag} from './types';
const UI_DEBUGGER_IDENTIFIER = 'ui-debugger';
type NodeEventPayload = {
name: string;
tags: Tag[];
};
type TrackerEvents = {
'more-options-opened': {};
'context-menu-opened': {};
'play-pause-toggled': {
paused: boolean;
};
'framework-event-monitored': {
eventType: FrameworkEventType;
monitored: boolean;
};
'search-term-updated': {
searchTerm: string;
};
'node-selected': NodeEventPayload;
'node-focused': NodeEventPayload;
'context-menu-name-copied': {
name: string;
};
'context-menu-copied': {
name: string;
key: string;
value: string;
};
};
export interface Tracker {
track<Event extends keyof TrackerEvents>(
event: Event,
payload: TrackerEvents[Event],
): void;
}
class UIDebuggerTracker implements Tracker {
track<Event extends keyof TrackerEvents>(
event: Event,
payload: TrackerEvents[Event],
): void {
getFlipperLib().logger.track(
'usage',
event,
payload,
UI_DEBUGGER_IDENTIFIER,
);
}
}
export const tracker: Tracker = new UIDebuggerTracker();