Skip to content

[CDX-472] Remove the limit of 100 for browse/search load events#457

Open
TarekAlQaddy wants to merge 2 commits into
masterfrom
cdx-472-js-sdk-remove-items-limit-of-100-in-searchbrowse-load-events
Open

[CDX-472] Remove the limit of 100 for browse/search load events#457
TarekAlQaddy wants to merge 2 commits into
masterfrom
cdx-472-js-sdk-remove-items-limit-of-100-in-searchbrowse-load-events

Conversation

@TarekAlQaddy
Copy link
Copy Markdown
Contributor

@TarekAlQaddy TarekAlQaddy commented Jun 2, 2026

@TarekAlQaddy TarekAlQaddy requested review from a team and Copilot June 2, 2026 16:01
@TarekAlQaddy TarekAlQaddy requested a review from a team as a code owner June 2, 2026 16:01
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 removes the hardcoded 100-item limit from trackSearchResultsLoaded and trackBrowseResultsLoaded, and updates tests accordingly. The change is straightforward and the intent is clear, but it is incomplete: four other tracker methods still enforce the same slice(0, 100) limit (trackPurchase, trackRecommendationView, trackQuizResultsLoaded, and trackAgentResultView), which is inconsistent and likely unintentional.

Inline comments: 4 discussions added

Overall Assessment: ⚠️ Needs Work

});
const itemIDs = [...Array(1000).keys()];
const formattedItems = itemIDs.slice(0, 100).map((i) => ({ item_id: String(i) }));
const itemIDs = [...Array(150).keys()];
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: The array size of 150 works, but it is arbitrary and does not document why 150 was chosen (it is just "greater than 100"). Consider using a named constant or at least a comment like // deliberately over the old 100-item cap to make the intent obvious to future readers, especially since the old tests used 1000 which made the intent equally clear.


// Request
expect(fetchSpy).to.have.been.called;
expect(requestParams).to.have.property('items').to.deep.equal(items);
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: In the new trackBrowseResultsLoaded test, items is constructed as objects with item_id keys (already snake_case), and the assertion checks deep.equal(items). This works coincidentally because helpers.toSnakeCaseKeys is a no-op on already-snake_case keys. The assertion does not exercise the camelCase→snake_case transformation path. This is a minor coverage gap — not a blocker, but worth noting since the previous deleted test (which used optionalParameters) did cover more of the function's behaviour (section, result_count, result_page, etc.).

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

This PR removes the client-side cap of 100 items for browse and search “results loaded” tracking events, allowing the full provided item list to be sent to the API.

Changes:

  • Removed the slice(0, 100) trimming when transforming items/item_ids/customer_ids for trackSearchResultsLoaded.
  • Removed the slice(0, 100) trimming when serializing items for trackBrowseResultsLoaded.
  • Updated and added specs to assert that >100 items are sent through unchanged.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/modules/tracker.js Stops truncating item lists to 100 for search/browse result load events.
spec/src/modules/tracker.js Updates tests to validate that all provided items (e.g., 150) are included in payloads.

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

}

it('Should limit number of customer_ids to 100 when using item_ids', (done) => {
it('Should send all items when more than 100 items are provided', (done) => {
Copy link
Copy Markdown
Contributor

@Alexey-Pavlov Alexey-Pavlov left a comment

Choose a reason for hiding this comment

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

LGTM!

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