feat(analytics-browser): resolve duplicate cookie via last write#1572
Draft
daniel-graham-amplitude wants to merge 84 commits intomainfrom
Draft
feat(analytics-browser): resolve duplicate cookie via last write#1572daniel-graham-amplitude wants to merge 84 commits intomainfrom
daniel-graham-amplitude wants to merge 84 commits intomainfrom
Conversation
This reverts commit 9707076.
…com:amplitude/Amplitude-TypeScript into AMP-149016-is-enabled-v2
…tude-TypeScript into AMP-149016-get-all
…com:amplitude/Amplitude-TypeScript into AMP-149016-is-enabled-v2
…com:amplitude/Amplitude-TypeScript into AMP-149016-is-enabled-v2
…com:amplitude/Amplitude-TypeScript into AMP-149016-is-enabled-v2
…tude-TypeScript into AMP-149016-get-all
Collaborator
Author
|
bugbot run |
Collaborator
Author
|
bugbot run |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CookieOptionscalledresolveMultipleCookiesBythat isdomainby default but can be set tolastWriteTime.lastWriteTime, the SDK changes the way it deals with multiple cookies. If it sees multiple cookies with the same name, it will read the one that was written to the most recently (denoted by a new parameterlastWriteTime, falls back tolastEventTimeto support backwards compatibility)Screen.Recording.2026-03-05.at.4.24.12.PM.mov
Checklist
Note
Medium Risk
Touches identity persistence and cookie read/write paths; incorrect resolution could restore the wrong
userId/sessionIdwhen duplicate cookies exist, though the change is scoped and covered by new tests.Overview
Improves duplicate-cookie handling by persisting a
lastWriteTimeinto theUserSessioncookie payload and, duringuseBrowserConfig, selecting the most recently written session when multiple cookies with the same key are present.Adds
CookieStorage.getAll()(optional on theStorageinterface) plus new browserstorage-helpersand tests to support deterministic resolution, with a small test-server tweak to allow cookie-domain experimentation.Written by Cursor Bugbot for commit ab0d16c. This will update automatically on new commits. Configure here.