Skip to content

[NO-REF] - add pia recommendations tracking#469

Open
vladconstructor wants to merge 7 commits into
Constructor-io:masterfrom
vladconstructor:NO-REF/add-pia-recommendations-tracking
Open

[NO-REF] - add pia recommendations tracking#469
vladconstructor wants to merge 7 commits into
Constructor-io:masterfrom
vladconstructor:NO-REF/add-pia-recommendations-tracking

Conversation

@vladconstructor

@vladconstructor vladconstructor commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Currently blocked by api deployment, but code itself can be reviewed

@vladconstructor vladconstructor requested a review from a team as a code owner June 18, 2026 13:14
Copilot AI review requested due to automatic review settings June 18, 2026 13:14

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 additional Product Insights Agent (PIA) tracking capabilities to the JavaScript client, expanding the tracker API to support conversation/thread grouping and richer answer payloads (recommendation items + follow-up questions), plus a new “result click” event.

Changes:

  • Add optional threadId to multiple existing PIA tracking events and include thread_id in request bodies.
  • Extend trackProductInsightsAgentAnswerView to optionally send items and followUpQuestions.
  • Add a new tracker method trackProductInsightsAgentResultClick with corresponding TypeScript typings and specs.

Reviewed changes

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

File Description
src/types/tracker.d.ts Updates Tracker type signatures to include threadId, plus items/followUpQuestions, and adds the new result-click method.
src/modules/tracker.js Implements thread_id support across PIA events, adds optional items/follow_up_questions for answer views, and introduces trackProductInsightsAgentResultClick.
spec/src/modules/tracker.js Updates/expands specs to cover thread_id, items/follow_up_questions, and the new result-click event.

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

Comment thread src/modules/tracker.js
Comment on lines +3626 to +3628
if (followUpQuestions && Array.isArray(followUpQuestions)) {
bodyParams.follow_up_questions = followUpQuestions.map((q) => helpers.toSnakeCaseKeys(q, false));
}
Comment thread src/modules/tracker.js
Comment on lines +3743 to +3746
* @param {number} [parameters.position] - Position of the clicked item in the list
* @param {string} [parameters.variationId] - Variation id of the clicked recommendation
* @param {string} [parameters.threadId] - Thread ID for grouping events within a conversation
* @param {string} [parameters.section] - The section name for the item Ex. "Products"
Comment on lines +15629 to +15633
it('Should throw an error when invalid parameters are provided', () => {
const { tracker } = new ConstructorIO({ apiKey: testApiKey });

expect(tracker.trackProductInsightsAgentResultClick()).to.be.an('error');
});

@TarekAlQaddy TarekAlQaddy 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.

Thanks @vladconstructor for working on this!
I left some comments to clarify some params, could you check them please?

Comment thread src/types/tracker.d.ts
answerText: string;
qnaResultId?: string;
items?: ItemTracked[];
followUpQuestions?: Array<{ question: string }>;

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.

The RFC mentions that followUpQuestions is an Array of objects, each object should have a value, could you confirm that this was changed to question field instead?

Comment thread src/types/tracker.d.ts
position?: number;
qnaResultId?: string;
variationId?: string;
threadId?: string;

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.

There are additional params that are mentioned in the RFC which are question, seedItemId, seedItemName and seedVariationId. Could you clarify if they were intentionally omitted?

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