Files
flipper/desktop/plugins/public/ui-debugger/tracker.tsx
Luke De Feo a6bc8933cc No longer autoscroll when selecting via tree
Summary:
Added selection source concept to onSelect callback. This allows us to only autoscroll the tree when selection source is the visualiser. We had feedback that the horizontal autoscrolling whilst using the tree was unhelpful.

A side benefit of selection source is better tracking of how people use kb, tree vs visualiser to select things

Changelog: UIDebugger only autoscroll horizontally when selecting via the visualiser

Reviewed By: lblasa

Differential Revision: D47334078

fbshipit-source-id: d7eadddb8d3d0fd428d5c294b2dccc2f1efa5a95
2023-07-19 08:58:20 -07:00

78 lines
1.6 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 {SelectionSource} from '.';
import {FrameworkEventType, Tag} from './types';
const UI_DEBUGGER_IDENTIFIER = 'ui-debugger';
type NodeEventPayload = {
name: string;
tags: Tag[];
source?: SelectionSource;
};
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;
};
'big-grep-searched': {
searchTerm: string;
tags: Tag[];
};
'ide-opened': {
ide: string;
name: string;
tags: Tag[];
};
};
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();