Skip to content

[CDX-441] Add support for origin_referrer in SABR#254

Merged
esezen merged 5 commits into
masterfrom
cdx-441-node-sdk-add-support-for-origin-referrer
May 27, 2026
Merged

[CDX-441] Add support for origin_referrer in SABR#254
esezen merged 5 commits into
masterfrom
cdx-441-node-sdk-add-support-for-origin-referrer

Conversation

@HHHindawy
Copy link
Copy Markdown
Contributor

Add originReferrer support for SABR requests

Summary

  • Add originReferrer to UserParameters for Search, Autocomplete, Browse, Recommendations, and Quizzes modules
  • The value is passed as the origin_referrer query parameter in request URLs (matching the existing tracker behavior)

Tests

  • Added tests for Search (getSearchResults, getVoiceSearchResults)
  • Added tests for Autocomplete (getAutocompleteResults)
  • Added tests for Browse (getBrowseResults)
  • Added tests for Recommendations (getRecommendations)
  • Added tests for Quizzes (getQuizNextQuestion, getQuizResults)

@HHHindawy HHHindawy requested review from a team and Copilot May 18, 2026 13:30
@HHHindawy HHHindawy requested a review from a team as a code owner May 18, 2026 13:30
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds originReferrer support across SABR request builders so callers can pass a client page URL through userParameters, which is then sent to the API as the origin_referrer query parameter (matching existing tracker behavior).

Changes:

  • Extended UserParameters TypeScript type with originReferrer.
  • Added origin_referrer query param support in Search, Autocomplete, Browse, Recommendations, and Quizzes URL builders.
  • Added/updated module specs to assert origin_referrer is included in generated request URLs.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/types/index.d.ts Adds originReferrer to the shared UserParameters type.
src/modules/search.js Appends origin_referrer to Search and Voice Search requests when provided.
src/modules/autocomplete.js Appends origin_referrer to Autocomplete requests when provided.
src/modules/browse.js Appends origin_referrer to Browse requests when provided.
src/modules/recommendations.js Appends origin_referrer to Recommendations requests when provided.
src/modules/quizzes.js Appends origin_referrer to Quizzes requests when provided.
spec/src/modules/search.js Adds assertions for origin_referrer in Search and Voice Search tests.
spec/src/modules/autocomplete.js Adds assertion for origin_referrer in Autocomplete tests.
spec/src/modules/browse.js Adds assertion for origin_referrer in Browse tests.
spec/src/modules/recommendations.js Adds assertion for origin_referrer in Recommendations tests.
spec/src/modules/quizzes.js Adds assertions for origin_referrer in Quiz next-question and results tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/modules/search.js Outdated
Comment thread src/modules/autocomplete.js Outdated
Comment thread src/modules/browse.js Outdated
Comment thread src/modules/recommendations.js Outdated
Comment thread src/modules/quizzes.js Outdated
constructor-claude-bedrock[bot]

This comment was marked as outdated.

constructor-claude-bedrock[bot]

This comment was marked as outdated.

constructor-claude-bedrock[bot]

This comment was marked as outdated.

Copy link
Copy Markdown

@constructor-claude-bedrock constructor-claude-bedrock Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This PR adds originReferrer support to the SABR modules (Search, Autocomplete, Browse, Recommendations, Quizzes) by passing it as the origin_referrer query parameter, consistent with the existing tracker behavior.

Inline comments: 5 discussions added

Overall Assessment: ⚠️ Needs Work

});
});

it('Should return a response with valid ids and origin referrer', (done) => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Important Issue: The test description "Should return a response with valid ids and origin referrer" (used for getBrowseResultsForItemIds) is also reused verbatim for the getBrowseGroups test block below (line ~1462), which doesn't deal with item IDs at all. The getBrowseGroups test description should be updated to something like "Should return a response with valid groups and origin referrer" to avoid confusion when reading test output.

expect(res).to.have.property('request').to.be.an('object');
expect(res).to.have.property('response').to.be.an('object');
expect(res).to.have.property('result_id').to.be.an('string');
expect(requestedUrlParams).to.have.property('origin_referrer').to.equal(originReferrer);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: Tests across all modules only verify that origin_referrer is present when originReferrer is provided. Consider adding a negative test (or at minimum one representative negative test per module) that verifies origin_referrer is not present in the URL when originReferrer is omitted from userParameters. This is especially valuable given the truthy+type guard pattern used in the implementation, as it confirms edge cases like empty strings are handled correctly.

fetch: fetchSpy,
});

browse.getBrowseResultsForItemIds(ids, null, { originReferrer }).then((res) => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: null is passed as the second argument (parameters) to getBrowseResultsForItemIds. While this likely works due to the if (parameters) guard in the implementation, it would be more idiomatic and self-documenting to pass an empty object {} instead—matching the pattern used by every other test in this PR (e.g., getBrowseResults, getBrowseFacets, etc.).

});

return quizzes.getQuizNextQuestion(validQuizId, { answers: validAnswers }).then((res) => {
return quizzes.getQuizNextQuestion(validQuizId, { answers: validAnswers, quizSessionId }).then((res) => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: Several existing quiz tests were modified to add quizSessionId to the parameters (e.g., getQuizNextQuestion with answers, getQuizResults with page/resultsPerPage/filters/section). These changes appear unrelated to the originReferrer feature being introduced and are not explained in the PR description. Adding quizSessionId to existing tests changes their test scope (they now also implicitly test session ID behavior). These changes should be explained, or kept in a separate commit/PR to keep the diff focused.

@esezen esezen merged commit d7847b7 into master May 27, 2026
5 of 6 checks passed
@esezen esezen deleted the cdx-441-node-sdk-add-support-for-origin-referrer branch May 27, 2026 19:18
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.

3 participants