Skip to content
Merged
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 developer-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@datadog/browser-core": "workspace:*",
"@datadog/browser-logs": "workspace:*",
"@datadog/browser-rum": "workspace:*",
"@datadog/browser-rum-core": "workspace:*",
"@mantine/core": "8.3.15",
"@mantine/hooks": "8.3.15",
"@tabler/icons-react": "3.36.1",
Expand Down
13 changes: 10 additions & 3 deletions developer-extension/src/panel/components/tabs/infosTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { ReactNode } from 'react'
import React, { useState } from 'react'
import { evalInWindow } from '../../evalInWindow'
import { useSdkInfos } from '../../hooks/useSdkInfos'
import { computeLogsTrackingType, computeRumTrackingType } from '../../sampler'
import { Columns } from '../columns'
import type { JsonValueDescriptor } from '../json'
import { Json } from '../json'
Expand Down Expand Up @@ -78,6 +79,12 @@ export function InfosTab() {

const sessionId = infos.cookie?.id

const logsTrackingType =
infos.cookie?.logs ?? (sessionId && infos.logs?.config && computeLogsTrackingType(sessionId, infos.logs.config))

const rumTrackingType =
infos.cookie?.rum ?? (sessionId && infos.rum?.config && computeRumTrackingType(sessionId, infos.rum.config))
Comment on lines +82 to +86
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Show "Not tracked" when v7 session has no id

The new fallback only computes logsTrackingType/rumTrackingType when sessionId is present. For sampled-out sessions, the SDK does not persist a session id (the session store only assigns id for tracked sessions), so in v7 environments where cookie logs/rum fields are removed this leaves both values undefined and the Infos tab displays empty values instead of Not tracked. This will affect any deployment using sessionSampleRate < 100.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not an issue — SDK v7 still writes the session ID to the cookie for all sessions (tracked and untracked). When a session is sampled out, the ID is present in the cookie but the logs/rum fields are absent. In that case, sessionId will be defined, computeLogsTrackingType/computeRumTrackingType will run, and they will correctly return '0' (not tracked).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use effective RUM sampling rates for fallback computation

This recomputation relies on infos.rum.config, which is read from DD_RUM.getInitConfiguration(); that API returns the original init config and does not include remote-configuration overrides applied at startup. If remote config changes sessionSampleRate or sessionReplaySampleRate, the extension will compute a deterministic tracking type that can differ from the active SDK decision, so the displayed RUM tracking status becomes incorrect in remote-config-enabled setups.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not an issue — getInitConfiguration() already includes remote config overrides. When remote config is applied, the SDK merges the overrides into a copy of the init configuration and stores that as cachedInitConfiguration, which is what getInitConfiguration() returns. So infos.rum.config reflects the effective sample rates.


return (
<TabBase>
<Columns>
Expand All @@ -87,14 +94,14 @@ export function InfosTab() {
<Entry name="Id" value={infos.cookie.id} />
<Entry
name="Logs"
value={infos.cookie.logs && formatSessionType(infos.cookie.logs, 'Not tracked', 'Tracked')}
value={logsTrackingType && formatSessionType(logsTrackingType, 'Not tracked', 'Tracked')}
/>
<Entry
name="RUM"
value={
infos.cookie.rum &&
rumTrackingType &&
formatSessionType(
infos.cookie.rum,
rumTrackingType,
'Not tracked',
'Tracked with Session Replay',
'Tracked without Session Replay'
Expand Down
29 changes: 29 additions & 0 deletions developer-extension/src/panel/sampler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { isSampled } from '@datadog/browser-rum-core'

export function computeRumTrackingType(
sessionId: string,
config: { sessionSampleRate?: number; sessionReplaySampleRate?: number }
): string {
const sessionSampleRate = config.sessionSampleRate ?? 100
const sessionReplaySampleRate = config.sessionReplaySampleRate ?? 0

if (!isSampled(sessionId, sessionSampleRate)) {
return '0' // NOT_TRACKED
}

if (isSampled(sessionId, (sessionSampleRate * sessionReplaySampleRate) / 100)) {
return '1' // TRACKED_WITH_SESSION_REPLAY
}

return '2' // TRACKED_WITHOUT_SESSION_REPLAY
}

export function computeLogsTrackingType(sessionId: string, config: { sessionSampleRate?: number }): string {
const sessionSampleRate = config.sessionSampleRate ?? 100

if (!isSampled(sessionId, sessionSampleRate)) {
return '0' // NOT_TRACKED
}

return '1' // TRACKED
}
2 changes: 2 additions & 0 deletions packages/rum-core/src/domain/configuration/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export interface RumInitConfiguration extends InitConfiguration {
* See [Connect RUM and Traces](https://docs.datadoghq.com/real_user_monitoring/platform/connect_rum_and_traces/?tab=browserrum) for further information.
*
* @category Tracing
* @defaultValue 100
*/
traceSampleRate?: number | undefined
/**
Expand Down Expand Up @@ -163,6 +164,7 @@ export interface RumInitConfiguration extends InitConfiguration {
* See [Configure Your Setup For Browser RUM and Browser RUM & Session Replay Sampling](https://docs.datadoghq.com/real_user_monitoring/guide/sampling-browser-plans) for further information.
*
* @category Session Replay
* @defaultValue 0
*/
sessionReplaySampleRate?: number | undefined

Expand Down
3 changes: 2 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ __metadata:
languageName: unknown
linkType: soft

"@datadog/browser-rum-core@npm:6.28.1, @datadog/browser-rum-core@workspace:packages/rum-core":
"@datadog/browser-rum-core@npm:6.28.1, @datadog/browser-rum-core@workspace:*, @datadog/browser-rum-core@workspace:packages/rum-core":
version: 0.0.0-use.local
resolution: "@datadog/browser-rum-core@workspace:packages/rum-core"
dependencies:
Expand Down Expand Up @@ -390,6 +390,7 @@ __metadata:
"@datadog/browser-core": "workspace:*"
"@datadog/browser-logs": "workspace:*"
"@datadog/browser-rum": "workspace:*"
"@datadog/browser-rum-core": "workspace:*"
"@mantine/core": "npm:8.3.15"
"@mantine/hooks": "npm:8.3.15"
"@tabler/icons-react": "npm:3.36.1"
Expand Down