Add af and referrer to default referral query parameters#286
Conversation
Add `af` and `referrer` to the default referral tracking query parameters checked on the landing-page URL, alongside the existing `ref`, `referral`, and `refcode`. So `?af=CODE` and `?referrer=CODE` are now captured as the `ref` traffic source out of the box. Centralize the default list as DEFAULT_REFERRAL_PARAMS in event/constants.ts (mirroring the CLICK_ID_PARAMS pattern) so the extraction list and the page-properties exclusion set share one source of truth and can't drift. EventFactory consumes it for the default, and it is spread into PAGE_PROPERTIES_EXCLUDED_FIELDS. Update the ReferralOptions.queryParams @default doc and add tests covering extraction of every default param into context.ref, the ?referrer-vs-document.referrer distinction, and default ordering. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NE7oDonRuxxDrNLe9Kfme3
There was a problem hiding this comment.
Code Review
This pull request extracts the default referral parameters into a shared constant DEFAULT_REFERRAL_PARAMS and expands the default list to include af and referrer. It also updates the excluded page properties, documentation, and adds comprehensive unit tests for the new default parameters. The feedback suggests simplifying the ternary expression in EventFactory.ts using optional chaining to improve readability.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| const referralParams = !this.options?.referral | ||
| ? defaultParams // No referral config at all → use defaults | ||
| : (this.options.referral.queryParams ?? defaultParams); // Has config → use queryParams or defaults | ||
| ? DEFAULT_REFERRAL_PARAMS // No referral config at all → use defaults | ||
| : (this.options.referral.queryParams ?? DEFAULT_REFERRAL_PARAMS); // Has config → use queryParams or defaults |
There was a problem hiding this comment.
Summary
Expanded the default referral code query parameters to include
af(affiliate) andreferrerparameters, in addition to the existingref,referral, andrefcodeparameters. This allows the SDK to capture more common referral attribution sources out of the box.Key Changes
afandreferrerto default referral parameters: ExtendedDEFAULT_REFERRAL_PARAMSconstant to include these additional attribution parameters in the order:ref,referral,refcode,af,referrerDEFAULT_REFERRAL_PARAMSconstant insrc/event/constants.tsto serve as the single source of truth for default referral parametersPAGE_PROPERTIES_EXCLUDED_FIELDSto use the newDEFAULT_REFERRAL_PARAMSconstant instead of hardcoding individual parameter namesDEFAULT_REFERRAL_PARAMSconstantcontext.ref?referrerquery parameter fromdocument.referrerafparameter is excluded from page propertiesImplementation Details
referrerparameter is intentionally included to capture referral codes, while being kept separate from thedocument.referrerproperty (which represents the external entry URL)ReferralOptions.queryParamsJSDoc default valuehttps://claude.ai/code/session_01NE7oDonRuxxDrNLe9Kfme3
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.