Skip to content

fix: make anonymousId cross-subdomain reconciliation the default - #1400

Merged
abueide merged 1 commit into
masterfrom
remove-anonymous-id-flag
Sep 11, 2026
Merged

abueide merged 1 commit into
masterfrom
remove-anonymous-id-flag

Conversation

@abueide

@abueide abueide commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #1398 (released as 1.84.2). That PR shipped resolveAnonymousIdConflicts as an opt-in, default-off flag -- a cautious first step taken before we'd confirmed how staged rollout actually works for this SDK.

Since then we traced the real delivery path end-to-end (ajs-renderer -> analytics.js-versions -> Flagon gates): which build of analytics-next a given source's CDN bundle contains is already controlled per-source, via v2projects pins and the ajs-renderer/v2rollout Flagon gate. That makes an application-level opt-in redundant -- exposure to this fix is governed by which code a source receives, not by a flag inside that code. Keeping the flag just adds a second, unnecessary gate: a source could receive the fix and still see the bug because nobody flipped an option in their load() call.

This PR removes resolveAnonymousIdConflicts and makes UniversalStorage#getConsistent the sole anonymousId resolution path -- no flag, no default to reason about.

Behavior change: no longer opt-in. Only affects sources where the cookie and localStorage already disagree (the broken case); when they agree, behavior is unchanged. The flag only existed for one release, so there's no meaningful adoption window for anyone depending on its absence.

Test plan

  • Updated User unit tests to drop the flag parameter -- reconciliation is now the only path (packages/browser/src/core/user/__tests__/index.test.ts)
  • Updated the Playwright e2e reproduction of Cross-domain tracking and clearing of LocalStorage #706 to drop the flag and assert convergence unconditionally (packages/browser-integration-tests/src/anonymous-id-subdomain-sync.test.ts) -- verified locally against a fresh build, including a full instrumented state-trace confirming the cookie wins the disagreement and resyncs localStorage as expected
  • Full packages/browser unit suite passes (unrelated pre-existing flake in ajs-destination/Amplitude tests, confirmed by rerun)
  • Full browser-integration-tests e2e suite passes
  • tsc --noEmit and eslint clean on all touched files
  • Bundle size actually decreased slightly (~29.96 kB, under the existing 30.1 kB limit) from removing the flag branch

…ove the opt-in flag

resolveAnonymousIdConflicts shipped default-off in the last release as a
cautious first step, before we'd confirmed the actual staged-rollout path
(Flagon gates + version_mappings pinning in analytics.js-versions) already
handles this at the infrastructure level. That makes the application-level
opt-in redundant: exposure is controlled by which build a source's CDN
bundle contains, not by a flag inside it. Remove the flag and make
getConsistent the only anonymousId resolution path.
@changeset-bot

changeset-bot Bot commented Sep 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a6dd87d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@segment/analytics-next Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codecov

codecov Bot commented Sep 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.58%. Comparing base (53d0a6b) to head (4d8f329).

⚠️ Current head 4d8f329 differs from pull request most recent head a6dd87d

Please upload reports for the commit a6dd87d to get more accurate results.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1400      +/-   ##
==========================================
- Coverage   91.59%   91.58%   -0.01%     
==========================================
  Files         127      127              
  Lines        4163     4159       -4     
  Branches     1040     1038       -2     
==========================================
- Hits         3813     3809       -4     
  Misses        350      350              
Flag Coverage Δ
browser 92.49% <100.00%> (-0.02%) ⬇️
core 90.07% <ø> (ø)
node 89.43% <ø> (ø)

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@abueide
abueide merged commit d49e05f into master Sep 11, 2026
35 of 37 checks passed
@abueide
abueide deleted the remove-anonymous-id-flag branch September 11, 2026 18:25
@abueide abueide mentioned this pull request Sep 11, 2026
4 tasks
abueide added a commit that referenced this pull request Sep 11, 2026
## Summary

Manual version bump (the `Changeset Release Creator` bot is still broken
-- see #1399 for the ongoing org-level Actions allow-list issue). Same
as before: ran `yarn update-versions-and-changelogs` against the one
changeset currently pending on `master`, from #1400 (removing the
`resolveAnonymousIdConflicts` opt-in flag, making cross-subdomain
`anonymousId` reconciliation unconditional).

`@segment/analytics-next` bumps `1.84.2` -> `1.84.3`.

Merging this (commit message starts with `Version Packages`) triggers
`publish.yml`'s `should-release` check on push to `master`, which runs
the real npm publish + CDN deploy.

## Test plan

- [x] Relevant test suites pass (`src/generated`, `src/core/user`,
`src/core/storage`)
- [x] `tsc --noEmit` clean
- [x] Verified `packages/browser/src/generated/version.ts` and
`package.json` both read `1.84.3`
- [x] Verified the generated `CHANGELOG.md` entry attributes #1400
correctly
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.

2 participants