Skip to content

Amp 149016 global is enabled locked#1562

Draft
daniel-graham-amplitude wants to merge 14 commits intomainfrom
AMP-149016-global-is-enabled-locked
Draft

Amp 149016 global is enabled locked#1562
daniel-graham-amplitude wants to merge 14 commits intomainfrom
AMP-149016-global-is-enabled-locked

Conversation

@daniel-graham-amplitude
Copy link
Collaborator

@daniel-graham-amplitude daniel-graham-amplitude commented Feb 27, 2026

Summary

Checklist

  • Does your PR title have the correct title format?
  • Does your PR have a breaking change?:

Note

Medium Risk
Touches core cookie enablement checks and top-level-domain detection used during browser initialization; behavior now depends on navigator.locks availability with fallback paths and new diagnostics logging, so regressions could affect cookie-based identity storage.

Overview
Prevents concurrent cookie enablement/TLD checks from racing by wrapping CookieStorage.isEnabled() and getTopLevelDomain() domain-probing in navigator.locks (with legacy fallback when locks aren’t available).

Adds diagnostics reporting for cookie enablement failures/value mismatches and propagates an optional diagnosticsClient into getTopLevelDomain() from browser config initialization.

Expands automated coverage with a new Playwright E2E regression test and updates unit tests/mocks (including legacyIsEnabled) plus a stronger test-server/cookies/is-enabled.html stress test.

Written by Cursor Bugbot for commit 3e642db. This will update automatically on new commits. Configure here.

@daniel-graham-amplitude daniel-graham-amplitude marked this pull request as draft February 27, 2026 16:26
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

testValue,
});
}
console.log('isEnabled -- exiting with result:', value === testValue);
Copy link

Choose a reason for hiding this comment

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

Debug console.log statements left in production code

High Severity

Two console.log debug statements were left in production code. cookie.ts logs 'isEnabled -- exiting with result:' on every cookie-enabled check, and config.ts logs 'TLD -- exiting with domain:' during top-level domain detection. These will produce noisy output in every end-user's browser console during SDK initialization.

Additional Locations (1)

Fix in Cursor Fix in Web

}

return '';
});
Copy link

Choose a reason for hiding this comment

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

Missing diagnostics event that test expects to find

Medium Severity

The new test at line 468 expects diagnosticsClient.recordEvent to be called with 'cookies.tld.failure' when TLD detection fails, but neither getTopLevelDomain nor legacyGetTopLevelDomain ever records this event. The return '' at the end of both functions silently discards the failure without any diagnostics reporting, causing the test to fail.

Additional Locations (1)

Fix in Cursor Fix in Web


const legacyGetTopLevelDomain = async (url?: string, diagnosticsClient?: IDiagnosticsClient) => {
if (
!(await new CookieStorage<number>(undefined, { diagnosticsClient }).isEnabled()) ||
Copy link

Choose a reason for hiding this comment

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

Redundant isEnabled check on legacy fallback path

Low Severity

legacyGetTopLevelDomain re-checks isEnabled() (line 518) even though getTopLevelDomain already verified it (line 476) before calling the legacy function. On the legacy path (no navigator.locks), each isEnabled() call creates a test cookie with a unique key, does a set/get/remove cycle — so this doubles the cookie operations during initialization unnecessarily.

Fix in Cursor Fix in Web

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