From d0161e2cd5b4ede3a9efd5fbad9345bc44b16229 Mon Sep 17 00:00:00 2001 From: Vitali Zaidman Date: Wed, 16 Apr 2025 11:18:32 +0100 Subject: [PATCH] add entrypoint and appId to analytics --- front_end/core/host/RNPerfMetrics.ts | 16 ++++++++++++++-- front_end/entrypoints/rn_fusebox/rn_fusebox.ts | 1 + .../entrypoints/rn_inspector/rn_inspector.ts | 1 + 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/front_end/core/host/RNPerfMetrics.ts b/front_end/core/host/RNPerfMetrics.ts index 9dd4d7dee9d8..86f3dd96517a 100644 --- a/front_end/core/host/RNPerfMetrics.ts +++ b/front_end/core/host/RNPerfMetrics.ts @@ -24,6 +24,8 @@ class RNPerfMetrics { readonly #consoleErrorMethod = 'error'; #listeners: Set = new Set(); #launchId: string|null = null; + #appId: string|null = null; + #entryPoint: EntryPoint = 'rn_inspector'; #telemetryInfo: Object = {}; // map of panel location to panel name #currentPanels: Map = new Map(); @@ -120,11 +122,17 @@ class RNPerfMetrics { this.#launchId = launchId; } + setAppId(appId: string|null): void { + this.#appId = appId; + } + setTelemetryInfo(telemetryInfo: Object): void { this.#telemetryInfo = telemetryInfo; } entryPointLoadingStarted(entryPoint: EntryPoint): void { + this.#entryPoint = entryPoint; + this.sendEvent({ eventName: 'Entrypoint.LoadingStarted', entryPoint, @@ -268,6 +276,8 @@ class RNPerfMetrics { const commonFields: CommonEventFields = { timestamp: getPerfTimestamp(), launchId: this.#launchId, + appId: this.#appId, + entryPoint: this.#entryPoint, telemetryInfo: this.#telemetryInfo, currentPanels: this.#currentPanels, }; @@ -298,15 +308,17 @@ function maybeWrapError(baseMessage: string, error: unknown): [string, Error] { return [message, new Error(message, {cause: error})]; } +type EntryPoint = 'rn_fusebox'|'rn_inspector'; + type CommonEventFields = Readonly<{ timestamp: DOMHighResTimeStamp, launchId: string | void | null, + appId: string | void | null, + entryPoint: EntryPoint, telemetryInfo: Object, currentPanels: Map, }>; -type EntryPoint = 'rn_fusebox'|'rn_inspector'; - export type EntrypointLoadingStartedEvent = Readonly<{ eventName: 'Entrypoint.LoadingStarted', entryPoint: EntryPoint, diff --git a/front_end/entrypoints/rn_fusebox/rn_fusebox.ts b/front_end/entrypoints/rn_fusebox/rn_fusebox.ts index 53b50060f135..16278e3f4283 100644 --- a/front_end/entrypoints/rn_fusebox/rn_fusebox.ts +++ b/front_end/entrypoints/rn_fusebox/rn_fusebox.ts @@ -35,6 +35,7 @@ import type * as Sources from '../../panels/sources/sources.js'; Host.rnPerfMetrics.registerPerfMetricsGlobalPostMessageHandler(); Host.rnPerfMetrics.registerGlobalErrorReporting(); Host.rnPerfMetrics.setLaunchId(Root.Runtime.Runtime.queryParam('launchId')); +Host.rnPerfMetrics.setAppId(Root.Runtime.Runtime.queryParam('appId')); Host.rnPerfMetrics.setTelemetryInfo(JSON.parse(Root.Runtime.Runtime.queryParam('telemetryInfo') || '{}')); Host.rnPerfMetrics.entryPointLoadingStarted('rn_fusebox'); diff --git a/front_end/entrypoints/rn_inspector/rn_inspector.ts b/front_end/entrypoints/rn_inspector/rn_inspector.ts index cf3824adf55e..0b7f92a8e2e9 100644 --- a/front_end/entrypoints/rn_inspector/rn_inspector.ts +++ b/front_end/entrypoints/rn_inspector/rn_inspector.ts @@ -28,6 +28,7 @@ import * as Host from '../../core/host/host.js'; */ Host.rnPerfMetrics.registerPerfMetricsGlobalPostMessageHandler(); Host.rnPerfMetrics.setLaunchId(Root.Runtime.Runtime.queryParam('launchId')); +Host.rnPerfMetrics.setAppId(Root.Runtime.Runtime.queryParam('appId')); Host.rnPerfMetrics.setTelemetryInfo(JSON.parse(Root.Runtime.Runtime.queryParam('telemetryInfo') || '{}')); Host.rnPerfMetrics.entryPointLoadingStarted('rn_inspector');