Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('getDevToolsFrontendUrl', () => {
enableOpenDebuggerRedirect: false,
};

describe('relative: false, launchId: undefined (default)', () => {
describe('relative: false, launchId: undefined, telemetryInfo: undefined, (default)', () => {
test('should return a valid url for all experiments off', async () => {
const actual = getDevToolsFrontendUrl(
experiments,
Expand Down Expand Up @@ -128,16 +128,22 @@ describe('getDevToolsFrontendUrl', () => {
});
});

describe('launchId: non-null', () => {
describe('non-null launchId and telemetryInfo', () => {
const launchId = 'dG8gdGhlIG1vb24h%21';

const telemetryInfo = JSON.stringify({
username: 'testuser123',
reactTechnologiesDeveloper: true,
});

test('should return a valid url for all experiments off', async () => {
const actual = getDevToolsFrontendUrl(
experiments,
webSocketDebuggerUrl,
devServerUrl,
{
launchId,
telemetryInfo,
},
);
const url = new URL(actual);
Expand All @@ -146,6 +152,9 @@ describe('getDevToolsFrontendUrl', () => {
'/inspector/debug?device=1a9372c&page=-1',
);
expect(url.searchParams.get('launchId')).toBe(launchId);
expect(JSON.parse(url.searchParams.get('telemetryInfo') || '{}')).toEqual(
JSON.parse(telemetryInfo),
);
});

test('should return a valid url for enableNetworkInspector experiment on', async () => {
Expand All @@ -155,6 +164,7 @@ describe('getDevToolsFrontendUrl', () => {
devServerUrl,
{
launchId,
telemetryInfo,
},
);
const url = new URL(actual);
Expand All @@ -164,6 +174,9 @@ describe('getDevToolsFrontendUrl', () => {
'/inspector/debug?device=1a9372c&page=-1',
);
expect(url.searchParams.get('launchId')).toBe(launchId);
expect(JSON.parse(url.searchParams.get('telemetryInfo') || '{}')).toEqual(
JSON.parse(telemetryInfo),
);
});

test('should return a full WS URL if on a different host than the dev server', () => {
Expand All @@ -175,13 +188,17 @@ describe('getDevToolsFrontendUrl', () => {
devServerUrl,
{
launchId,
telemetryInfo,
},
);
const url = new URL(actual);
expect(url.searchParams.get('ws')).toBe(
'localhost:8082/inspector/debug?device=1a9372c&page=-1',
);
expect(url.searchParams.get('launchId')).toBe(launchId);
expect(JSON.parse(url.searchParams.get('telemetryInfo') || '{}')).toEqual(
JSON.parse(telemetryInfo),
);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export default function openDebuggerMiddleware({
/** @deprecated Will only match legacy Hermes targets */
device?: string,
launchId?: string,
telemetryInfo?: string,
target?: string,
...
} = paresedUrl.query;
Expand Down Expand Up @@ -146,7 +147,12 @@ export default function openDebuggerMiddleware({
experiments,
target.webSocketDebuggerUrl,
serverBaseUrl,
{launchId: query.launchId, useFuseboxEntryPoint},
{
launchId: query.launchId,
telemetryInfo: query.telemetryInfo,
appId: target.appId,
useFuseboxEntryPoint,
},
),
);
res.writeHead(200);
Expand All @@ -161,6 +167,8 @@ export default function openDebuggerMiddleware({
{
relative: true,
launchId: query.launchId,
telemetryInfo: query.telemetryInfo,
appId: target.appId,
useFuseboxEntryPoint,
},
),
Expand Down
8 changes: 8 additions & 0 deletions packages/dev-middleware/src/utils/getDevToolsFrontendUrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ export default function getDevToolsFrontendUrl(
options?: $ReadOnly<{
relative?: boolean,
launchId?: string,
telemetryInfo?: string,
/** Whether to use the modern `rn_fusebox.html` entry point. */
useFuseboxEntryPoint?: boolean,
appId?: string,
}>,
): string {
const wsParam = getWsParam({
Expand All @@ -47,6 +49,12 @@ export default function getDevToolsFrontendUrl(
if (options?.launchId != null && options.launchId !== '') {
searchParams.append('launchId', options.launchId);
}
if (options?.appId != null && options.appId !== '') {
searchParams.append('appId', options.appId);
}
if (options?.telemetryInfo != null && options.telemetryInfo !== '') {
searchParams.append('telemetryInfo', options.telemetryInfo);
}

return appUrl + '?' + searchParams.toString();
}
Expand Down
Loading