From 6fe014ca0e9b61c860d2a3ca2516219ae878928f Mon Sep 17 00:00:00 2001 From: Joseph Ong Date: Fri, 16 Oct 2026 20:54:59 +0800 Subject: [PATCH] [AGI-550] Add uiLibrary parameter to agent and PIA tracking events UI libraries (cio-ui-asa, cio-ui-pia) can render on a customer's own client, whose `c` tag then hides which library sent the event. The agent and product insights agent tracker methods now take an optional `uiLibrary`, sent as the `ui_library` query parameter, so the library stays identifiable without changing the client's own tag. Co-Authored-By: Claude Opus 5.5 --- spec/src/modules/tracker.js | 44 +++++++++++++ src/modules/tracker.js | 124 ++++++++++++++++++++++++++++++++++-- src/types/tracker.d.ts | 16 +++++ 3 files changed, 177 insertions(+), 7 deletions(-) diff --git a/spec/src/modules/tracker.js b/spec/src/modules/tracker.js index 575a1853..6b5de331 100644 --- a/spec/src/modules/tracker.js +++ b/spec/src/modules/tracker.js @@ -9837,6 +9837,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { section: 'Products', threadId: 'thread-1234', source: 'suggestion', + uiLibrary: 'cio-ui-mocha-1.0.0', }; it('Should respond with a valid response when intent and required parameters are provided', (done) => { @@ -9984,6 +9985,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { // Request expect(fetchSpy).to.have.been.called; + expect(helpers.extractUrlParamsFromFetch(fetchSpy)).to.have.property('ui_library').to.equal(optionalParameters.uiLibrary); expect(requestParams).to.have.property('section').to.equal('Products'); expect(requestParams).to.have.property('thread_id').to.equal(optionalParameters.threadId); expect(requestParams).to.have.property('source').to.equal(optionalParameters.source); @@ -10155,6 +10157,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { section: 'Products', intentResultId: '123451', threadId: 'thread-123', + uiLibrary: 'cio-ui-mocha-1.0.0', }; it('Should respond with a valid response when term and required parameters are provided', (done) => { @@ -10302,6 +10305,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { // Request expect(fetchSpy).to.have.been.called; + expect(helpers.extractUrlParamsFromFetch(fetchSpy)).to.have.property('ui_library').to.equal(optionalParameters.uiLibrary); expect(requestParams).to.have.property('section').to.equal(optionalParameters.section); expect(requestParams).to.have.property('intent_result_id').to.equal(optionalParameters.intentResultId); expect(requestParams).to.have.property('thread_id').to.equal(optionalParameters.threadId); @@ -10474,6 +10478,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { section: 'Products', intentResultId: '123451', threadId: 'thread-123', + uiLibrary: 'cio-ui-mocha-1.0.0', }; it('Should respond with a valid response when term and required parameters are provided', (done) => { @@ -10622,6 +10627,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { // Request expect(fetchSpy).to.have.been.called; + expect(helpers.extractUrlParamsFromFetch(fetchSpy)).to.have.property('ui_library').to.equal(optionalParameters.uiLibrary); expect(requestParams).to.have.property('section').to.equal(optionalParameters.section); expect(requestParams).to.have.property('intent_result_id').to.equal(optionalParameters.intentResultId); expect(requestParams).to.have.property('thread_id').to.equal(optionalParameters.threadId); @@ -10800,6 +10806,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { intentResultId: '12312', variationId: '123123', threadId: 'thread-123', + uiLibrary: 'cio-ui-mocha-1.0.0', }; it('Should respond with a valid response when required parameters are provided', (done) => { @@ -10950,6 +10957,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { // Request expect(fetchSpy).to.have.been.called; + expect(helpers.extractUrlParamsFromFetch(fetchSpy)).to.have.property('ui_library').to.equal(optionalParameters.uiLibrary); expect(requestParams).to.have.property('intent_result_id').to.equal(optionalParameters.intentResultId); expect(requestParams).to.have.property('section').to.equal(optionalParameters.section); expect(requestParams).to.have.property('variation_id').to.equal(optionalParameters.variationId); @@ -11137,6 +11145,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { itemId: '789', }, ], + uiLibrary: 'cio-ui-mocha-1.0.0', }; const snakeCaseItems = [ { @@ -11296,6 +11305,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { // Request expect(fetchSpy).to.have.been.called; + expect(helpers.extractUrlParamsFromFetch(fetchSpy)).to.have.property('ui_library').to.equal(optionalParameters.uiLibrary); expect(requestParams).to.have.property('intent_result_id').to.equal(optionalParameters.intentResultId); expect(requestParams).to.have.property('items').to.deep.equal(snakeCaseItems); expect(requestParams).to.have.property('section').to.equal(optionalParameters.section); @@ -11468,6 +11478,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { section: 'Products', intentResultId: '1234', threadId: 'thread-123', + uiLibrary: 'cio-ui-mocha-1.0.0', }; it('Should respond with a valid response when term and required parameters are provided', (done) => { @@ -11617,6 +11628,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { // Request expect(fetchSpy).to.have.been.called; + expect(helpers.extractUrlParamsFromFetch(fetchSpy)).to.have.property('ui_library').to.equal(optionalParameters.uiLibrary); expect(requestParams).to.have.property('section').to.equal(optionalParameters.section); expect(requestParams).to.have.property('intent_result_id').to.equal(optionalParameters.intentResultId); expect(requestParams).to.have.property('thread_id').to.equal(optionalParameters.threadId); @@ -11789,6 +11801,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { positionOnPage: 'search_bar', pageType: 'search', instanceId: 1, + uiLibrary: 'cio-ui-mocha-1.0.0', }; it('Should respond with a valid response when required parameters are provided', (done) => { @@ -11938,6 +11951,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { // Request expect(fetchSpy).to.have.been.called; + expect(helpers.extractUrlParamsFromFetch(fetchSpy)).to.have.property('ui_library').to.equal(optionalParameters.uiLibrary); expect(requestParams).to.have.property('section').to.equal('Products'); expect(requestParams).to.have.property('position_on_page').to.equal(optionalParameters.positionOnPage); expect(requestParams).to.have.property('page_type').to.equal(optionalParameters.pageType); @@ -12146,6 +12160,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { const requiredParameters = { intent: 'Show me cookie recipes' }; const optionalParameters = { section: 'Products', + uiLibrary: 'cio-ui-mocha-1.0.0', }; it('Should respond with a valid response when intent and required parameters are provided', (done) => { @@ -12293,6 +12308,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { // Request expect(fetchSpy).to.have.been.called; + expect(helpers.extractUrlParamsFromFetch(fetchSpy)).to.have.property('ui_library').to.equal(optionalParameters.uiLibrary); expect(requestParams).to.have.property('section').to.equal('Products'); // Response @@ -12461,6 +12477,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { const optionalParameters = { section: 'Products', intentResultId: '123451', + uiLibrary: 'cio-ui-mocha-1.0.0', }; it('Should respond with a valid response when term and required parameters are provided', (done) => { @@ -12608,6 +12625,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { // Request expect(fetchSpy).to.have.been.called; + expect(helpers.extractUrlParamsFromFetch(fetchSpy)).to.have.property('ui_library').to.equal(optionalParameters.uiLibrary); expect(requestParams).to.have.property('section').to.equal(optionalParameters.section); expect(requestParams).to.have.property('intent_result_id').to.equal(optionalParameters.intentResultId); @@ -12778,6 +12796,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { const optionalParameters = { section: 'Products', intentResultId: '123451', + uiLibrary: 'cio-ui-mocha-1.0.0', }; it('Should respond with a valid response when term and required parameters are provided', (done) => { @@ -12926,6 +12945,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { // Request expect(fetchSpy).to.have.been.called; + expect(helpers.extractUrlParamsFromFetch(fetchSpy)).to.have.property('ui_library').to.equal(optionalParameters.uiLibrary); expect(requestParams).to.have.property('section').to.equal(optionalParameters.section); expect(requestParams).to.have.property('intent_result_id').to.equal(optionalParameters.intentResultId); @@ -13102,6 +13122,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { section: 'Products', intentResultId: '12312', variationId: '123123', + uiLibrary: 'cio-ui-mocha-1.0.0', }; it('Should respond with a valid response when required parameters are provided', (done) => { @@ -13252,6 +13273,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { // Request expect(fetchSpy).to.have.been.called; + expect(helpers.extractUrlParamsFromFetch(fetchSpy)).to.have.property('ui_library').to.equal(optionalParameters.uiLibrary); expect(requestParams).to.have.property('intent_result_id').to.equal(optionalParameters.intentResultId); expect(requestParams).to.have.property('section').to.equal(optionalParameters.section); expect(requestParams).to.have.property('variation_id').to.equal(optionalParameters.variationId); @@ -13437,6 +13459,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { itemId: '789', }, ], + uiLibrary: 'cio-ui-mocha-1.0.0', }; const snakeCaseItems = [ { @@ -13596,6 +13619,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { // Request expect(fetchSpy).to.have.been.called; + expect(helpers.extractUrlParamsFromFetch(fetchSpy)).to.have.property('ui_library').to.equal(optionalParameters.uiLibrary); expect(requestParams).to.have.property('intent_result_id').to.equal(optionalParameters.intentResultId); expect(requestParams).to.have.property('items').to.deep.equal(snakeCaseItems); expect(requestParams).to.have.property('section').to.equal(optionalParameters.section); @@ -13766,6 +13790,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { const optionalParameters = { section: 'Products', intentResultId: '1234', + uiLibrary: 'cio-ui-mocha-1.0.0', }; it('Should respond with a valid response when term and required parameters are provided', (done) => { @@ -13915,6 +13940,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { // Request expect(fetchSpy).to.have.been.called; + expect(helpers.extractUrlParamsFromFetch(fetchSpy)).to.have.property('ui_library').to.equal(optionalParameters.uiLibrary); expect(requestParams).to.have.property('section').to.equal(optionalParameters.section); expect(requestParams).to.have.property('intent_result_id').to.equal(optionalParameters.intentResultId); @@ -14103,6 +14129,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { section: 'Products', variationId: '2', threadId: 'thread-123', + uiLibrary: 'cio-ui-mocha-1.0.0', }; it('Should respond with a valid response when term and required parameters are provided', (done) => { @@ -14254,6 +14281,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { // Request expect(fetchSpy).to.have.been.called; + expect(helpers.extractUrlParamsFromFetch(fetchSpy)).to.have.property('ui_library').to.equal(optionalParameters.uiLibrary); expect(requestParams).to.have.property('section').to.equal(optionalParameters.section); expect(bodyParams).to.have.property('variation_id').to.equal(optionalParameters.variationId); expect(bodyParams).to.have.property('thread_id').to.equal(optionalParameters.threadId); @@ -14435,6 +14463,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { section: 'Products', variationId: '2', threadId: 'thread-123', + uiLibrary: 'cio-ui-mocha-1.0.0', }; it('Should respond with a valid response when term and required parameters are provided', (done) => { @@ -14585,6 +14614,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { // Request expect(fetchSpy).to.have.been.called; + expect(helpers.extractUrlParamsFromFetch(fetchSpy)).to.have.property('ui_library').to.equal(optionalParameters.uiLibrary); expect(requestParams).to.have.property('section').to.equal(optionalParameters.section); expect(bodyParams).to.have.property('variation_id').to.equal(optionalParameters.variationId); expect(bodyParams).to.have.property('thread_id').to.equal(optionalParameters.threadId); @@ -14758,6 +14788,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { section: 'Products', variationId: '2', threadId: 'thread-123', + uiLibrary: 'cio-ui-mocha-1.0.0', }; it('Should respond with a valid response when term and required parameters are provided', (done) => { @@ -14909,6 +14940,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { // Request expect(fetchSpy).to.have.been.called; + expect(helpers.extractUrlParamsFromFetch(fetchSpy)).to.have.property('ui_library').to.equal(optionalParameters.uiLibrary); expect(requestParams).to.have.property('section').to.equal(optionalParameters.section); expect(bodyParams).to.have.property('variation_id').to.equal(optionalParameters.variationId); expect(bodyParams).to.have.property('thread_id').to.equal(optionalParameters.threadId); @@ -15082,6 +15114,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { section: 'Products', variationId: '2', threadId: 'thread-123', + uiLibrary: 'cio-ui-mocha-1.0.0', }; it('Should respond with a valid response when term and required parameters are provided', (done) => { @@ -15231,6 +15264,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { // Request expect(fetchSpy).to.have.been.called; + expect(helpers.extractUrlParamsFromFetch(fetchSpy)).to.have.property('ui_library').to.equal(optionalParameters.uiLibrary); expect(requestParams).to.have.property('section').to.equal(optionalParameters.section); expect(bodyParams).to.have.property('variation_id').to.equal(optionalParameters.variationId); expect(bodyParams).to.have.property('thread_id').to.equal(optionalParameters.threadId); @@ -15405,6 +15439,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { variationId: '2', threadId: 'thread-123', questionTopic: 'pricing', + uiLibrary: 'cio-ui-mocha-1.0.0', }; it('Should respond with a valid response when term and required parameters are provided', (done) => { @@ -15555,6 +15590,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { // Request expect(fetchSpy).to.have.been.called; + expect(helpers.extractUrlParamsFromFetch(fetchSpy)).to.have.property('ui_library').to.equal(optionalParameters.uiLibrary); expect(requestParams).to.have.property('section').to.equal(optionalParameters.section); expect(bodyParams).to.have.property('variation_id').to.equal(optionalParameters.variationId); expect(bodyParams).to.have.property('thread_id').to.equal(optionalParameters.threadId); @@ -15730,6 +15766,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { variationId: '2', threadId: 'thread-123', questionTopic: 'pricing', + uiLibrary: 'cio-ui-mocha-1.0.0', }; it('Should respond with a valid response when term and required parameters are provided', (done) => { @@ -15880,6 +15917,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { // Request expect(fetchSpy).to.have.been.called; + expect(helpers.extractUrlParamsFromFetch(fetchSpy)).to.have.property('ui_library').to.equal(optionalParameters.uiLibrary); expect(requestParams).to.have.property('section').to.equal(optionalParameters.section); expect(bodyParams).to.have.property('variation_id').to.equal(optionalParameters.variationId); expect(bodyParams).to.have.property('thread_id').to.equal(optionalParameters.threadId); @@ -16057,6 +16095,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { threadId: 'thread-123', items: [{ itemId: 'rec1', itemName: 'Rec Product 1' }, { itemId: 'rec2', itemName: 'Rec Product 2' }], followUpQuestions: [{ value: 'What about size?' }, { value: 'Is it machine washable?' }], + uiLibrary: 'cio-ui-mocha-1.0.0', }; it('Should respond with a valid response when term and required parameters are provided', (done) => { @@ -16208,6 +16247,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { // Request expect(fetchSpy).to.have.been.called; + expect(helpers.extractUrlParamsFromFetch(fetchSpy)).to.have.property('ui_library').to.equal(optionalParameters.uiLibrary); expect(requestParams).to.have.property('section').to.equal(optionalParameters.section); expect(bodyParams).to.have.property('variation_id').to.equal(optionalParameters.variationId); expect(bodyParams).to.have.property('qna_result_id').to.equal(optionalParameters.qnaResultId); @@ -16388,6 +16428,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { variationId: '2', qnaResultId: '0daf0015-fc29-4727-9140-8d5313a1902c', threadId: 'thread-123', + uiLibrary: 'cio-ui-mocha-1.0.0', }; it('Should respond with a valid response when term and required parameters are provided', (done) => { @@ -16537,6 +16578,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { const requestParams = helpers.extractUrlParamsFromFetch(fetchSpy); // Request expect(fetchSpy).to.have.been.called; + expect(helpers.extractUrlParamsFromFetch(fetchSpy)).to.have.property('ui_library').to.equal(optionalParameters.uiLibrary); expect(requestParams).to.have.property('section').to.equal(optionalParameters.section); expect(bodyParams).to.have.property('qna_result_id').to.equal(optionalParameters.qnaResultId); expect(bodyParams).to.have.property('variation_id').to.equal(optionalParameters.variationId); @@ -16715,6 +16757,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { seedVariationId: 'seed-var-1', threadId: 'thread-123', qnaResultId: '0daf0015-fc29-4727-9140-8d5313a1902c', + uiLibrary: 'cio-ui-mocha-1.0.0', }; it('Should respond with a valid response when required parameters are provided', (done) => { @@ -16762,6 +16805,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { const requestParams = helpers.extractUrlParamsFromFetch(fetchSpy); // Request expect(fetchSpy).to.have.been.called; + expect(helpers.extractUrlParamsFromFetch(fetchSpy)).to.have.property('ui_library').to.equal(optionalParameters.uiLibrary); expect(requestParams).to.have.property('section').to.equal(optionalParameters.section); expect(bodyParams).to.have.property('variation_id').to.equal(optionalParameters.variationId); expect(bodyParams).to.have.property('position').to.equal(optionalParameters.position); diff --git a/src/modules/tracker.js b/src/modules/tracker.js index 139597db..b539c44b 100644 --- a/src/modules/tracker.js +++ b/src/modules/tracker.js @@ -2739,6 +2739,7 @@ class Tracker { * @param {string} [parameters.section] - The section name for the item Ex. "Products" * @param {string} [parameters.threadId] - Thread ID for grouping events within a conversation * @param {string} [parameters.source] - How the intent was submitted Ex. "suggestion" + * @param {string} [parameters.uiLibrary] - Name and version of the UI library sending the event, sent as `ui_library` Ex. "cio-ui-pia-1.4.0" * @param {object} [networkParameters] - Parameters relevant to the network request * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds) * @returns {(true|Error)} @@ -2762,6 +2763,7 @@ class Tracker { intent, threadId, source, + uiLibrary, } = parameters; const bodyParams = { intent, @@ -2776,7 +2778,13 @@ class Tracker { bodyParams.source = source; } - const requestURL = `${baseUrl}${applyParamsAsString({}, this.options)}`; + const queryParams = {}; + + if (uiLibrary) { + queryParams.ui_library = uiLibrary; + } + + const requestURL = `${baseUrl}${applyParamsAsString(queryParams, this.options)}`; const requestMethod = 'POST'; const requestBody = applyParams(bodyParams, { ...this.options, @@ -2806,6 +2814,7 @@ class Tracker { * @param {string} [parameters.section] - The section name for the item Ex. "Products" * @param {string} [parameters.intentResultId] - The intent result id from the ASA response * @param {string} [parameters.threadId] - Thread ID for grouping events within a conversation + * @param {string} [parameters.uiLibrary] - Name and version of the UI library sending the event, sent as `ui_library` Ex. "cio-ui-pia-1.4.0" * @param {object} [networkParameters] - Parameters relevant to the network request * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds) * @returns {(true|Error)} @@ -2827,6 +2836,7 @@ class Tracker { intentResultId, intent, threadId, + uiLibrary, } = parameters; const bodyParams = { intent_result_id: intentResultId, @@ -2838,7 +2848,13 @@ class Tracker { bodyParams.thread_id = threadId; } - const requestURL = `${baseUrl}${applyParamsAsString({}, this.options)}`; + const queryParams = {}; + + if (uiLibrary) { + queryParams.ui_library = uiLibrary; + } + + const requestURL = `${baseUrl}${applyParamsAsString(queryParams, this.options)}`; const requestMethod = 'POST'; const requestBody = applyParams(bodyParams, { ...this.options, @@ -2869,6 +2885,7 @@ class Tracker { * @param {string} [parameters.section] - The section name for the item Ex. "Products" * @param {string} [parameters.intentResultId] - The intent result id from the ASA response * @param {string} [parameters.threadId] - Thread ID for grouping events within a conversation + * @param {string} [parameters.uiLibrary] - Name and version of the UI library sending the event, sent as `ui_library` Ex. "cio-ui-pia-1.4.0" * @param {object} [networkParameters] - Parameters relevant to the network request * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds) * @returns {(true|Error)} @@ -2892,6 +2909,7 @@ class Tracker { intentResultId, intent, threadId, + uiLibrary, } = parameters; const bodyParams = { intent_result_id: intentResultId, @@ -2904,7 +2922,13 @@ class Tracker { bodyParams.thread_id = threadId; } - const requestURL = `${baseUrl}${applyParamsAsString({}, this.options)}`; + const queryParams = {}; + + if (uiLibrary) { + queryParams.ui_library = uiLibrary; + } + + const requestURL = `${baseUrl}${applyParamsAsString(queryParams, this.options)}`; const requestMethod = 'POST'; const requestBody = applyParams(bodyParams, { ...this.options, @@ -2938,6 +2962,7 @@ class Tracker { * @param {string} [parameters.variationId] - Product item variation unique identifier * @param {string} [parameters.intentResultId] - Browse result identifier (returned in response from Constructor) * @param {string} [parameters.threadId] - Thread ID for grouping events within a conversation + * @param {string} [parameters.uiLibrary] - Name and version of the UI library sending the event, sent as `ui_library` Ex. "cio-ui-pia-1.4.0" * @param {object} [networkParameters] - Parameters relevant to the network request * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds) * @returns {(true|Error)} @@ -2966,6 +2991,7 @@ class Tracker { itemName, intent, threadId, + uiLibrary, } = parameters; const bodyParams = { @@ -2982,7 +3008,13 @@ class Tracker { bodyParams.thread_id = threadId; } - const requestURL = `${requestPath}${applyParamsAsString({}, this.options)}`; + const queryParams = {}; + + if (uiLibrary) { + queryParams.ui_library = uiLibrary; + } + + const requestURL = `${requestPath}${applyParamsAsString(queryParams, this.options)}`; const requestMethod = 'POST'; const requestBody = applyParams(bodyParams, { ...this.options, requestMethod }); @@ -3014,6 +3046,7 @@ class Tracker { * @param {string} [parameters.section] - The section name for the item Ex. "Products" * @param {string} [parameters.intentResultId] - Browse result identifier (returned in response from Constructor) * @param {string} [parameters.threadId] - Thread ID for grouping events within a conversation + * @param {string} [parameters.uiLibrary] - Name and version of the UI library sending the event, sent as `ui_library` Ex. "cio-ui-pia-1.4.0" * @param {object} [networkParameters] - Parameters relevant to the network request * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds) * @returns {(true|Error)} @@ -3041,6 +3074,7 @@ class Tracker { searchResultId, intent, threadId, + uiLibrary, } = parameters; const bodyParams = { @@ -3056,7 +3090,13 @@ class Tracker { bodyParams.thread_id = threadId; } - const requestURL = `${requestPath}${applyParamsAsString({}, this.options)}`; + const queryParams = {}; + + if (uiLibrary) { + queryParams.ui_library = uiLibrary; + } + + const requestURL = `${requestPath}${applyParamsAsString(queryParams, this.options)}`; const requestMethod = 'POST'; const requestBody = applyParams(bodyParams, { ...this.options, requestMethod }); @@ -3087,6 +3127,7 @@ class Tracker { * @param {string} [parameters.section] - The section name for the item Ex. "Products" * @param {string} [parameters.intentResultId] - intentResultId from the ASA response * @param {string} [parameters.threadId] - Thread ID for grouping events within a conversation + * @param {string} [parameters.uiLibrary] - Name and version of the UI library sending the event, sent as `ui_library` Ex. "cio-ui-pia-1.4.0" * @param {object} [networkParameters] - Parameters relevant to the network request * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds) * @returns {(true|Error)} @@ -3113,6 +3154,7 @@ class Tracker { searchResultId, intentResultId, threadId, + uiLibrary, } = parameters; const bodyParams = { @@ -3127,7 +3169,13 @@ class Tracker { bodyParams.thread_id = threadId; } - const requestURL = `${baseUrl}${applyParamsAsString({}, this.options)}`; + const queryParams = {}; + + if (uiLibrary) { + queryParams.ui_library = uiLibrary; + } + + const requestURL = `${baseUrl}${applyParamsAsString(queryParams, this.options)}`; const requestMethod = 'POST'; const requestBody = applyParams(bodyParams, { ...this.options, @@ -3159,6 +3207,7 @@ class Tracker { * @param {string} [parameters.pageType] - Page surface where the CTA was clicked. One of "home", "plp", "pdp", "search", "collection", "email_campaign", "cart" * @param {number} [parameters.instanceId] - 1-based positive integer distinguishing CTA instances with the same mode and position during one page view * @param {string} [parameters.section] - The section name for the item Ex. "Products" + * @param {string} [parameters.uiLibrary] - Name and version of the UI library sending the event, sent as `ui_library` Ex. "cio-ui-pia-1.4.0" * @param {object} [networkParameters] - Parameters relevant to the network request * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds) * @returns {(true|Error)} @@ -3183,6 +3232,7 @@ class Tracker { pageType, instanceId, section, + uiLibrary, } = parameters; if (!mode || typeof mode !== 'string') { @@ -3222,7 +3272,13 @@ class Tracker { bodyParams.instance_id = instanceId; } - const requestURL = `${baseUrl}${applyParamsAsString({}, this.options)}`; + const queryParams = {}; + + if (uiLibrary) { + queryParams.ui_library = uiLibrary; + } + + const requestURL = `${baseUrl}${applyParamsAsString(queryParams, this.options)}`; const requestMethod = 'POST'; const requestBody = applyParams(bodyParams, { ...this.options, @@ -3428,6 +3484,7 @@ class Tracker { * @param {string} [parameters.variationId] - Variation id whose page we are on * @param {string} [parameters.threadId] - Thread ID for grouping events within a conversation * @param {string} [parameters.section] - The section name for the item Ex. "Products" + * @param {string} [parameters.uiLibrary] - Name and version of the UI library sending the event, sent as `ui_library` Ex. "cio-ui-pia-1.4.0" * @param {object} [networkParameters] - Parameters relevant to the network request * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds) * @returns {(true|Error)} @@ -3468,6 +3525,7 @@ class Tracker { variationId, viewTimespans, threadId, + uiLibrary, } = parameters; const queryParams = {}; const bodyParams = { @@ -3486,6 +3544,10 @@ class Tracker { queryParams.section = section; } + if (uiLibrary) { + queryParams.ui_library = uiLibrary; + } + const requestURL = `${baseUrl}${applyParamsAsString(queryParams, this.options)}`; const requestMethod = 'POST'; const requestBody = applyParams(bodyParams, { @@ -3518,6 +3580,7 @@ class Tracker { * @param {string} [parameters.variationId] - Variation id whose page we are on * @param {string} [parameters.threadId] - Thread ID for grouping events within a conversation * @param {string} [parameters.section] - The section name for the item Ex. "Products" + * @param {string} [parameters.uiLibrary] - Name and version of the UI library sending the event, sent as `ui_library` Ex. "cio-ui-pia-1.4.0" * @param {object} [networkParameters] - Parameters relevant to the network request * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds) * @returns {(true|Error)} @@ -3547,6 +3610,7 @@ class Tracker { itemName, variationId, threadId, + uiLibrary, } = parameters; const queryParams = {}; const bodyParams = { @@ -3564,6 +3628,10 @@ class Tracker { queryParams.section = section; } + if (uiLibrary) { + queryParams.ui_library = uiLibrary; + } + const requestURL = `${baseUrl}${applyParamsAsString(queryParams, this.options)}`; const requestMethod = 'POST'; const requestBody = applyParams(bodyParams, { @@ -3595,6 +3663,7 @@ class Tracker { * @param {string} [parameters.variationId] - Variation id whose page we are on * @param {string} [parameters.threadId] - Thread ID for grouping events within a conversation * @param {string} [parameters.section] - The section name for the item Ex. "Products" + * @param {string} [parameters.uiLibrary] - Name and version of the UI library sending the event, sent as `ui_library` Ex. "cio-ui-pia-1.4.0" * @param {object} [networkParameters] - Parameters relevant to the network request * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds) * @returns {(true|Error)} @@ -3618,6 +3687,7 @@ class Tracker { itemName, variationId, threadId, + uiLibrary, } = parameters; const queryParams = {}; const bodyParams = { @@ -3634,6 +3704,10 @@ class Tracker { queryParams.section = section; } + if (uiLibrary) { + queryParams.ui_library = uiLibrary; + } + const requestURL = `${baseUrl}${applyParamsAsString(queryParams, this.options)}`; const requestMethod = 'POST'; const requestBody = applyParams(bodyParams, { @@ -3665,6 +3739,7 @@ class Tracker { * @param {string} [parameters.variationId] - Variation id whose page we are on * @param {string} [parameters.threadId] - Thread ID for grouping events within a conversation * @param {string} [parameters.section] - The section name for the item Ex. "Products" + * @param {string} [parameters.uiLibrary] - Name and version of the UI library sending the event, sent as `ui_library` Ex. "cio-ui-pia-1.4.0" * @param {object} [networkParameters] - Parameters relevant to the network request * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds) * @returns {(true|Error)} @@ -3688,6 +3763,7 @@ class Tracker { itemName, variationId, threadId, + uiLibrary, } = parameters; const queryParams = {}; const bodyParams = { @@ -3704,6 +3780,10 @@ class Tracker { queryParams.section = section; } + if (uiLibrary) { + queryParams.ui_library = uiLibrary; + } + const requestURL = `${baseUrl}${applyParamsAsString(queryParams, this.options)}`; const requestMethod = 'POST'; const requestBody = applyParams(bodyParams, { @@ -3737,6 +3817,7 @@ class Tracker { * @param {string} [parameters.threadId] - Thread ID for grouping events within a conversation * @param {string} [parameters.questionTopic] - Topic category of the question. * @param {string} [parameters.section] - The section name for the item Ex. "Products" + * @param {string} [parameters.uiLibrary] - Name and version of the UI library sending the event, sent as `ui_library` Ex. "cio-ui-pia-1.4.0" * @param {object} [networkParameters] - Parameters relevant to the network request * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds) * @returns {(true|Error)} @@ -3763,6 +3844,7 @@ class Tracker { question, threadId, questionTopic, + uiLibrary, } = parameters; const queryParams = {}; const bodyParams = { @@ -3784,6 +3866,10 @@ class Tracker { queryParams.section = section; } + if (uiLibrary) { + queryParams.ui_library = uiLibrary; + } + const requestURL = `${baseUrl}${applyParamsAsString(queryParams, this.options)}`; const requestMethod = 'POST'; const requestBody = applyParams(bodyParams, { @@ -3817,6 +3903,7 @@ class Tracker { * @param {string} [parameters.threadId] - Thread ID for grouping events within a conversation * @param {string} [parameters.questionTopic] - Topic category of the question * @param {string} [parameters.section] - The section name for the item Ex. "Products" + * @param {string} [parameters.uiLibrary] - Name and version of the UI library sending the event, sent as `ui_library` Ex. "cio-ui-pia-1.4.0" * @param {object} [networkParameters] - Parameters relevant to the network request * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds) * @returns {(true|Error)} @@ -3843,6 +3930,7 @@ class Tracker { question, threadId, questionTopic, + uiLibrary, } = parameters; const queryParams = {}; const bodyParams = { @@ -3864,6 +3952,10 @@ class Tracker { queryParams.section = section; } + if (uiLibrary) { + queryParams.ui_library = uiLibrary; + } + const requestURL = `${baseUrl}${applyParamsAsString(queryParams, this.options)}`; const requestMethod = 'POST'; const requestBody = applyParams(bodyParams, { @@ -3900,6 +3992,7 @@ class Tracker { * @param {string} [parameters.variationId] - Variation id whose page we are on * @param {string} [parameters.threadId] - Thread ID for grouping events within a conversation * @param {string} [parameters.section] - The section name for the item Ex. "Products" + * @param {string} [parameters.uiLibrary] - Name and version of the UI library sending the event, sent as `ui_library` Ex. "cio-ui-pia-1.4.0" * @param {object} [networkParameters] - Parameters relevant to the network request * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds) * @returns {(true|Error)} @@ -3931,6 +4024,7 @@ class Tracker { items, followUpQuestions, threadId, + uiLibrary, } = parameters; const queryParams = {}; const bodyParams = { @@ -3958,6 +4052,10 @@ class Tracker { queryParams.section = section; } + if (uiLibrary) { + queryParams.ui_library = uiLibrary; + } + const requestURL = `${baseUrl}${applyParamsAsString(queryParams, this.options)}`; const requestMethod = 'POST'; const requestBody = applyParams(bodyParams, { @@ -3991,6 +4089,7 @@ class Tracker { * @param {string} [parameters.variationId] - Variation id whose page we are on * @param {string} [parameters.threadId] - Thread ID for grouping events within a conversation * @param {string} [parameters.section] - The section name for the item Ex. "Products" + * @param {string} [parameters.uiLibrary] - Name and version of the UI library sending the event, sent as `ui_library` Ex. "cio-ui-pia-1.4.0" * @param {object} [networkParameters] - Parameters relevant to the network request * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds) * @returns {(true|Error)} @@ -4018,6 +4117,7 @@ class Tracker { feedbackLabel, qnaResultId, threadId, + uiLibrary, } = parameters; const queryParams = {}; const bodyParams = { @@ -4036,6 +4136,10 @@ class Tracker { queryParams.section = section; } + if (uiLibrary) { + queryParams.ui_library = uiLibrary; + } + const requestURL = `${baseUrl}${applyParamsAsString(queryParams, this.options)}`; const requestMethod = 'POST'; const requestBody = applyParams(bodyParams, { @@ -4073,6 +4177,7 @@ class Tracker { * @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" + * @param {string} [parameters.uiLibrary] - Name and version of the UI library sending the event, sent as `ui_library` Ex. "cio-ui-pia-1.4.0" * @param {object} [networkParameters] - Parameters relevant to the network request * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds) * @returns {(true|Error)} @@ -4104,6 +4209,7 @@ class Tracker { seedVariationId, qnaResultId, threadId, + uiLibrary, } = parameters; const queryParams = {}; const bodyParams = { @@ -4138,6 +4244,10 @@ class Tracker { queryParams.section = section; } + if (uiLibrary) { + queryParams.ui_library = uiLibrary; + } + const requestURL = `${baseUrl}${applyParamsAsString(queryParams, this.options)}`; const requestMethod = 'POST'; const requestBody = applyParams(bodyParams, { diff --git a/src/types/tracker.d.ts b/src/types/tracker.d.ts index dbcde5f1..b35c668c 100644 --- a/src/types/tracker.d.ts +++ b/src/types/tracker.d.ts @@ -285,6 +285,7 @@ declare class Tracker { section?: string; threadId?: string; source?: string; + uiLibrary?: string; }, networkParameters?: NetworkParameters ): true | Error; @@ -295,6 +296,7 @@ declare class Tracker { section?: string; intentResultId?: string; threadId?: string; + uiLibrary?: string; }, networkParameters?: NetworkParameters ): true | Error; @@ -306,6 +308,7 @@ declare class Tracker { section?: string; intentResultId?: string; threadId?: string; + uiLibrary?: string; }, networkParameters?: NetworkParameters ): true | Error; @@ -320,6 +323,7 @@ declare class Tracker { section?: string; intentResultId?: string; threadId?: string; + uiLibrary?: string; }, networkParameters?: NetworkParameters ): true | Error; @@ -333,6 +337,7 @@ declare class Tracker { intentResultId?: string; section?: string; threadId?: string; + uiLibrary?: string; }, networkParameters?: NetworkParameters ): true | Error; @@ -347,6 +352,7 @@ declare class Tracker { section?: string; intentResultId?: string; threadId?: string; + uiLibrary?: string; }, networkParameters?: NetworkParameters ): true | Error; @@ -359,6 +365,7 @@ declare class Tracker { pageType?: 'home' | 'plp' | 'pdp' | 'search' | 'collection' | 'email_campaign' | 'cart'; instanceId?: number; section?: string; + uiLibrary?: string; }, networkParameters?: NetworkParameters ): true | Error; @@ -384,6 +391,7 @@ declare class Tracker { variationId?: string; threadId?: string; section?: string; + uiLibrary?: string; }, networkParameters?: NetworkParameters ): true | Error; @@ -396,6 +404,7 @@ declare class Tracker { variationId?: string; threadId?: string; section?: string; + uiLibrary?: string; }, networkParameters?: NetworkParameters ): true | Error; @@ -407,6 +416,7 @@ declare class Tracker { variationId?: string; threadId?: string; section?: string; + uiLibrary?: string; }, networkParameters?: NetworkParameters ): true | Error; @@ -418,6 +428,7 @@ declare class Tracker { variationId?: string; threadId?: string; section?: string; + uiLibrary?: string; }, networkParameters?: NetworkParameters ): true | Error; @@ -431,6 +442,7 @@ declare class Tracker { threadId?: string; questionTopic?: string; section?: string; + uiLibrary?: string; }, networkParameters?: NetworkParameters ): true | Error; @@ -444,6 +456,7 @@ declare class Tracker { threadId?: string; questionTopic?: string; section?: string; + uiLibrary?: string; }, networkParameters?: NetworkParameters ): true | Error; @@ -460,6 +473,7 @@ declare class Tracker { variationId?: string; threadId?: string; section?: string; + uiLibrary?: string; }, networkParameters?: NetworkParameters ): true | Error; @@ -473,6 +487,7 @@ declare class Tracker { variationId?: string; threadId?: string; section?: string; + uiLibrary?: string; }, networkParameters?: NetworkParameters ): true | Error; @@ -490,6 +505,7 @@ declare class Tracker { variationId?: string; threadId?: string; section?: string; + uiLibrary?: string; }, networkParameters?: NetworkParameters ): true | Error;