Skip to content

DRAFT: Amp 149016 default referrers fallback#1540

Open
daniel-graham-amplitude wants to merge 3 commits intoAMP-149016-cookie-enabled-reentrancy-bugfrom
AMP-149016-default-referrers-fallback
Open

DRAFT: Amp 149016 default referrers fallback#1540
daniel-graham-amplitude wants to merge 3 commits intoAMP-149016-cookie-enabled-reentrancy-bugfrom
AMP-149016-default-referrers-fallback

Conversation

@daniel-graham-amplitude
Copy link
Collaborator

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

Summary

Checklist

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

Note

Medium Risk
Changes default referrer-exclusion behavior, which can affect campaign attribution/session logic across different hostnames and TLD edge cases; logic is bounded and covered by new tests but still heuristic.

Overview
When getDefaultExcludedReferrers() is called without a configured cookie domain, it now derives a best-effort base domain from location.hostname (including support for a curated set of common 2-level TLDs) and builds the exclusion regex from that value.

This also tightens regex escaping (escapes all dots) and expands unit tests by mocking global.location and adding cases for 1-level domains, known 2-level TLDs, and edge cases like localhost and IP hostnames.

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

@daniel-graham-amplitude daniel-graham-amplitude changed the base branch from main to AMP-149016-cookie-enabled-reentrancy-bug February 16, 2026 18:56
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 1 potential issue.

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

const parts = hostname.split('.');
let tld = parts[parts.length - 1];
let name = parts[parts.length - 2];
if (KNOWN_2LDS.find((tld) => hostname.endsWith(`.${tld}`))) {
Copy link

Choose a reason for hiding this comment

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

Callback parameter shadows outer variable tld

Low Severity

The find callback parameter tld on line 146 shadows the outer let tld declared on line 144. While the current logic works correctly (the outer tld is still properly reassigned in the if block body, outside the callback scope), this shadowing is confusing and fragile. A future developer modifying this code could easily misunderstand which tld is in scope. Additionally, Array.prototype.some would be more idiomatic here since the found value is only used as a boolean.

Additional Locations (1)

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