From cc99e924ca4f8d29cb6bf6bb5d2e180df541936a Mon Sep 17 00:00:00 2001 From: Edmond Chui Date: Thu, 9 May 2024 03:43:38 -0700 Subject: [PATCH] add prefersFuseboxFrontend field to debugger_command (#44499) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/44499 Changelog: [internal] As [discussed](https://fb.workplace.com/groups/react.devx.team/permalink/930483712103526/), we'll begin segmenting Telemetry signals by Fusebox/non-Fusebox. * Add new flag in event reporter for `debugger_command` (other events in subsequent diffs) * Add new column to the Scuba destination Reviewed By: blakef Differential Revision: D57140479 fbshipit-source-id: 7ea813b1b4d53a282873fa95c8ee82e5d6f3d1d3 --- .../src/inspector-proxy/Device.js | 28 +++++++++++++++++-- .../inspector-proxy/DeviceEventReporter.js | 7 +++++ .../dev-middleware/src/types/EventReporter.js | 1 + 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/packages/dev-middleware/src/inspector-proxy/Device.js b/packages/dev-middleware/src/inspector-proxy/Device.js index 1ecfd66f6535f4..5a5f3ff0671dfd 100644 --- a/packages/dev-middleware/src/inspector-proxy/Device.js +++ b/packages/dev-middleware/src/inspector-proxy/Device.js @@ -320,6 +320,9 @@ export default class Device { this.#deviceEventReporter?.logRequest(debuggerRequest, 'debugger', { pageId: this.#debuggerConnection?.pageId ?? null, frontendUserAgent: metadata.userAgent, + prefersFuseboxFrontend: this.#isPageFuseboxFrontend( + this.#debuggerConnection?.pageId, + ), }); let processedReq = debuggerRequest; @@ -521,6 +524,7 @@ export default class Device { this.#deviceEventReporter?.logResponse(parsedPayload, 'device', { pageId, frontendUserAgent: this.#debuggerConnection?.userAgent ?? null, + prefersFuseboxFrontend: this.#isPageFuseboxFrontend(pageId), }); } @@ -601,9 +605,11 @@ export default class Device { ]; for (const message of toSend) { + const pageId = this.#debuggerConnection?.pageId ?? null; this.#deviceEventReporter?.logRequest(message, 'proxy', { - pageId: this.#debuggerConnection?.pageId ?? null, + pageId, frontendUserAgent: this.#debuggerConnection?.userAgent ?? null, + prefersFuseboxFrontend: this.#isPageFuseboxFrontend(pageId), }); this.#sendMessageToDevice({ event: 'wrappedEvent', @@ -713,6 +719,9 @@ export default class Device { this.#deviceEventReporter?.logRequest(resumeMessage, 'proxy', { pageId: this.#debuggerConnection?.pageId ?? null, frontendUserAgent: this.#debuggerConnection?.userAgent ?? null, + prefersFuseboxFrontend: this.#isPageFuseboxFrontend( + this.#debuggerConnection?.pageId, + ), }); this.#sendMessageToDevice({ event: 'wrappedEvent', @@ -796,9 +805,11 @@ export default class Device { result, }; socket.send(JSON.stringify(response)); + const pageId = this.#debuggerConnection?.pageId ?? null; this.#deviceEventReporter?.logResponse(response, 'proxy', { - pageId: this.#debuggerConnection?.pageId ?? null, + pageId, frontendUserAgent: this.#debuggerConnection?.userAgent ?? null, + prefersFuseboxFrontend: this.#isPageFuseboxFrontend(pageId), }); }; const sendErrorResponse = (error: string) => { @@ -809,9 +820,11 @@ export default class Device { // Send to the console as well, so the user can see it this.#sendErrorToDebugger(error); + const pageId = this.#debuggerConnection?.pageId ?? null; this.#deviceEventReporter?.logResponse(response, 'proxy', { - pageId: this.#debuggerConnection?.pageId ?? null, + pageId, frontendUserAgent: this.#debuggerConnection?.userAgent ?? null, + prefersFuseboxFrontend: this.#isPageFuseboxFrontend(pageId), }); }; @@ -909,4 +922,13 @@ export default class Device { ); } } + + #isPageFuseboxFrontend(pageId: ?string): boolean | null { + const page = pageId == null ? null : this.#pages.get(pageId); + if (page == null) { + return null; + } + + return this.#pageHasCapability(page, 'prefersFuseboxFrontend'); + } } diff --git a/packages/dev-middleware/src/inspector-proxy/DeviceEventReporter.js b/packages/dev-middleware/src/inspector-proxy/DeviceEventReporter.js index 5fe9b4bc83dc59..41e8e6ddc24c36 100644 --- a/packages/dev-middleware/src/inspector-proxy/DeviceEventReporter.js +++ b/packages/dev-middleware/src/inspector-proxy/DeviceEventReporter.js @@ -29,11 +29,13 @@ type DeviceMetadata = $ReadOnly<{ type RequestMetadata = $ReadOnly<{ pageId: string | null, frontendUserAgent: string | null, + prefersFuseboxFrontend: boolean | null, }>; type ResponseMetadata = $ReadOnly<{ pageId: string | null, frontendUserAgent: string | null, + prefersFuseboxFrontend: boolean | null, }>; class DeviceEventReporter { @@ -95,6 +97,7 @@ class DeviceEventReporter { deviceName: this.#metadata.deviceName, pageId: metadata.pageId, frontendUserAgent: metadata.frontendUserAgent, + prefersFuseboxFrontend: metadata.prefersFuseboxFrontend, }); return; } @@ -120,6 +123,7 @@ class DeviceEventReporter { deviceName: this.#metadata.deviceName, pageId: pendingCommand.metadata.pageId, frontendUserAgent: pendingCommand.metadata.frontendUserAgent, + prefersFuseboxFrontend: metadata.prefersFuseboxFrontend, }); return; } @@ -136,6 +140,7 @@ class DeviceEventReporter { deviceName: this.#metadata.deviceName, pageId: pendingCommand.metadata.pageId, frontendUserAgent: pendingCommand.metadata.frontendUserAgent, + prefersFuseboxFrontend: metadata.prefersFuseboxFrontend, }); } @@ -181,6 +186,7 @@ class DeviceEventReporter { deviceName: this.#metadata.deviceName, pageId: pendingCommand.metadata.pageId, frontendUserAgent: pendingCommand.metadata.frontendUserAgent, + prefersFuseboxFrontend: pendingCommand.metadata.prefersFuseboxFrontend, }); } this.#pendingCommands.clear(); @@ -220,6 +226,7 @@ class DeviceEventReporter { deviceName: this.#metadata.deviceName, pageId: pendingCommand.metadata.pageId, frontendUserAgent: pendingCommand.metadata.frontendUserAgent, + prefersFuseboxFrontend: pendingCommand.metadata.prefersFuseboxFrontend, }); } } diff --git a/packages/dev-middleware/src/types/EventReporter.js b/packages/dev-middleware/src/types/EventReporter.js index 8a242eab1bbba8..c6f2de877c5a58 100644 --- a/packages/dev-middleware/src/types/EventReporter.js +++ b/packages/dev-middleware/src/types/EventReporter.js @@ -64,6 +64,7 @@ export type ReportableEvent = timeSinceStart: number | null, ...DebuggerSessionIDs, frontendUserAgent: string | null, + prefersFuseboxFrontend: boolean | null, ... | SuccessResult | CodedErrorResult<