Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion packages/core/src/domain/telemetry/telemetryEvent.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -981,6 +985,6 @@ export interface AndroidNetworkInstrumentation {
/**
* The network instrumentation API used
*/
type: 'CRONET' | 'OKHTTP'
type: 'CRONET' | 'OKHTTP' | 'LEGACY_OKHTTP'
[k: string]: unknown
}
41 changes: 39 additions & 2 deletions packages/rum-core/src/domain/configuration/configuration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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<Key>
// By specifying the type here, we can ensure that serializeConfiguration is returning an
Expand Down Expand Up @@ -855,6 +891,7 @@ describe('serializeRumConfiguration', () => {
remote_configuration_id: '123',
use_remote_configuration_proxy: true,
profiling_sample_rate: 42,
track_resource_headers: 'default_headers',
})
})
})
13 changes: 13 additions & 0 deletions packages/rum-core/src/domain/configuration/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
}
6 changes: 4 additions & 2 deletions packages/rum-core/src/rumEvent.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ export type RumResourceEvent = CommonProperties &
/**
* HTTP headers of the resource request
*/
readonly headers?: {
headers?: {
[k: string]: string
}
[k: string]: unknown
Expand All @@ -874,7 +874,7 @@ export type RumResourceEvent = CommonProperties &
/**
* HTTP headers of the resource response
*/
readonly headers?: {
headers?: {
[k: string]: string
}
[k: string]: unknown
Expand Down Expand Up @@ -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
*/
Expand Down
Loading