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
18 changes: 17 additions & 1 deletion front_end/core/host/RNPerfMetrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,15 @@ class RNPerfMetrics {
});
}

manualBreakpointSetSucceeded(bpSettingDuration: number): void {
this.sendEvent({
eventName: 'ManualBreakpointSetSucceeded',
params: {
bpSettingDuration
}
});
}

panelShown(_panelName: string, _isLaunching?: boolean): void {
// no-op
// We only care about the "main" and "drawer" panels for now via panelShownInLocation(…)
Expand Down Expand Up @@ -489,12 +498,19 @@ export type StackTraceFrameUrlResolutionFailed = Readonly<{
}>,
}>;

export type ManualBreakpointSetSucceeded = Readonly<{
eventName: 'ManualBreakpointSetSucceeded',
params: Readonly<{
bpSettingDuration: number,
}>,
}>;

export type ReactNativeChromeDevToolsEvent =
EntrypointLoadingStartedEvent|EntrypointLoadingFinishedEvent|DebuggerReadyEvent|BrowserVisibilityChangeEvent|
BrowserErrorEvent|RemoteDebuggingTerminatedEvent|DeveloperResourceLoadingStartedEvent|
DeveloperResourceLoadingFinishedEvent|FuseboxSetClientMetadataStartedEvent|FuseboxSetClientMetadataFinishedEvent|
MemoryPanelActionStartedEvent|MemoryPanelActionFinishedEvent|PanelShownEvent|PanelClosedEvent|
StackTraceSymbolicationSucceeded|StackTraceSymbolicationFailed|StackTraceFrameUrlResolutionSucceeded|
StackTraceFrameUrlResolutionFailed;
StackTraceFrameUrlResolutionFailed|ManualBreakpointSetSucceeded;

export type DecoratedReactNativeChromeDevToolsEvent = CommonEventFields&ReactNativeChromeDevToolsEvent;
32 changes: 31 additions & 1 deletion front_end/panels/sources/DebuggerPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,37 @@ export class DebuggerPlugin extends Plugin {
}),
CodeMirror.lineNumbers({
domEventHandlers: {
click: (view, block, event) => this.handleGutterClick(view.state.doc.lineAt(block.from), event as MouseEvent),
click: (view, block, event) => {
if (Host.rnPerfMetrics.isEnabled()) {
const element = (event.target as Element);
const isClickAddingBreakpoint = (
element.classList &&
element.classList.contains('cm-gutterElement') &&
!element.classList.contains('cm-breakpoint')
);
if (isClickAddingBreakpoint) {
const setBreakpointStartMs = Date.now();
const observer = new MutationObserver(mutations => {
mutations.forEach(mutation => {
if (
mutation.type === 'attributes' &&
mutation.attributeName === 'class'
) {
if (element.classList.contains('cm-breakpoint')) {
Host.rnPerfMetrics.manualBreakpointSetSucceeded(Date.now() - setBreakpointStartMs);
observer.disconnect();
}
}
});
});
observer.observe(element, { attributes: true });
// if there's no breakpoint set on the line in 3 seconds, don't track the event.
// this could happen due to a different line getting the breakpoint, or an error.
setTimeout(() => observer.disconnect(), 3000);
}
}
return this.handleGutterClick(view.state.doc.lineAt(block.from), event as MouseEvent);
},
},
}),
breakpointMarkers,
Expand Down
Loading