[NO-REF] - add pia recommendations tracking#469
Conversation
There was a problem hiding this comment.
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
threadIdto multiple existing PIA tracking events and includethread_idin request bodies. - Extend
trackProductInsightsAgentAnswerViewto optionally senditemsandfollowUpQuestions. - Add a new tracker method
trackProductInsightsAgentResultClickwith 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.
| if (followUpQuestions && Array.isArray(followUpQuestions)) { | ||
| bodyParams.follow_up_questions = followUpQuestions.map((q) => helpers.toSnakeCaseKeys(q, false)); | ||
| } |
| * @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" |
| it('Should throw an error when invalid parameters are provided', () => { | ||
| const { tracker } = new ConstructorIO({ apiKey: testApiKey }); | ||
|
|
||
| expect(tracker.trackProductInsightsAgentResultClick()).to.be.an('error'); | ||
| }); |
…rio-client-javascript into NO-REF/add-pia-recommendations-tracking
TarekAlQaddy
left a comment
There was a problem hiding this comment.
Thanks @vladconstructor for working on this!
I left some comments to clarify some params, could you check them please?
| answerText: string; | ||
| qnaResultId?: string; | ||
| items?: ItemTracked[]; | ||
| followUpQuestions?: Array<{ question: string }>; |
There was a problem hiding this comment.
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?
| position?: number; | ||
| qnaResultId?: string; | ||
| variationId?: string; | ||
| threadId?: string; |
There was a problem hiding this comment.
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?
Currently blocked by api deployment, but code itself can be reviewed