Skip to content

Commit bc635fa

Browse files
authored
add entrypoint and appId to analytics (#158)
1 parent cca2c66 commit bc635fa

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

front_end/core/host/RNPerfMetrics.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ class RNPerfMetrics {
2424
readonly #consoleErrorMethod = 'error';
2525
#listeners: Set<RNReliabilityEventListener> = new Set();
2626
#launchId: string|null = null;
27+
#appId: string|null = null;
28+
#entryPoint: EntryPoint = 'rn_inspector';
2729
#telemetryInfo: Object = {};
2830
// map of panel location to panel name
2931
#currentPanels: Map<PanelLocation, string> = new Map();
@@ -120,11 +122,17 @@ class RNPerfMetrics {
120122
this.#launchId = launchId;
121123
}
122124

125+
setAppId(appId: string|null): void {
126+
this.#appId = appId;
127+
}
128+
123129
setTelemetryInfo(telemetryInfo: Object): void {
124130
this.#telemetryInfo = telemetryInfo;
125131
}
126132

127133
entryPointLoadingStarted(entryPoint: EntryPoint): void {
134+
this.#entryPoint = entryPoint;
135+
128136
this.sendEvent({
129137
eventName: 'Entrypoint.LoadingStarted',
130138
entryPoint,
@@ -268,6 +276,8 @@ class RNPerfMetrics {
268276
const commonFields: CommonEventFields = {
269277
timestamp: getPerfTimestamp(),
270278
launchId: this.#launchId,
279+
appId: this.#appId,
280+
entryPoint: this.#entryPoint,
271281
telemetryInfo: this.#telemetryInfo,
272282
currentPanels: this.#currentPanels,
273283
};
@@ -298,15 +308,17 @@ function maybeWrapError(baseMessage: string, error: unknown): [string, Error] {
298308
return [message, new Error(message, {cause: error})];
299309
}
300310

311+
type EntryPoint = 'rn_fusebox'|'rn_inspector';
312+
301313
type CommonEventFields = Readonly<{
302314
timestamp: DOMHighResTimeStamp,
303315
launchId: string | void | null,
316+
appId: string | void | null,
317+
entryPoint: EntryPoint,
304318
telemetryInfo: Object,
305319
currentPanels: Map<PanelLocation, string>,
306320
}>;
307321

308-
type EntryPoint = 'rn_fusebox'|'rn_inspector';
309-
310322
export type EntrypointLoadingStartedEvent = Readonly<{
311323
eventName: 'Entrypoint.LoadingStarted',
312324
entryPoint: EntryPoint,

front_end/entrypoints/rn_fusebox/rn_fusebox.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import type * as Sources from '../../panels/sources/sources.js';
3535
Host.rnPerfMetrics.registerPerfMetricsGlobalPostMessageHandler();
3636
Host.rnPerfMetrics.registerGlobalErrorReporting();
3737
Host.rnPerfMetrics.setLaunchId(Root.Runtime.Runtime.queryParam('launchId'));
38+
Host.rnPerfMetrics.setAppId(Root.Runtime.Runtime.queryParam('appId'));
3839
Host.rnPerfMetrics.setTelemetryInfo(JSON.parse(Root.Runtime.Runtime.queryParam('telemetryInfo') || '{}'));
3940
Host.rnPerfMetrics.entryPointLoadingStarted('rn_fusebox');
4041

front_end/entrypoints/rn_inspector/rn_inspector.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import * as Host from '../../core/host/host.js';
2828
*/
2929
Host.rnPerfMetrics.registerPerfMetricsGlobalPostMessageHandler();
3030
Host.rnPerfMetrics.setLaunchId(Root.Runtime.Runtime.queryParam('launchId'));
31+
Host.rnPerfMetrics.setAppId(Root.Runtime.Runtime.queryParam('appId'));
3132
Host.rnPerfMetrics.setTelemetryInfo(JSON.parse(Root.Runtime.Runtime.queryParam('telemetryInfo') || '{}'));
3233
Host.rnPerfMetrics.entryPointLoadingStarted('rn_inspector');
3334

0 commit comments

Comments
 (0)