Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/react-devtools-shared/src/Logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ export type LogEvent =
+event_name: 'profiling-start',
|};

export type LogFunction = LogEvent => void | Promise<void>;
export type LogFunction = (LogEvent, ?Object) => void | Promise<void>;

let logFunctions: Array<LogFunction> = [];
export const logEvent: LogFunction =
enableLogger === true
? function logEvent(event: LogEvent): void {
? function logEvent(event: LogEvent, metadata: ?Object): void {
logFunctions.forEach(log => {
log(event);
log(event, metadata);
});
}
: function logEvent() {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default function Element({data, index, style}: Props) {

const handleClick = ({metaKey}) => {
if (id !== null) {
logEvent({event_name: 'select-element'});
logEvent({event_name: 'select-element'}, {source: 'click-element'});
dispatch({
type: 'SELECT_ELEMENT_BY_ID',
payload: metaKey ? null : id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ function OwnerView({
} = useHighlightNativeElement();

const handleClick = useCallback(() => {
logEvent({event_name: 'select-element'});
logEvent({event_name: 'select-element'}, {source: 'owner-view'});
dispatch({
type: 'SELECT_ELEMENT_BY_ID',
payload: id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export default function Tree(props: Props) {
function handleStopInspectingNative(didSelectNode) {
if (didSelectNode && focusTargetRef.current !== null) {
focusTargetRef.current.focus();
logEvent({event_name: 'select-element'});
logEvent({event_name: 'select-element'}, {source: 'inspector'});
}
}
bridge.addListener('stopInspectingNative', handleStopInspectingNative);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,6 @@ function ProfilerContextController({children}: Props) {
});
}

const startProfiling = useCallback(() => {
logEvent({event_name: 'profiling-start'});
store.profilerStore.startProfiling();
}, [store]);
const stopProfiling = useCallback(() => store.profilerStore.stopProfiling(), [
store,
]);

const [
isCommitFilterEnabled,
setIsCommitFilterEnabled,
Expand All @@ -217,6 +209,14 @@ function ProfilerContextController({children}: Props) {
'flame-chart',
);

const startProfiling = useCallback(() => {
logEvent({event_name: 'profiling-start'}, {current_tab: selectedTabID});
store.profilerStore.startProfiling();
}, [store, selectedTabID]);
const stopProfiling = useCallback(() => store.profilerStore.stopProfiling(), [
store,
]);

if (isProfiling) {
batchedUpdates(() => {
if (selectedCommitIndex !== null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function registerDevToolsEventLogger(
| LoggerContext
| ?(() => Promise<LoggerContext>),
): void {
async function logEvent(event: LogEvent) {
async function logEvent(event: LogEvent, metadata: ?Object) {
if (enableLogger) {
if (loggingIFrame != null) {
loggingIFrame.contentWindow.postMessage(
Expand All @@ -35,6 +35,7 @@ export function registerDevToolsEventLogger(
context: {
surface,
version: process.env.DEVTOOLS_VERSION,
metadata: metadata != null ? JSON.stringify(metadata) : '',
...(fetchAdditionalContext != null
? await fetchAdditionalContext()
: {}),
Expand Down