Skip to content

🐛 [devext] support v7 session cookie and expose anonymous ID / account context - #4960

Draft
mormubis wants to merge 5 commits into
mainfrom
adlrb/devext-v7-cookie
Draft

🐛 [devext] support v7 session cookie and expose anonymous ID / account context#4960
mormubis wants to merge 5 commits into
mainfrom
adlrb/devext-v7-cookie

Conversation

@mormubis

Copy link
Copy Markdown
Contributor

Motivation

SDK v7 renamed the session cookie from _dd_s to _dd_s_v2, so the extension was showing empty session data for any v7 app. v7 also added an aid (anonymous ID) field in the cookie and a getAccount() API that the extension wasn't exposing. Jira: RUM-17172.

Changes

In useSdkInfos.ts, refactored cookie reading into a findCookieValue() helper. The new cookie name _dd_s_v2 is preferred only when a v7 SDK is detected on the page (DD_RUM.version or DD_LOGS.version starts with "7"), falling back to _dd_s otherwise. This prevents a stale _dd_s_v2 left over from a previous v7 session from shadowing an active v6 session. The aid cookie field is mapped to anonymousId for readability. Added getAccount() calls for both RUM and Logs.

In infosTab.tsx, the new fields show up in the panel: anonymous ID under the cookie section, account under RUM and Logs. endSession() also expires _dd_s_v2, but only if it already exists — unconditionally writing it on a v6 page would create a phantom cookie that shadows the real v6 session on next load.

Test instructions

  1. Load a v7 app (yarn dev, open http://localhost:8080) and open the Infos tab — session data should show, including the anonymous ID.
  2. Call DD_RUM.setAccount({ id: 'test' }) in the console — Account should appear under RUM.
  3. Click "End current session" — _dd_s_v2 should be expired in Application → Cookies.
  4. Reload — new session should start.
  5. On a page without v7 SDK, set _dd_s manually and verify session shows. Click End session — _dd_s expires and no _dd_s_v2 is created.
  6. Set both _dd_s and _dd_s_v2 manually on a non-v7 page — extension should show _dd_s. On a v7 page with both cookies — extension should show _dd_s_v2.

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

.find(([cookieName]) => cookieName === name)
?.[1]
}
const isV7 = window.DD_RUM?.version?.startsWith('7') || window.DD_LOGS?.version?.startsWith('7')

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If the SDK hasn't initialized yet when the extension first reads, version is undefined and isV7 is false, so it falls back to _dd_s. On the next poll (once the SDK is up) it corrects itself. Not a real issue in practice but worth knowing.

@datadog-prod-us1-3

datadog-prod-us1-3 Bot commented Aug 18, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

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

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 8af253c | Docs | View more details | Give us feedback!

@mormubis
mormubis force-pushed the adlrb/devext-v7-cookie branch from 5eb1c53 to 8af253c Compare August 18, 2026 10:46
@cit-pr-commenter-54b7da

Copy link
Copy Markdown

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 181.27 KiB 181.27 KiB 0 B 0.00%
Rum Profiler 8.43 KiB 8.43 KiB 0 B 0.00%
Rum Recorder 21.12 KiB 21.12 KiB 0 B 0.00%
Logs 57.50 KiB 57.50 KiB 0 B 0.00%
Rum Salesforce N/A 139.22 KiB N/A N/A N/A
Rum Slim 139.21 KiB 139.21 KiB 0 B 0.00%
Worker 22.96 KiB 22.96 KiB 0 B 0.00%
Rum Shopify N/A 200.99 KiB N/A N/A N/A
Rum-shopify Profiler N/A 8.43 KiB N/A N/A N/A
Rum-shopify Recorder N/A 3.72 KiB N/A N/A N/A

@mormubis
mormubis marked this pull request as ready for review August 19, 2026 09:54
@mormubis
mormubis requested a review from a team as a code owner August 19, 2026 09:54
@mormubis
mormubis marked this pull request as draft August 19, 2026 09:54

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

Copy link
Copy Markdown

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: 8af253ce64

ℹ️ 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 +89 to +90
.find(([cookieName]) => cookieName === name)
?.[1]

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 Match the active v7 cookie by its configuration marker

issue: When multiple _dd_s_v2 cookies are visible, such as after changing trackSessionAcrossSubdomains or partitioned-cookie settings, this returns the first value regardless of its c marker. The v7 SDK deliberately selects the cookie whose marker matches its current cookie options in sessionInCookie.ts, so the extension can display and link to a stale or unrelated session instead of the one the SDK is using.

Useful? React with 👍 / 👎.

`
document.cookie = '_dd_s=isExpired=1; expires=${expires}; path=/'
if (document.cookie.includes('_dd_s_v2=')) {
document.cookie = '_dd_s_v2=isExpired=1; expires=${expires}; path=/'

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 Preserve v7 cookie attributes when ending the session

issue: For v7 applications using trackSessionAcrossSubdomains or usePartitionedCrossSiteSessionCookie, this assignment omits the original Domain or Partitioned attributes and therefore creates or updates a different cookie rather than the SDK's active _dd_s_v2. Because the SDK continues selecting the original cookie by its c marker, clicking “End current session” does not actually end that session; use the SDK configuration to write the expiration with matching cookie attributes.

Useful? React with 👍 / 👎.

internalContext: window.DD_RUM?.getInternalContext?.(),
globalContext: window.DD_RUM?.getGlobalContext?.(),
user: window.DD_RUM?.getUser?.(),
account: window.DD_RUM?.getAccount?.(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Avoid reporting extension polling as getAccount usage

issue: Opening the Infos tab now invokes RUM's instrumented getAccount() method every two seconds. That method records the get-account telemetry usage feature, so merely inspecting a page marks the API as customer-used even when the application never calls it, contaminating API-adoption measurements; retrieve the account through a non-instrumented inspection path instead.

AGENTS.md reference: AGENTS.md:L120-L120

Useful? React with 👍 / 👎.

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.

1 participant