Skip to content

Commit 3436f87

Browse files
vzaidmanfacebook-github-bot
authored andcommitted
react native devtools extra telemetry
Summary: Changelog: [Internal][General] the debugger can now be opened with the query param "telemetryInfo" Corresponding PR on debugger: facebook/react-native-devtools-frontend#157 Reviewed By: huntie Differential Revision: D72972397
1 parent 44c274a commit 3436f87

3 files changed

Lines changed: 36 additions & 3 deletions

File tree

packages/dev-middleware/src/__tests__/getDevToolsFrontendUrl-test.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('getDevToolsFrontendUrl', () => {
2121
enableOpenDebuggerRedirect: false,
2222
};
2323

24-
describe('relative: false, launchId: undefined (default)', () => {
24+
describe('relative: false, launchId: undefined, telemetryInfo: undefined, (default)', () => {
2525
test('should return a valid url for all experiments off', async () => {
2626
const actual = getDevToolsFrontendUrl(
2727
experiments,
@@ -128,16 +128,22 @@ describe('getDevToolsFrontendUrl', () => {
128128
});
129129
});
130130

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

134+
const telemetryInfo = JSON.stringify({
135+
username: 'testuser123',
136+
reactTechnologiesDeveloper: true,
137+
});
138+
134139
test('should return a valid url for all experiments off', async () => {
135140
const actual = getDevToolsFrontendUrl(
136141
experiments,
137142
webSocketDebuggerUrl,
138143
devServerUrl,
139144
{
140145
launchId,
146+
telemetryInfo,
141147
},
142148
);
143149
const url = new URL(actual);
@@ -146,6 +152,9 @@ describe('getDevToolsFrontendUrl', () => {
146152
'/inspector/debug?device=1a9372c&page=-1',
147153
);
148154
expect(url.searchParams.get('launchId')).toBe(launchId);
155+
expect(JSON.parse(url.searchParams.get('telemetryInfo') || '{}')).toEqual(
156+
JSON.parse(telemetryInfo),
157+
);
149158
});
150159

151160
test('should return a valid url for enableNetworkInspector experiment on', async () => {
@@ -155,6 +164,7 @@ describe('getDevToolsFrontendUrl', () => {
155164
devServerUrl,
156165
{
157166
launchId,
167+
telemetryInfo,
158168
},
159169
);
160170
const url = new URL(actual);
@@ -164,6 +174,9 @@ describe('getDevToolsFrontendUrl', () => {
164174
'/inspector/debug?device=1a9372c&page=-1',
165175
);
166176
expect(url.searchParams.get('launchId')).toBe(launchId);
177+
expect(JSON.parse(url.searchParams.get('telemetryInfo') || '{}')).toEqual(
178+
JSON.parse(telemetryInfo),
179+
);
167180
});
168181

169182
test('should return a full WS URL if on a different host than the dev server', () => {
@@ -175,13 +188,17 @@ describe('getDevToolsFrontendUrl', () => {
175188
devServerUrl,
176189
{
177190
launchId,
191+
telemetryInfo,
178192
},
179193
);
180194
const url = new URL(actual);
181195
expect(url.searchParams.get('ws')).toBe(
182196
'localhost:8082/inspector/debug?device=1a9372c&page=-1',
183197
);
184198
expect(url.searchParams.get('launchId')).toBe(launchId);
199+
expect(JSON.parse(url.searchParams.get('telemetryInfo') || '{}')).toEqual(
200+
JSON.parse(telemetryInfo),
201+
);
185202
});
186203
});
187204

packages/dev-middleware/src/middleware/openDebuggerMiddleware.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export default function openDebuggerMiddleware({
6565
/** @deprecated Will only match legacy Hermes targets */
6666
device?: string,
6767
launchId?: string,
68+
telemetryInfo?: string,
6869
target?: string,
6970
...
7071
} = paresedUrl.query;
@@ -146,7 +147,12 @@ export default function openDebuggerMiddleware({
146147
experiments,
147148
target.webSocketDebuggerUrl,
148149
serverBaseUrl,
149-
{launchId: query.launchId, useFuseboxEntryPoint},
150+
{
151+
launchId: query.launchId,
152+
telemetryInfo: query.telemetryInfo,
153+
appId: target.appId,
154+
useFuseboxEntryPoint,
155+
},
150156
),
151157
);
152158
res.writeHead(200);
@@ -161,6 +167,8 @@ export default function openDebuggerMiddleware({
161167
{
162168
relative: true,
163169
launchId: query.launchId,
170+
telemetryInfo: query.telemetryInfo,
171+
appId: target.appId,
164172
useFuseboxEntryPoint,
165173
},
166174
),

packages/dev-middleware/src/utils/getDevToolsFrontendUrl.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ export default function getDevToolsFrontendUrl(
2121
options?: $ReadOnly<{
2222
relative?: boolean,
2323
launchId?: string,
24+
telemetryInfo?: string,
2425
/** Whether to use the modern `rn_fusebox.html` entry point. */
2526
useFuseboxEntryPoint?: boolean,
27+
appId?: string,
2628
}>,
2729
): string {
2830
const wsParam = getWsParam({
@@ -47,6 +49,12 @@ export default function getDevToolsFrontendUrl(
4749
if (options?.launchId != null && options.launchId !== '') {
4850
searchParams.append('launchId', options.launchId);
4951
}
52+
if (options?.appId != null && options.appId !== '') {
53+
searchParams.append('appId', options.appId);
54+
}
55+
if (options?.telemetryInfo != null && options.telemetryInfo !== '') {
56+
searchParams.append('telemetryInfo', options.telemetryInfo);
57+
}
5058

5159
return appUrl + '?' + searchParams.toString();
5260
}

0 commit comments

Comments
 (0)