✨ Compute session tracking type in developer extension for SDK v7 support#4202
✨ Compute session tracking type in developer extension for SDK v7 support#4202thomas-lebeau wants to merge 1 commit intomainfrom
Conversation
Bundles Sizes Evolution
🚀 CPU Performance
🧠 Memory Performance
|
|
✅ Tests 🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage (details) 🔗 Commit SHA: a46373f | Docs | Datadog PR Page | Was this helpful? Give us feedback! |
0c5c1fb to
6b098bd
Compare
There was a problem hiding this comment.
💡 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".
| 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)) |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
6b098bd to
e5066d7
Compare
…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.
e5066d7 to
a46373f
Compare
mormubis
left a comment
There was a problem hiding this comment.
Nice! I completely forgot that the devtool would fail without this. 👏
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
isSampledfunction from@datadog/browser-rum-core, so the Infos tab continues to work correctly with SDK v7.Changes
sampler.tswithcomputeRumTrackingTypeandcomputeLogsTrackingTypefunctions that reuseisSampledfrom@datadog/browser-rum-coreinfosTab.tsxto 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)@defaultValueJSDoc annotations fortraceSampleRateandsessionReplaySampleRateinRumInitConfigurationTest instructions
Checklist