Skip to content

✨ Compute session tracking type in developer extension for SDK v7 support#4202

Open
thomas-lebeau wants to merge 1 commit intomainfrom
thomas.lebeau/dev-tool-sdk-v7-support
Open

✨ Compute session tracking type in developer extension for SDK v7 support#4202
thomas-lebeau wants to merge 1 commit intomainfrom
thomas.lebeau/dev-tool-sdk-v7-support

Conversation

@thomas-lebeau
Copy link
Collaborator

@thomas-lebeau thomas-lebeau commented Feb 18, 2026

Motivation

SDK v7 will no longer store the session tracking type (logs/rum) in the session cookie. The developer extension currently reads these values directly from the cookie to display session tracking status in the Infos tab.

This change computes the tracking type locally in the extension using the same isSampled function from @datadog/browser-rum-core, so the Infos tab continues to work correctly with SDK v7.

Changes

  • Add sampler.ts with computeRumTrackingType and computeLogsTrackingType functions that reuse isSampled from @datadog/browser-rum-core
  • Update infosTab.tsx to compute the tracking type from the session ID and SDK config when the cookie does not contain it (SDK v7), falling back to the cookie value when available (SDK v6)
  • Add @defaultValue JSDoc annotations for traceSampleRate and sessionReplaySampleRate in RumInitConfiguration

Test instructions

  1. Open a page instrumented with the Browser SDK
  2. Open the Datadog Developer Extension and go to the Infos tab
  3. Verify that the Logs and RUM session tracking types are displayed correctly

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.
  • Updated documentation and/or relevant AGENTS.md file

@cit-pr-commenter-54b7da
Copy link

cit-pr-commenter-54b7da bot commented Feb 18, 2026

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 171.96 KiB 171.96 KiB 0 B 0.00%
Rum Profiler 4.67 KiB 4.67 KiB 0 B 0.00%
Rum Recorder 24.88 KiB 24.88 KiB 0 B 0.00%
Logs 56.29 KiB 56.29 KiB 0 B 0.00%
Flagging 944 B 944 B 0 B 0.00%
Rum Slim 127.73 KiB 127.73 KiB 0 B 0.00%
Worker 23.63 KiB 23.63 KiB 0 B 0.00%
🚀 CPU Performance
Action Name Base CPU Time (ms) Local CPU Time (ms) 𝚫%
RUM - add global context 0.0039 0.0048 +23.08%
RUM - add action 0.0125 0.0136 +8.80%
RUM - add error 0.0124 0.014 +12.90%
RUM - add timing 0.0025 0.0025 0.00%
RUM - start view 0.0119 0.0123 +3.36%
🧠 Memory Performance
Action Name Base Memory Consumption Local Memory Consumption 𝚫
RUM - add global context 27.19 KiB 26.71 KiB -493 B
RUM - add action 110.94 KiB 111.79 KiB +865 B
RUM - add timing 26.53 KiB 26.47 KiB -58 B
RUM - add error 120.44 KiB 115.31 KiB -5.13 KiB
RUM - start/stop session replay recording 25.73 KiB 26.01 KiB +286 B
RUM - start view 500.61 KiB 501.10 KiB +506 B
Logs - log message 45.04 KiB 45.80 KiB +782 B

🔗 RealWorld

@datadog-datadog-prod-us1
Copy link

datadog-datadog-prod-us1 bot commented Feb 18, 2026

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 77.16% (+0.00%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: a46373f | Docs | Datadog PR Page | Was this helpful? Give us feedback!

@thomas-lebeau thomas-lebeau force-pushed the thomas.lebeau/dev-tool-sdk-v7-support branch 3 times, most recently from 0c5c1fb to 6b098bd Compare February 20, 2026 10:13
@thomas-lebeau thomas-lebeau marked this pull request as ready for review February 20, 2026 10:20
@thomas-lebeau thomas-lebeau requested a review from a team as a code owner February 20, 2026 10:20
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6b098bd447

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +82 to +86
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))

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
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).

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))

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
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.

@thomas-lebeau thomas-lebeau force-pushed the thomas.lebeau/dev-tool-sdk-v7-support branch from 6b098bd to e5066d7 Compare February 20, 2026 10:26
…port

SDK v7 uses deterministic sampling and no longer stores tracking type
in the session cookie. Add a sampler module replicating the Knuth factor
algorithm so the developer extension can compute tracking type from the
session ID and config, maintaining compatibility with both v6 and v7.
@thomas-lebeau thomas-lebeau force-pushed the thomas.lebeau/dev-tool-sdk-v7-support branch from e5066d7 to a46373f Compare February 20, 2026 10:31
Copy link
Contributor

@mormubis mormubis left a comment

Choose a reason for hiding this comment

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

Nice! I completely forgot that the devtool would fail without this. 👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments