Skip to content

Commit

Permalink
add prefersFuseboxFrontend field to debugger_command (facebook#44499)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#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
  • Loading branch information
EdmondChuiHW authored and facebook-github-bot committed May 9, 2024
1 parent 75dc42f commit cc99e92
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
28 changes: 25 additions & 3 deletions packages/dev-middleware/src/inspector-proxy/Device.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -521,6 +524,7 @@ export default class Device {
this.#deviceEventReporter?.logResponse(parsedPayload, 'device', {
pageId,
frontendUserAgent: this.#debuggerConnection?.userAgent ?? null,
prefersFuseboxFrontend: this.#isPageFuseboxFrontend(pageId),
});
}

Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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) => {
Expand All @@ -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),
});
};

Expand Down Expand Up @@ -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');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -95,6 +97,7 @@ class DeviceEventReporter {
deviceName: this.#metadata.deviceName,
pageId: metadata.pageId,
frontendUserAgent: metadata.frontendUserAgent,
prefersFuseboxFrontend: metadata.prefersFuseboxFrontend,
});
return;
}
Expand All @@ -120,6 +123,7 @@ class DeviceEventReporter {
deviceName: this.#metadata.deviceName,
pageId: pendingCommand.metadata.pageId,
frontendUserAgent: pendingCommand.metadata.frontendUserAgent,
prefersFuseboxFrontend: metadata.prefersFuseboxFrontend,
});
return;
}
Expand All @@ -136,6 +140,7 @@ class DeviceEventReporter {
deviceName: this.#metadata.deviceName,
pageId: pendingCommand.metadata.pageId,
frontendUserAgent: pendingCommand.metadata.frontendUserAgent,
prefersFuseboxFrontend: metadata.prefersFuseboxFrontend,
});
}

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -220,6 +226,7 @@ class DeviceEventReporter {
deviceName: this.#metadata.deviceName,
pageId: pendingCommand.metadata.pageId,
frontendUserAgent: pendingCommand.metadata.frontendUserAgent,
prefersFuseboxFrontend: pendingCommand.metadata.prefersFuseboxFrontend,
});
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/dev-middleware/src/types/EventReporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export type ReportableEvent =
timeSinceStart: number | null,
...DebuggerSessionIDs,
frontendUserAgent: string | null,
prefersFuseboxFrontend: boolean | null,
...
| SuccessResult<void>
| CodedErrorResult<
Expand Down

0 comments on commit cc99e92

Please sign in to comment.