Skip to content

fix(extension): Use stopSession to end the current session - #5373

Open
pdad04 wants to merge 1 commit into
mainfrom
andre.dean/browser-extension-handle-end-session-for-v2-cookie
Open

pdad04 wants to merge 1 commit into
mainfrom
andre.dean/browser-extension-handle-end-session-for-v2-cookie

Conversation

@pdad04

@pdad04 pdad04 commented Dec 4, 2026

Copy link
Copy Markdown

Motivation

In the extension the end current session button only wrote _dd_s, so it didn't end sessions stored in _dd_s_v2, and it dropped aid, and c.

Changes

The button wrote _dd_s=isExpired=1. Now the button calls DD_RUM.stopSession(), so the normal expired stated is written by the SDK.

Test instructions

  • From developer-extension directory, build the extension and start the dev server
  • Open a page that runs RUM (e.g. yarn dev → http://localhost:8080)
  • Click End current session. Check that the session cookie becomes isExpired=1… and still has its aid and c

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

@pdad04
pdad04 requested a review from a team as a code owner December 4, 2026 00:40
@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Pipelines  Tests

✨ Unblock PR with BitsAI

❌ Errors

Your PR has failed checks. Please review the issues below and take necessary action before merging.

🚦 1 Pipeline job failed

DataDog/browser-sdk | format — 🔧 Needs a code fix, caused by this PR

View more details · View in GitLab

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

Useful? React with 👍 / 👎

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

@datadog-datadog-prod-us1-2 datadog-datadog-prod-us1-2 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.

Bits Code Review: FAIL

The session-ending button remains visible on Logs-only pages, but its new unconditional DD_RUM call throws and leaves the session active.

Open Bits AI session

🤖 Bits Code Review · Commit 7cdde01

evalInWindow(
`
document.cookie = '_dd_s=isExpired=1; expires=${expires}; path=/'
DD_RUM.stopSession()

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 Preserve session termination on Logs-only pages

On Logs-only pages, infos.cookie still displays “End current session,” but DD_RUM is absent. Clicking the button now throws a ReferenceError and leaves the session active; previously it could expire a legacy _dd_s session. Preserve a working termination fallback when RUM is unavailable. The Logs public API has no equivalent stopSession method, so simply switching SDK globals or guarding this call is insufficient.

React: 👍 useful · 👎 wrong · 😕 unclear · 👀 right, but not acting on it

What each reaction means
  • 👍 Useful: correct, and you're fixing it or will.
  • 👎 Wrong: the finding is incorrect, for example the bug can't happen or the code was misread.
  • 😕 Unclear: you can't tell what it means or why it matters.
  • 👀 Right, not acting: correct, but intended, out of scope for this PR, a known risk, or too minor.

🤖 Bits Code Review · Open Bits AI session

This branch has not been deployed

No deployments
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