diff --git a/AGENTS.md b/AGENTS.md index fdf86406a0..04bd6cb440 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 the usage of a configuration option that might contain customer data (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 81033d1c71..b3dd7be5c6 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 + */ + track_resource_headers?: 'default_headers' | 'custom' /** * Whether the beta encode cookie options is enabled */ @@ -981,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 5caeef9f9f..95a513395f 100644 --- a/packages/rum-core/src/domain/configuration/configuration.spec.ts +++ b/packages/rum-core/src/domain/configuration/configuration.spec.ts @@ -635,6 +635,42 @@ describe('validateAndBuildRumConfiguration', () => { expect(serializeRumConfiguration(wrongTracingConfig).selected_tracing_propagators).toEqual([]) }) }) + + 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 }) + .track_resource_headers + ).toBeUndefined() + }) + + it('should set track_resource_headers to default_headers when trackResourceHeaders is true', () => { + expect( + serializeRumConfiguration({ ...DEFAULT_INIT_CONFIGURATION, trackResourceHeaders: true }) + .track_resource_headers + ).toBe('default_headers') + }) + + it('should set track_resource_headers to custom when trackResourceHeaders is an array', () => { + expect( + serializeRumConfiguration({ ...DEFAULT_INIT_CONFIGURATION, trackResourceHeaders: [] }).track_resource_headers + ).toBe('custom') + expect( + serializeRumConfiguration({ + ...DEFAULT_INIT_CONFIGURATION, + trackResourceHeaders: [{ name: 'x-foo' }], + }).track_resource_headers + ).toBe('custom') + }) + + it('should omit track_resource_headers when trackResourceHeaders has an unexpected type', () => { + expect( + serializeRumConfiguration({ ...DEFAULT_INIT_CONFIGURATION, trackResourceHeaders: 42 as any }) + .track_resource_headers + ).toBeUndefined() + }) + }) }) describe('workerUrl', () => { @@ -813,8 +849,8 @@ describe('serializeRumConfiguration', () => { : 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' + // 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 @@ -855,6 +891,7 @@ describe('serializeRumConfiguration', () => { remote_configuration_id: '123', use_remote_configuration_proxy: true, profiling_sample_rate: 42, + 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..89b7a02365 100644 --- a/packages/rum-core/src/domain/configuration/configuration.ts +++ b/packages/rum-core/src/domain/configuration/configuration.ts @@ -628,9 +628,21 @@ 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) + // `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, @@ -662,6 +674,7 @@ export function serializeRumConfiguration(configuration: RumInitConfiguration) { remote_configuration_id: configuration.remoteConfigurationId, profiling_sample_rate: configuration.profilingSampleRate, use_remote_configuration_proxy: !!configuration.remoteConfigurationProxy, + 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..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 @@ -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..4f4ab2c504 160000 --- a/rum-events-format +++ b/rum-events-format @@ -1 +1 @@ -Subproject commit 5a80fb9a3c054b28fba195fd301cadb094bccef8 +Subproject commit 4f4ab2c50456d688ae228904ced4c68aa382ae4c