From 601e2783ed4ee1b3d515d35b87af31466780e110 Mon Sep 17 00:00:00 2001 From: Boris Dibon Date: Tue, 14 Apr 2026 16:53:08 +0200 Subject: [PATCH 1/4] =?UTF-8?q?[RUM-15273]=20=F0=9F=94=8A=20Add=20telemetr?= =?UTF-8?q?y=20for=20trackResourceHeaders?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Bump rum-events-format submodule for telemetry configuration schema - Regenerate telemetry and RUM event types - Map trackResourceHeaders init value to default_headers or custom for telemetry --- .../domain/telemetry/telemetryEvent.types.ts | 4 ++ .../configuration/configuration.spec.ts | 56 ++++++++++++++++--- .../src/domain/configuration/configuration.ts | 12 ++++ packages/rum-core/src/rumEvent.types.ts | 2 + rum-events-format | 2 +- 5 files changed, 68 insertions(+), 8 deletions(-) diff --git a/packages/core/src/domain/telemetry/telemetryEvent.types.ts b/packages/core/src/domain/telemetry/telemetryEvent.types.ts index 81033d1c71..2f5be90f75 100644 --- a/packages/core/src/domain/telemetry/telemetryEvent.types.ts +++ b/packages/core/src/domain/telemetry/telemetryEvent.types.ts @@ -470,6 +470,10 @@ export type TelemetryConfigurationEvent = CommonTelemetryProperties & { * Whether trace baggage is propagated to child spans */ propagate_trace_baggage?: boolean + /** + * How the SDK tracks resource request/response headers + */ + use_track_resource_headers?: 'default_headers' | 'custom' /** * Whether the beta encode cookie options is enabled */ diff --git a/packages/rum-core/src/domain/configuration/configuration.spec.ts b/packages/rum-core/src/domain/configuration/configuration.spec.ts index 5caeef9f9f..0c686445d1 100644 --- a/packages/rum-core/src/domain/configuration/configuration.spec.ts +++ b/packages/rum-core/src/domain/configuration/configuration.spec.ts @@ -635,6 +635,43 @@ describe('validateAndBuildRumConfiguration', () => { expect(serializeRumConfiguration(wrongTracingConfig).selected_tracing_propagators).toEqual([]) }) }) + + describe('use_track_resource_headers telemetry', () => { + it('should omit use_track_resource_headers when trackResourceHeaders is undefined or false', () => { + expect(serializeRumConfiguration(DEFAULT_INIT_CONFIGURATION).use_track_resource_headers).toBeUndefined() + expect( + serializeRumConfiguration({ ...DEFAULT_INIT_CONFIGURATION, trackResourceHeaders: false }) + .use_track_resource_headers + ).toBeUndefined() + }) + + it('should set use_track_resource_headers to default_headers when trackResourceHeaders is true', () => { + expect( + serializeRumConfiguration({ ...DEFAULT_INIT_CONFIGURATION, trackResourceHeaders: true }) + .use_track_resource_headers + ).toBe('default_headers') + }) + + it('should set use_track_resource_headers to custom when trackResourceHeaders is an array', () => { + expect( + serializeRumConfiguration({ ...DEFAULT_INIT_CONFIGURATION, trackResourceHeaders: [] }) + .use_track_resource_headers + ).toBe('custom') + expect( + serializeRumConfiguration({ + ...DEFAULT_INIT_CONFIGURATION, + trackResourceHeaders: [{ name: 'x-foo' }], + }).use_track_resource_headers + ).toBe('custom') + }) + + it('should omit use_track_resource_headers when trackResourceHeaders has an unexpected type', () => { + expect( + serializeRumConfiguration({ ...DEFAULT_INIT_CONFIGURATION, trackResourceHeaders: 42 as any }) + .use_track_resource_headers + ).toBeUndefined() + }) + }) }) describe('workerUrl', () => { @@ -812,19 +849,23 @@ describe('serializeRumConfiguration', () => { ? `use_${CamelToSnakeCase}` : Key extends 'trackLongTasks' ? 'track_long_task' // We forgot the s, keeping this for backward compatibility - : // The following options are not reported as telemetry. Please avoid adding more of them. - // TODO: Add betaTrackActionsInShadowDom and trackResourceHeaders to rum-events-format telemetry schema and remove from this exclusion - Key extends 'applicationId' | 'subdomain' | 'betaTrackActionsInShadowDom' | 'trackResourceHeaders' - ? never - : CamelToSnakeCase + : Key extends 'trackResourceHeaders' + ? 'use_track_resource_headers' + : // The following options are not reported as telemetry. Please avoid adding more of them. + // TODO: Add betaTrackActionsInShadowDom to rum-events-format telemetry schema and remove from this exclusion + Key extends 'applicationId' | 'subdomain' | 'betaTrackActionsInShadowDom' + ? never + : CamelToSnakeCase // By specifying the type here, we can ensure that serializeConfiguration is returning an // object containing all expected properties. - const serializedConfiguration: ExtractTelemetryConfiguration< + const serializedConfiguration = serializeRumConfiguration( + exhaustiveRumInitConfiguration + ) as ExtractTelemetryConfiguration< | MapRumInitConfigurationKey | 'selected_tracing_propagators' | 'use_track_graph_ql_payload' | 'use_track_graph_ql_response_errors' - > = serializeRumConfiguration(exhaustiveRumInitConfiguration) + > expect(serializedConfiguration).toEqual({ ...SERIALIZED_EXHAUSTIVE_INIT_CONFIGURATION, @@ -855,6 +896,7 @@ describe('serializeRumConfiguration', () => { remote_configuration_id: '123', use_remote_configuration_proxy: true, profiling_sample_rate: 42, + use_track_resource_headers: 'default_headers', }) }) }) diff --git a/packages/rum-core/src/domain/configuration/configuration.ts b/packages/rum-core/src/domain/configuration/configuration.ts index f8277fa005..349bba5b78 100644 --- a/packages/rum-core/src/domain/configuration/configuration.ts +++ b/packages/rum-core/src/domain/configuration/configuration.ts @@ -628,6 +628,17 @@ function hasGraphQlResponseErrorsTracking(allowedGraphQlUrls: RumInitConfigurati ) } +function getTrackResourceHeadersTelemetryValue( + trackResourceHeaders: RumInitConfiguration['trackResourceHeaders'] +): 'default_headers' | 'custom' | undefined { + if (trackResourceHeaders === true) { + return 'default_headers' + } + if (Array.isArray(trackResourceHeaders)) { + return 'custom' + } +} + export function serializeRumConfiguration(configuration: RumInitConfiguration) { const baseSerializedConfiguration = serializeConfiguration(configuration) @@ -662,6 +673,7 @@ export function serializeRumConfiguration(configuration: RumInitConfiguration) { remote_configuration_id: configuration.remoteConfigurationId, profiling_sample_rate: configuration.profilingSampleRate, use_remote_configuration_proxy: !!configuration.remoteConfigurationProxy, + use_track_resource_headers: getTrackResourceHeadersTelemetryValue(configuration.trackResourceHeaders), ...baseSerializedConfiguration, } satisfies RawTelemetryConfiguration } diff --git a/packages/rum-core/src/rumEvent.types.ts b/packages/rum-core/src/rumEvent.types.ts index 04e06ab94b..fef1b42d04 100644 --- a/packages/rum-core/src/rumEvent.types.ts +++ b/packages/rum-core/src/rumEvent.types.ts @@ -1732,6 +1732,8 @@ export interface ViewProperties { | 'fragment_redisplay' | 'view_controller_display' | 'view_controller_redisplay' + | 'session_renewal' + | 'bf_cache' /** * Time spent on the view in ns */ diff --git a/rum-events-format b/rum-events-format index 5a80fb9a3c..0cbc687015 160000 --- a/rum-events-format +++ b/rum-events-format @@ -1 +1 @@ -Subproject commit 5a80fb9a3c054b28fba195fd301cadb094bccef8 +Subproject commit 0cbc6870157a030ad73643d1e08cbab3c226d533 From fa0f464888cc4eac927d763d58a62b4e5b83821c Mon Sep 17 00:00:00 2001 From: Boris Dibon Date: Fri, 17 Apr 2026 10:41:33 +0200 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=91=8C=20Use=20types=20properly?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../configuration/configuration.spec.ts | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/packages/rum-core/src/domain/configuration/configuration.spec.ts b/packages/rum-core/src/domain/configuration/configuration.spec.ts index 0c686445d1..9fdeb378b4 100644 --- a/packages/rum-core/src/domain/configuration/configuration.spec.ts +++ b/packages/rum-core/src/domain/configuration/configuration.spec.ts @@ -846,26 +846,23 @@ describe('serializeRumConfiguration', () => { | 'excludedActivityUrls' | 'remoteConfigurationProxy' | 'allowedGraphQlUrls' + | 'trackResourceHeaders' ? `use_${CamelToSnakeCase}` : Key extends 'trackLongTasks' ? 'track_long_task' // We forgot the s, keeping this for backward compatibility - : Key extends 'trackResourceHeaders' - ? 'use_track_resource_headers' - : // The following options are not reported as telemetry. Please avoid adding more of them. - // TODO: Add betaTrackActionsInShadowDom to rum-events-format telemetry schema and remove from this exclusion - Key extends 'applicationId' | 'subdomain' | 'betaTrackActionsInShadowDom' - ? never - : CamelToSnakeCase + : // The following options are not reported as telemetry. Please avoid adding more of them. + // TODO: Add betaTrackActionsInShadowDom to rum-events-format telemetry schema and remove from this exclusion + Key extends 'applicationId' | 'subdomain' | 'betaTrackActionsInShadowDom' + ? never + : CamelToSnakeCase // By specifying the type here, we can ensure that serializeConfiguration is returning an // object containing all expected properties. - const serializedConfiguration = serializeRumConfiguration( - exhaustiveRumInitConfiguration - ) as ExtractTelemetryConfiguration< + const serializedConfiguration: ExtractTelemetryConfiguration< | MapRumInitConfigurationKey | 'selected_tracing_propagators' | 'use_track_graph_ql_payload' | 'use_track_graph_ql_response_errors' - > + > = serializeRumConfiguration(exhaustiveRumInitConfiguration) expect(serializedConfiguration).toEqual({ ...SERIALIZED_EXHAUSTIVE_INIT_CONFIGURATION, From e6316c1afab950da6cdea1d3724807b031c0b6a1 Mon Sep 17 00:00:00 2001 From: Boris Dibon Date: Mon, 20 Apr 2026 13:58:44 +0200 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=91=8C=20Remove=20use=5F=20prefix=20t?= =?UTF-8?q?hat=20broke=20convention?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AGENTS.md | 1 + .../domain/telemetry/telemetryEvent.types.ts | 4 +-- .../configuration/configuration.spec.ts | 26 +++++++++---------- .../src/domain/configuration/configuration.ts | 3 ++- packages/rum-core/src/rumEvent.types.ts | 4 +-- rum-events-format | 2 +- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index fdf86406a0..a65a8d2ccb 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -106,6 +106,7 @@ For deeper context, see: - `addTelemetryUsage` tracks **which public API the customer calls and which options they pass** (static call-site information) - Do NOT include runtime state analysis (e.g., whether a view was active, whether a value was overwritten) in telemetry usage — that belongs elsewhere +- In serialized telemetry configuration, the `use_` prefix is reserved for boolean fields that track whether a complex configuration option is used (e.g. `use_allowed_tracing_urls`) ### Auto-Generated Files diff --git a/packages/core/src/domain/telemetry/telemetryEvent.types.ts b/packages/core/src/domain/telemetry/telemetryEvent.types.ts index 2f5be90f75..b3dd7be5c6 100644 --- a/packages/core/src/domain/telemetry/telemetryEvent.types.ts +++ b/packages/core/src/domain/telemetry/telemetryEvent.types.ts @@ -473,7 +473,7 @@ export type TelemetryConfigurationEvent = CommonTelemetryProperties & { /** * How the SDK tracks resource request/response headers */ - use_track_resource_headers?: 'default_headers' | 'custom' + track_resource_headers?: 'default_headers' | 'custom' /** * Whether the beta encode cookie options is enabled */ @@ -985,6 +985,6 @@ export interface AndroidNetworkInstrumentation { /** * The network instrumentation API used */ - type: 'CRONET' | 'OKHTTP' + type: 'CRONET' | 'OKHTTP' | 'LEGACY_OKHTTP' [k: string]: unknown } diff --git a/packages/rum-core/src/domain/configuration/configuration.spec.ts b/packages/rum-core/src/domain/configuration/configuration.spec.ts index 9fdeb378b4..95a513395f 100644 --- a/packages/rum-core/src/domain/configuration/configuration.spec.ts +++ b/packages/rum-core/src/domain/configuration/configuration.spec.ts @@ -636,39 +636,38 @@ describe('validateAndBuildRumConfiguration', () => { }) }) - describe('use_track_resource_headers telemetry', () => { - it('should omit use_track_resource_headers when trackResourceHeaders is undefined or false', () => { - expect(serializeRumConfiguration(DEFAULT_INIT_CONFIGURATION).use_track_resource_headers).toBeUndefined() + describe('track_resource_headers telemetry', () => { + it('should omit track_resource_headers when trackResourceHeaders is undefined or false', () => { + expect(serializeRumConfiguration(DEFAULT_INIT_CONFIGURATION).track_resource_headers).toBeUndefined() expect( serializeRumConfiguration({ ...DEFAULT_INIT_CONFIGURATION, trackResourceHeaders: false }) - .use_track_resource_headers + .track_resource_headers ).toBeUndefined() }) - it('should set use_track_resource_headers to default_headers when trackResourceHeaders is true', () => { + it('should set track_resource_headers to default_headers when trackResourceHeaders is true', () => { expect( serializeRumConfiguration({ ...DEFAULT_INIT_CONFIGURATION, trackResourceHeaders: true }) - .use_track_resource_headers + .track_resource_headers ).toBe('default_headers') }) - it('should set use_track_resource_headers to custom when trackResourceHeaders is an array', () => { + it('should set track_resource_headers to custom when trackResourceHeaders is an array', () => { expect( - serializeRumConfiguration({ ...DEFAULT_INIT_CONFIGURATION, trackResourceHeaders: [] }) - .use_track_resource_headers + serializeRumConfiguration({ ...DEFAULT_INIT_CONFIGURATION, trackResourceHeaders: [] }).track_resource_headers ).toBe('custom') expect( serializeRumConfiguration({ ...DEFAULT_INIT_CONFIGURATION, trackResourceHeaders: [{ name: 'x-foo' }], - }).use_track_resource_headers + }).track_resource_headers ).toBe('custom') }) - it('should omit use_track_resource_headers when trackResourceHeaders has an unexpected type', () => { + it('should omit track_resource_headers when trackResourceHeaders has an unexpected type', () => { expect( serializeRumConfiguration({ ...DEFAULT_INIT_CONFIGURATION, trackResourceHeaders: 42 as any }) - .use_track_resource_headers + .track_resource_headers ).toBeUndefined() }) }) @@ -846,7 +845,6 @@ describe('serializeRumConfiguration', () => { | 'excludedActivityUrls' | 'remoteConfigurationProxy' | 'allowedGraphQlUrls' - | 'trackResourceHeaders' ? `use_${CamelToSnakeCase}` : Key extends 'trackLongTasks' ? 'track_long_task' // We forgot the s, keeping this for backward compatibility @@ -893,7 +891,7 @@ describe('serializeRumConfiguration', () => { remote_configuration_id: '123', use_remote_configuration_proxy: true, profiling_sample_rate: 42, - use_track_resource_headers: 'default_headers', + track_resource_headers: 'default_headers', }) }) }) diff --git a/packages/rum-core/src/domain/configuration/configuration.ts b/packages/rum-core/src/domain/configuration/configuration.ts index 349bba5b78..45c9203261 100644 --- a/packages/rum-core/src/domain/configuration/configuration.ts +++ b/packages/rum-core/src/domain/configuration/configuration.ts @@ -642,6 +642,7 @@ function getTrackResourceHeadersTelemetryValue( export function serializeRumConfiguration(configuration: RumInitConfiguration) { const baseSerializedConfiguration = serializeConfiguration(configuration) + // `use_` prefix is for boolean telemetry options that track complex configuration options return { session_replay_sample_rate: configuration.sessionReplaySampleRate, start_session_replay_recording_manually: configuration.startSessionReplayRecordingManually, @@ -673,7 +674,7 @@ export function serializeRumConfiguration(configuration: RumInitConfiguration) { remote_configuration_id: configuration.remoteConfigurationId, profiling_sample_rate: configuration.profilingSampleRate, use_remote_configuration_proxy: !!configuration.remoteConfigurationProxy, - use_track_resource_headers: getTrackResourceHeadersTelemetryValue(configuration.trackResourceHeaders), + track_resource_headers: getTrackResourceHeadersTelemetryValue(configuration.trackResourceHeaders), ...baseSerializedConfiguration, } satisfies RawTelemetryConfiguration } diff --git a/packages/rum-core/src/rumEvent.types.ts b/packages/rum-core/src/rumEvent.types.ts index fef1b42d04..2cccc7f9ba 100644 --- a/packages/rum-core/src/rumEvent.types.ts +++ b/packages/rum-core/src/rumEvent.types.ts @@ -862,7 +862,7 @@ export type RumResourceEvent = CommonProperties & /** * HTTP headers of the resource request */ - readonly headers?: { + headers?: { [k: string]: string } [k: string]: unknown @@ -874,7 +874,7 @@ export type RumResourceEvent = CommonProperties & /** * HTTP headers of the resource response */ - readonly headers?: { + headers?: { [k: string]: string } [k: string]: unknown diff --git a/rum-events-format b/rum-events-format index 0cbc687015..4f4ab2c504 160000 --- a/rum-events-format +++ b/rum-events-format @@ -1 +1 @@ -Subproject commit 0cbc6870157a030ad73643d1e08cbab3c226d533 +Subproject commit 4f4ab2c50456d688ae228904ced4c68aa382ae4c From ac7366b8918562e4aa24ecd035f3aa3f6e480bb9 Mon Sep 17 00:00:00 2001 From: Boris Dibon Date: Tue, 21 Apr 2026 10:20:32 +0200 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=91=8C=20Clarify=20wording=20on=20use?= =?UTF-8?q?=5F=20prefix=20usage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AGENTS.md | 2 +- packages/rum-core/src/domain/configuration/configuration.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index a65a8d2ccb..04bd6cb440 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -106,7 +106,7 @@ For deeper context, see: - `addTelemetryUsage` tracks **which public API the customer calls and which options they pass** (static call-site information) - Do NOT include runtime state analysis (e.g., whether a view was active, whether a value was overwritten) in telemetry usage — that belongs elsewhere -- In serialized telemetry configuration, the `use_` prefix is reserved for boolean fields that track whether a complex configuration option is used (e.g. `use_allowed_tracing_urls`) +- In serialized telemetry configuration, the `use_` prefix is reserved for boolean fields that track the usage of a configuration option that might contain customer data (e.g. `use_allowed_tracing_urls`) ### Auto-Generated Files diff --git a/packages/rum-core/src/domain/configuration/configuration.ts b/packages/rum-core/src/domain/configuration/configuration.ts index 45c9203261..89b7a02365 100644 --- a/packages/rum-core/src/domain/configuration/configuration.ts +++ b/packages/rum-core/src/domain/configuration/configuration.ts @@ -642,7 +642,7 @@ function getTrackResourceHeadersTelemetryValue( export function serializeRumConfiguration(configuration: RumInitConfiguration) { const baseSerializedConfiguration = serializeConfiguration(configuration) - // `use_` prefix is for boolean telemetry options that track complex configuration options + // `use_` prefix is for telemetry options that track usage of a configuration option as a boolean to avoid capturing customer data return { session_replay_sample_rate: configuration.sessionReplaySampleRate, start_session_replay_recording_manually: configuration.startSessionReplayRecordingManually,