Skip to content

Clear cached user and account ids on logout (#1495) - #1498

Open
hippi345 wants to merge 1 commit into
DataDog:developfrom
hippi345:fix/1495-clear-cached-user-id
Open

hippi345 wants to merge 1 commit into
DataDog:developfrom
hippi345:fix/1495-clear-cached-user-id

Conversation

@hippi345

Copy link
Copy Markdown

What does this PR do?

clearUserInfo() and clearAccountInfo() reset the stored info but leave the cached user and account ids in rum/helper in place. Those cached ids are what RequestContext reads when it builds the baggage header, so once a user logs out, outgoing requests keep sending the previous user's id (and account id) until someone else logs in.

This calls the existing clearCachedUserId() / clearCachedAccountId() helpers from the two clear methods, so the cache follows the singleton.

Motivation

Fixes #1495

Additional Notes

Added a test to each singleton's test file that sets the info, clears it, and checks that the cached id the baggage uses is gone afterwards.

This change was prepared with AI assistance and reviewed by the author.

@hippi345
hippi345 marked this pull request as ready for review October 18, 2026 04:14
@hippi345
hippi345 requested a review from a team as a code owner October 18, 2026 04:14
Copilot AI balanced review requested due to automatic review settings October 18, 2026 04:14
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-18T04:16:54.564189Z 42a116a Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused changes synchronize identity caches with singleton state and include regression coverage, with no blocking issues identified.

No open issues 🎉

What changed in this PR

Fixes #1495 by clearing cached identity IDs alongside singleton state, preventing subsequent requests from sending stale IDs in baggage headers.

Changes:

  • Clear the corresponding cache in both identity-clear methods.
  • Add regression tests checking singleton state, cached IDs, and generated baggage.
File Description
packages/​core/​src/​sdk/​UserInfoSingleton/​UserInfoSingleton.ts Clears the cached user ID.
packages/​core/​src/​sdk/​UserInfoSingleton/​__tests__/​UserInfoSingleton.test.ts Tests user ID removal from cache and baggage.
packages/​core/​src/​sdk/​AccountInfoSingleton/​AccountInfoSingleton.ts Clears the cached account ID.
packages/​core/​src/​sdk/​AccountInfoSingleton/​__tests__/​AccountInfoSingleton.test.ts Tests account ID removal from cache and baggage.

Review effort: Balanced

@maciejburda
maciejburda requested a review from sbarrio October 19, 2026 07:09

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.

clearUserInfo() doesn't clear the cached user id, so baggage keeps the previous user's id

2 participants