Skip to content
This repository has been archived by the owner on Nov 22, 2024. It is now read-only.

Commit

Permalink
Set the app id as received from the ws connection
Browse files Browse the repository at this point in the history
Summary: The previous diff sent the app or bundle identifier. This change parses the received field and sets it accordingly.

Reviewed By: passy

Differential Revision: D56577811

fbshipit-source-id: 8b1fea08ce5a71424c362e11fabb34553ac223d1
  • Loading branch information
antonk52 authored and facebook-github-bot committed May 8, 2024
1 parent 345a4df commit e4c8c99
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 1 deletion.
1 change: 1 addition & 0 deletions desktop/flipper-common/src/server-types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export type UninitializedClient = {

export type ClientQuery = {
readonly app: string;
readonly app_id?: string;
readonly os: DeviceOS;
readonly device: string;
readonly device_id: string;
Expand Down
1 change: 1 addition & 0 deletions desktop/flipper-plugin/src/plugin/Plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export interface RealFlipperClient {
connected: Atom<boolean>;
query: {
app: string;
app_id?: string;
os: string;
device: string;
device_id: string;
Expand Down
1 change: 1 addition & 0 deletions desktop/flipper-plugin/src/test-utils/test-utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ export function startPlugin<Module extends FlipperPluginModule<any>>(
plugins: new Set([definition.id]),
query: {
app: appName,
app_id: `com.facebook.flipper.${appName}`,
device: deviceName,
device_id: testDevice.serial,
os: testDevice.serial,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ export class ServerController
): Promise<ClientDescription> {
const {
app,
app_id,
os,
device,
device_id,
Expand All @@ -194,6 +195,7 @@ export class ServerController
clientConnection,
{
app,
app_id,
os,
device,
device_id,
Expand Down
6 changes: 6 additions & 0 deletions desktop/flipper-server/src/app-connectivity/Utilities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ export function parseClientQuery(
return;
}

let app_id: string | undefined;
if (typeof query.app_id === 'string') {
app_id = query.app_id;
}

let os: DeviceOS | undefined;
if (typeof query.os === 'string') {
os = query.os as DeviceOS;
Expand Down Expand Up @@ -152,6 +157,7 @@ export function parseClientQuery(
device_id,
device,
app,
app_id,
os,
medium: transformCertificateExchangeMediumToType(medium),
sdk_version,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ describe('BrowserServerWebSocket', () => {
device,
os,
app,
app_id: `com.facebook.flipper.${app}`,
sdk_version: sdkVersion,
medium: 'NONE',
};
Expand Down Expand Up @@ -182,6 +183,7 @@ describe('BrowserServerWebSocket', () => {
device,
os: 'MacOS',
app: device,
app_id: `com.facebook.flipper.${device}`,
sdk_version: 4,
medium: 'NONE',
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ describe('SecureServerWebSocket', () => {
device,
os,
app,
app_id: `com.facebook.flipper.${app}`,
sdk_version: sdkVersion,
csr,
csr_path: csrPath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ describe('ServerWebSocket', () => {
device,
os,
app,
app_id: `com.facebook.flipper.${app}`,
sdk_version: sdkVersion,
medium: 'WWW',
};
Expand Down
1 change: 1 addition & 0 deletions desktop/flipper-server/src/recorder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Recorder {
private flipperServer_: FlipperServerImpl | undefined;
private undefinedClientQuery_: ClientQuery = {
app: 'NONE',
app_id: 'NONE',
device: 'NONE',
medium: 'NONE',
os: 'Browser',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ export default class MockFlipper {
}
query = query ?? {
app: name ?? `serial_${++this._clientCounter}`,
app_id: name ?? 'NONE',
os: 'Android',
device: device.title,
device_id: device.serial,
Expand Down
23 changes: 22 additions & 1 deletion desktop/flipper-ui/src/utils/__tests__/exportData.node.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ function generateClientFromClientWithSalt(
id: identifier,
query: {
app,
app_id: `com.facebook.flipper.${app}`,
os,
device,
device_id: `${salt}-${device_id}`,
Expand All @@ -121,7 +122,14 @@ function generateClientFromDevice(device: Device, app: string): ClientExport {
const identifier = generateClientIdentifier(device, app);
return {
id: identifier,
query: {app, os, device: deviceType, device_id: serial, medium: 'NONE'},
query: {
app,
app_id: `com.facebook.flipper.${app}`,
os,
device: deviceType,
device_id: serial,
medium: 'NONE',
},
};
}

Expand Down Expand Up @@ -734,6 +742,7 @@ test('test determinePluginsToProcess for mutilple clients having plugins present
generateClientIdentifier(device1, 'app'),
{
app: 'app',
app_id: 'com.facebook.flipper.app',
os: 'iOS',
device: 'TestiPhone',
device_id: 'serial1',
Expand All @@ -750,6 +759,7 @@ test('test determinePluginsToProcess for mutilple clients having plugins present
generateClientIdentifier(device1, 'app2'),
{
app: 'app2',
app_id: 'com.facebook.flipper.app2',
os: 'iOS',
device: 'TestiPhone',
device_id: 'serial1',
Expand All @@ -766,6 +776,7 @@ test('test determinePluginsToProcess for mutilple clients having plugins present
generateClientIdentifier(device1, 'app3'),
{
app: 'app3',
app_id: 'com.facebook.flipper.app3',
os: 'iOS',
device: 'TestiPhone',
device_id: 'serial1',
Expand Down Expand Up @@ -826,6 +837,7 @@ test('test determinePluginsToProcess for no selected plugin present in any clien
generateClientIdentifier(device1, 'app'),
{
app: 'app',
app_id: 'com.facebook.flipper.app',
os: 'iOS',
device: 'TestiPhone',
device_id: 'serial1',
Expand All @@ -842,6 +854,7 @@ test('test determinePluginsToProcess for no selected plugin present in any clien
generateClientIdentifier(device1, 'app2'),
{
app: 'app2',
app_id: 'com.facebook.flipper.app2',
os: 'iOS',
device: 'TestiPhone',
device_id: 'serial1',
Expand Down Expand Up @@ -885,6 +898,7 @@ test('test determinePluginsToProcess for multiple clients on same device', async
generateClientIdentifier(device1, 'app'),
{
app: 'app',
app_id: 'com.facebook.flipper.app',
os: 'iOS',
device: 'TestiPhone',
device_id: 'serial1',
Expand All @@ -901,6 +915,7 @@ test('test determinePluginsToProcess for multiple clients on same device', async
generateClientIdentifier(device1, 'app2'),
{
app: 'app2',
app_id: 'com.facebook.flipper.app2',
os: 'iOS',
device: 'TestiPhone',
device_id: 'serial1',
Expand Down Expand Up @@ -949,6 +964,7 @@ test('test determinePluginsToProcess for multiple clients on different device',
generateClientIdentifier(device1, 'app'),
{
app: 'app',
app_id: 'com.facebook.flipper.app',
os: 'iOS',
device: 'TestiPhone',
device_id: 'serial1',
Expand All @@ -965,6 +981,7 @@ test('test determinePluginsToProcess for multiple clients on different device',
generateClientIdentifier(device1, 'app2'),
{
app: 'app1',
app_id: 'com.facebook.flipper.app1',
os: 'iOS',
device: 'TestiPhone',
device_id: 'serial1',
Expand All @@ -981,6 +998,7 @@ test('test determinePluginsToProcess for multiple clients on different device',
generateClientIdentifier(device2, 'app'),
{
app: 'app',
app_id: 'com.facebook.flipper.app',
os: 'iOS',
device: 'TestiPhone',
device_id: 'serial2',
Expand All @@ -997,6 +1015,7 @@ test('test determinePluginsToProcess for multiple clients on different device',
generateClientIdentifier(device2, 'app2'),
{
app: 'app1',
app_id: 'com.facebook.flipper.app1',
os: 'iOS',
device: 'TestiPhone',
device_id: 'serial2',
Expand Down Expand Up @@ -1069,6 +1088,7 @@ test('test determinePluginsToProcess to ignore archived clients', async () => {
generateClientIdentifier(selectedDevice, 'app'),
{
app: 'app',
app_id: 'com.facebook.flipper.app',
os: 'iOS',
device: 'TestiPhone',
device_id: 'serial',
Expand All @@ -1085,6 +1105,7 @@ test('test determinePluginsToProcess to ignore archived clients', async () => {
generateClientIdentifier(archivedDevice, 'app'),
{
app: 'app',
app_id: 'com.facebook.flipper.app',
os: 'iOS',
device: 'TestiPhone',
device_id: 'serial-archived',
Expand Down

0 comments on commit e4c8c99

Please sign in to comment.