Skip to content

fix: add diagnostics + retry logic to isEnabled and getTopLevelDomain#1543

Open
daniel-graham-amplitude wants to merge 11 commits intomainfrom
AMP-149016-is-enabled-diagnostics
Open

fix: add diagnostics + retry logic to isEnabled and getTopLevelDomain#1543
daniel-graham-amplitude wants to merge 11 commits intomainfrom
AMP-149016-is-enabled-diagnostics

Conversation

@daniel-graham-amplitude
Copy link
Collaborator

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

Summary

  • Harden the "isEnabled" function to reduce the likelihood of false negatives
    • Add 3 retries with 100 ms in between to confirm the failure isn't a "one-off"
  • Add "diagnostics" to "isEnabled" and "getTopLevelDomain" so that we can monitor when either of them unexpectedly fails and can find out sooner

Checklist

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

Note

Medium Risk
Touches cross-window postMessage handling, dynamic script loading, and cookie-detection logic; bugs here could affect instrumentation startup, diagnostics noise, or cookie persistence across many browser environments.

Overview
Introduces a new cross-window messaging layer in analytics-core (BaseWindowMessenger, getOrCreateWindowMessenger, and enableBackgroundCapture) and exports shared origin/script constants, enabling autocapture and session replay to share a singleton messenger, dedupe script loads, and avoid handler race conditions.

Hardens cookie-related behavior: CookieStorage.isEnabled() now retries and caches successful results, and both cookie enablement and getTopLevelDomain() failures can emit diagnostics events (with getTopLevelDomain() now accepting a diagnostics client). Uncaught SDK error diagnostics now track multiple loader script URLs instead of a single URL.

plugin-autocapture-browser is refactored to use the shared messenger (replacing WindowMessenger with enableVisualTagging + core singleton), adds background-capture actions, and updates text extraction to avoid cloneNode side effects; session-replay-browser enables background capture when opened via window.opener. Includes version/CDN snippet updates across packages and minor dependency lockfile bumps.

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

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 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

@daniel-graham-amplitude daniel-graham-amplitude changed the base branch from main to prerelease/is-enabled-hardening February 17, 2026 23:42
@daniel-graham-amplitude daniel-graham-amplitude changed the base branch from prerelease/is-enabled-hardening to prerelease-attribution-cookie-hardening February 17, 2026 23:45
@daniel-graham-amplitude daniel-graham-amplitude force-pushed the AMP-149016-is-enabled-diagnostics branch from 4bab69b to ba83071 Compare February 24, 2026 00:42
@daniel-graham-amplitude daniel-graham-amplitude requested a review from a team as a code owner February 24, 2026 00:42
@daniel-graham-amplitude daniel-graham-amplitude changed the base branch from prerelease-attribution-cookie-hardening to main February 24, 2026 00:42
Copy link
Collaborator

@lewgordon-amplitude lewgordon-amplitude left a comment

Choose a reason for hiding this comment

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

LGTM!

@daniel-graham-amplitude daniel-graham-amplitude marked this pull request as draft February 24, 2026 18:03
@daniel-graham-amplitude daniel-graham-amplitude changed the title DRAFT: refactor: add diagnostics + retry logic to isEnabled and getTopLevelDomain fix: add diagnostics + retry logic to isEnabled and getTopLevelDomain Feb 25, 2026
@daniel-graham-amplitude daniel-graham-amplitude marked this pull request as ready for review February 26, 2026 00:24
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