Skip to content

Add optional seedItemIds to trackRecommendationClick#256

Merged
esezen merged 4 commits into
masterfrom
cdx-435-node-sdk-add-optional-seeditemids-to-recommendation-click
Jun 8, 2026
Merged

Add optional seedItemIds to trackRecommendationClick#256
esezen merged 4 commits into
masterfrom
cdx-435-node-sdk-add-optional-seeditemids-to-recommendation-click

Conversation

@Sher-Bakhodirov

Copy link
Copy Markdown
Contributor

No description provided.

@Sher-Bakhodirov Sher-Bakhodirov requested a review from HHHindawy June 2, 2026 17:36
@Sher-Bakhodirov Sher-Bakhodirov requested a review from a team as a code owner June 2, 2026 17:36
Copilot AI review requested due to automatic review settings June 2, 2026 17:36
constructor-claude-bedrock[bot]

This comment was marked as outdated.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds support for optionally including seedItemIds when sending trackRecommendationClick events, allowing the API to receive the seed item(s) that generated the recommendation.

Changes:

  • Extend trackRecommendationClick to accept seedItemIds (string or string array) and send it as seed_item_ids in the POST body.
  • Update TypeScript declarations to include the new optional parameter.
  • Add unit tests covering omission and inclusion of seed_item_ids for different input shapes.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/types/tracker.d.ts Adds seedItemIds?: string[] | string to trackRecommendationClick parameter types.
src/modules/tracker.js Adds JSDoc + parameter normalization/mapping to send seed_item_ids in the request body.
spec/src/modules/tracker.js Adds tests for seedItemIds behavior (omitted/array/string/invalid type).

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

Comment thread src/modules/tracker.js
Comment on lines 1194 to 1197
* @param {number} [parameters.numResultsPerPage] - Number of results on page
* @param {object} [parameters.analyticsTags] - Pass additional analytics data
* @param {string[]|string} [parameters.seedItemIds] - Item ID(s) used to generate recommendations
* @param {object} userParameters - Parameters relevant to the user request
Comment thread spec/src/modules/tracker.js Outdated

expect(tracker.trackRecommendationClick({ ...requiredParameters, seedItemIds }, userParameters)).to.equal(true);
});
it('Should return valid response and omit seed_items_id if seedItemIds is not string or array', (done) => {
constructor-claude-bedrock[bot]

This comment was marked as outdated.

@esezen

esezen commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

@Sher-Bakhodirov thanks for working on this. I don't love having number in there but we have to make it consistent with client-js. Can we please update the implementation to support string[]|string|number?
Constructor-io/constructorio-client-javascript#375

constructor-claude-bedrock[bot]

This comment was marked as outdated.

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

Copy link
Copy Markdown

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 an optional seedItemIds parameter to trackRecommendationView and trackRecommendationClick, with tests and TypeScript types included — the implementation is clean and well-structured.

Inline comments: 5 discussions added

Overall Assessment: ⚠️ Needs Work

Comment thread spec/src/modules/tracker.js
Comment thread .github/workflows/run-tests.yml

@esezen esezen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@esezen esezen merged commit 6a94560 into master Jun 8, 2026
6 checks passed
@esezen esezen deleted the cdx-435-node-sdk-add-optional-seeditemids-to-recommendation-click branch June 8, 2026 19:27
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