From 7186d55dd531e980c44412f19b8a66cc86953a34 Mon Sep 17 00:00:00 2001 From: Chris Gee Date: Thu, 18 Jan 2024 11:42:08 -0800 Subject: [PATCH 1/2] Add dateTime param --- spec/src/modules/tracker.js | 378 ++++++++++++++++++++++++++++++++++++ src/modules/tracker.js | 17 +- src/types/tracker.d.ts | 1 + 3 files changed, 395 insertions(+), 1 deletion(-) diff --git a/spec/src/modules/tracker.js b/spec/src/modules/tracker.js index b53c8de4..ad64a5b2 100644 --- a/spec/src/modules/tracker.js +++ b/spec/src/modules/tracker.js @@ -419,6 +419,33 @@ describe('ConstructorIO - Tracker', () => { })).to.equal(true); }); + it('Should respond with a valid response with dateTime', (done) => { + const dateTime = 123456789; + const { tracker } = new ConstructorIO({ + apiKey: testApiKey, + fetch: fetchSpy, + }); + + tracker.on('success', (responseParams) => { + const requestedHeaders = helpers.extractHeadersFromFetch(fetchSpy); + + // Request + expect(fetchSpy).to.have.been.called; + expect(requestedHeaders).to.have.property('_dt').to.equal(dateTime); + + // Response + expect(responseParams).to.have.property('method').to.equal('GET'); + expect(responseParams).to.have.property('message').to.equal('ok'); + + done(); + }); + + expect(tracker.trackSessionStart({ + ...userParameters, + dateTime, + })).to.equal(true); + }); + it('Should respond with a valid response with referer', (done) => { const referer = 'https://localhost'; const { tracker } = new ConstructorIO({ @@ -893,6 +920,33 @@ describe('ConstructorIO - Tracker', () => { })).to.equal(true); }); + it('Should respond with a valid response with dateTime', (done) => { + const dateTime = 123456789; + const { tracker } = new ConstructorIO({ + apiKey: testApiKey, + fetch: fetchSpy, + }); + + tracker.on('success', (responseParams) => { + const requestedHeaders = helpers.extractHeadersFromFetch(fetchSpy); + + // Request + expect(fetchSpy).to.have.been.called; + expect(requestedHeaders).to.have.property('_dt').to.equal(dateTime); + + // Response + expect(responseParams).to.have.property('method').to.equal('GET'); + expect(responseParams).to.have.property('message').to.equal('ok'); + + done(); + }); + + expect(tracker.trackInputFocus({ + ...userParameters, + dateTime, + })).to.equal(true); + }); + it('Should respond with a valid response with referer', (done) => { const referer = 'https://localhost'; const { tracker } = new ConstructorIO({ @@ -1388,6 +1442,33 @@ describe('ConstructorIO - Tracker', () => { })).to.equal(true); }); + it('Should respond with a valid response with dateTime', (done) => { + const dateTime = 123456789; + const { tracker } = new ConstructorIO({ + apiKey: testApiKey, + fetch: fetchSpy, + }); + + tracker.on('success', (responseParams) => { + const requestedHeaders = helpers.extractHeadersFromFetch(fetchSpy); + + // Request + expect(fetchSpy).to.have.been.called; + expect(requestedHeaders).to.have.property('_dt').to.equal(dateTime); + + // Response + expect(responseParams).to.have.property('method').to.equal('GET'); + expect(responseParams).to.have.property('message').to.equal('ok'); + + done(); + }); + + expect(tracker.trackAutocompleteSelect(term, requiredParameters, { + ...userParameters, + dateTime, + })).to.equal(true); + }); + it('Should respond with a valid response with referer', (done) => { const referer = 'https://localhost'; const { tracker } = new ConstructorIO({ @@ -2013,6 +2094,33 @@ describe('ConstructorIO - Tracker', () => { })).to.equal(true); }); + it('Should respond with a valid response with dateTime', (done) => { + const dateTime = 123456789; + const { tracker } = new ConstructorIO({ + apiKey: testApiKey, + fetch: fetchSpy, + }); + + tracker.on('success', (responseParams) => { + const requestedHeaders = helpers.extractHeadersFromFetch(fetchSpy); + + // Request + expect(fetchSpy).to.have.been.called; + expect(requestedHeaders).to.have.property('_dt').to.equal(dateTime); + + // Response + expect(responseParams).to.have.property('method').to.equal('POST'); + expect(responseParams).to.have.property('message').to.equal('ok'); + + done(); + }); + + expect(tracker.trackItemDetailLoad(requiredParameters, { + ...userParameters, + dateTime, + })).to.equal(true); + }); + it('Should respond with a valid response with referer', (done) => { const referer = 'https://localhost'; const { tracker } = new ConstructorIO({ @@ -2332,6 +2440,33 @@ describe('ConstructorIO - Tracker', () => { })).to.equal(true); }); + it('Should respond with a valid response with dateTime', (done) => { + const dateTime = 123456789; + const { tracker } = new ConstructorIO({ + apiKey: testApiKey, + fetch: fetchSpy, + }); + + tracker.on('success', (responseParams) => { + const requestedHeaders = helpers.extractHeadersFromFetch(fetchSpy); + + // Request + expect(fetchSpy).to.have.been.called; + expect(requestedHeaders).to.have.property('_dt').to.equal(dateTime); + + // Response + expect(responseParams).to.have.property('method').to.equal('GET'); + expect(responseParams).to.have.property('message').to.equal('ok'); + + done(); + }); + + expect(tracker.trackSearchSubmit(term, requiredParameters, { + ...userParameters, + dateTime, + })).to.equal(true); + }); + it('Should respond with a valid response with referer', (done) => { const referer = 'https://localhost'; const { tracker } = new ConstructorIO({ @@ -2822,6 +2957,33 @@ describe('ConstructorIO - Tracker', () => { })).to.equal(true); }); + it('Should respond with a valid response with dateTime', (done) => { + const dateTime = 123456789; + const { tracker } = new ConstructorIO({ + apiKey: testApiKey, + fetch: fetchSpy, + }); + + tracker.on('success', (responseParams) => { + const requestedHeaders = helpers.extractHeadersFromFetch(fetchSpy); + + // Request + expect(fetchSpy).to.have.been.called; + expect(requestedHeaders).to.have.property('_dt').to.equal(dateTime); + + // Response + expect(responseParams).to.have.property('method').to.equal('GET'); + expect(responseParams).to.have.property('message').to.equal('ok'); + + done(); + }); + + expect(tracker.trackSearchResultsLoaded(term, requiredParameters, { + ...userParameters, + dateTime, + })).to.equal(true); + }); + it('Should respond with a valid response with referer', (done) => { const referer = 'https://localhost'; const { tracker } = new ConstructorIO({ @@ -3416,6 +3578,33 @@ describe('ConstructorIO - Tracker', () => { })).to.equal(true); }); + it('Should respond with a valid response with dateTime', (done) => { + const dateTime = 123456789; + const { tracker } = new ConstructorIO({ + apiKey: testApiKey, + fetch: fetchSpy, + }); + + tracker.on('success', (responseParams) => { + const requestedHeaders = helpers.extractHeadersFromFetch(fetchSpy); + + // Request + expect(fetchSpy).to.have.been.called; + expect(requestedHeaders).to.have.property('_dt').to.equal(dateTime); + + // Response + expect(responseParams).to.have.property('method').to.equal('GET'); + expect(responseParams).to.have.property('message').to.equal('ok'); + + done(); + }); + + expect(tracker.trackSearchResultClick(term, requiredParameters, { + ...userParameters, + dateTime, + })).to.equal(true); + }); + it('Should respond with a valid response with referer', (done) => { const referer = 'https://localhost'; const { tracker } = new ConstructorIO({ @@ -4090,6 +4279,33 @@ describe('ConstructorIO - Tracker', () => { })).to.equal(true); }); + it('Should respond with a valid response with dateTime', (done) => { + const dateTime = 123456789; + const { tracker } = new ConstructorIO({ + apiKey: testApiKey, + fetch: fetchSpy, + }); + + tracker.on('success', (responseParams) => { + const requestedHeaders = helpers.extractHeadersFromFetch(fetchSpy); + + // Request + expect(fetchSpy).to.have.been.called; + expect(requestedHeaders).to.have.property('_dt').to.equal(dateTime); + + // Response + expect(responseParams).to.have.property('method').to.equal('POST'); + expect(responseParams).to.have.property('message').to.equal('ok'); + + done(); + }); + + expect(tracker.trackConversion(term, requiredParameters, { + ...userParameters, + dateTime, + })).to.equal(true); + }); + it('Should respond with a valid response with referer', (done) => { const referer = 'https://localhost'; const { tracker } = new ConstructorIO({ @@ -4793,6 +5009,33 @@ describe('ConstructorIO - Tracker', () => { })).to.equal(true); }); + it('Should respond with a valid response with dateTime', (done) => { + const dateTime = 123456789; + const { tracker } = new ConstructorIO({ + apiKey: testApiKey, + fetch: fetchSpy, + }); + + tracker.on('success', (responseParams) => { + const requestedHeaders = helpers.extractHeadersFromFetch(fetchSpy); + + // Request + expect(fetchSpy).to.have.been.called; + expect(requestedHeaders).to.have.property('_dt').to.equal(dateTime); + + // Response + expect(responseParams).to.have.property('method').to.equal('POST'); + expect(responseParams).to.have.property('message').to.equal('ok'); + + done(); + }); + + expect(tracker.trackPurchase(requiredParameters, { + ...userParameters, + dateTime, + })).to.equal(true); + }); + it('Should respond with a valid response with referer', (done) => { const referer = 'https://localhost'; const { tracker } = new ConstructorIO({ @@ -5352,6 +5595,33 @@ describe('ConstructorIO - Tracker', () => { })).to.equal(true); }); + it('Should respond with a valid response with dateTime', (done) => { + const dateTime = 123456789; + const { tracker } = new ConstructorIO({ + apiKey: testApiKey, + fetch: fetchSpy, + }); + + tracker.on('success', (responseParams) => { + const requestedHeaders = helpers.extractHeadersFromFetch(fetchSpy); + + // Request + expect(fetchSpy).to.have.been.called; + expect(requestedHeaders).to.have.property('_dt').to.equal(dateTime); + + // Response + expect(responseParams).to.have.property('method').to.equal('POST'); + expect(responseParams).to.have.property('message').to.equal('ok'); + + done(); + }); + + expect(tracker.trackRecommendationView(requiredParameters, { + ...userParameters, + dateTime, + })).to.equal(true); + }); + it('Should respond with a valid response with referer', (done) => { const referer = 'https://localhost'; const { tracker } = new ConstructorIO({ @@ -5861,6 +6131,33 @@ describe('ConstructorIO - Tracker', () => { })).to.equal(true); }); + it('Should respond with a valid response with dateTime', (done) => { + const dateTime = 123456789; + const { tracker } = new ConstructorIO({ + apiKey: testApiKey, + fetch: fetchSpy, + }); + + tracker.on('success', (responseParams) => { + const requestedHeaders = helpers.extractHeadersFromFetch(fetchSpy); + + // Request + expect(fetchSpy).to.have.been.called; + expect(requestedHeaders).to.have.property('_dt').to.equal(dateTime); + + // Response + expect(responseParams).to.have.property('method').to.equal('POST'); + expect(responseParams).to.have.property('message').to.equal('ok'); + + done(); + }); + + expect(tracker.trackRecommendationClick(requiredParameters, { + ...userParameters, + dateTime, + })).to.equal(true); + }); + it('Should respond with a valid response with referer', (done) => { const referer = 'https://localhost'; const { tracker } = new ConstructorIO({ @@ -6388,6 +6685,33 @@ describe('ConstructorIO - Tracker', () => { })).to.equal(true); }); + it('Should respond with a valid response with dateTime', (done) => { + const dateTime = 123456789; + const { tracker } = new ConstructorIO({ + apiKey: testApiKey, + fetch: fetchSpy, + }); + + tracker.on('success', (responseParams) => { + const requestedHeaders = helpers.extractHeadersFromFetch(fetchSpy); + + // Request + expect(fetchSpy).to.have.been.called; + expect(requestedHeaders).to.have.property('_dt').to.equal(dateTime); + + // Response + expect(responseParams).to.have.property('method').to.equal('POST'); + expect(responseParams).to.have.property('message').to.equal('ok'); + + done(); + }); + + expect(tracker.trackBrowseResultsLoaded(requiredParameters, { + ...userParameters, + dateTime, + })).to.equal(true); + }); + it('Should respond with a valid response with referer', (done) => { const referer = 'https://localhost'; const { tracker } = new ConstructorIO({ @@ -6934,6 +7258,33 @@ describe('ConstructorIO - Tracker', () => { })).to.equal(true); }); + it('Should respond with a valid response with dateTime', (done) => { + const dateTime = 123456789; + const { tracker } = new ConstructorIO({ + apiKey: testApiKey, + fetch: fetchSpy, + }); + + tracker.on('success', (responseParams) => { + const requestedHeaders = helpers.extractHeadersFromFetch(fetchSpy); + + // Request + expect(fetchSpy).to.have.been.called; + expect(requestedHeaders).to.have.property('_dt').to.equal(dateTime); + + // Response + expect(responseParams).to.have.property('method').to.equal('POST'); + expect(responseParams).to.have.property('message').to.equal('ok'); + + done(); + }); + + expect(tracker.trackBrowseResultClick(requiredParameters, { + ...userParameters, + dateTime, + })).to.equal(true); + }); + it('Should respond with a valid response with referer', (done) => { const referer = 'https://localhost'; const { tracker } = new ConstructorIO({ @@ -7458,6 +7809,33 @@ describe('ConstructorIO - Tracker', () => { })).to.equal(true); }); + it('Should respond with a valid response with dateTime', (done) => { + const dateTime = 123456789; + const { tracker } = new ConstructorIO({ + apiKey: testApiKey, + fetch: fetchSpy, + }); + + tracker.on('success', (responseParams) => { + const requestedHeaders = helpers.extractHeadersFromFetch(fetchSpy); + + // Request + expect(fetchSpy).to.have.been.called; + expect(requestedHeaders).to.have.property('_dt').to.equal(dateTime); + + // Response + expect(responseParams).to.have.property('method').to.equal('POST'); + expect(responseParams).to.have.property('message').to.equal('ok'); + + done(); + }); + + expect(tracker.trackGenericResultClick(requiredParameters, { + ...userParameters, + dateTime, + })).to.equal(true); + }); + it('Should respond with a valid response with referer', (done) => { const referer = 'https://localhost'; const { tracker } = new ConstructorIO({ diff --git a/src/modules/tracker.js b/src/modules/tracker.js index ceeee08c..705be85f 100644 --- a/src/modules/tracker.js +++ b/src/modules/tracker.js @@ -16,6 +16,7 @@ function applyParams(parameters, userParameters, options) { segments, testCells, originReferrer, + dateTime, } = userParameters || {}; let aggregateParams = Object.assign(parameters); @@ -63,7 +64,7 @@ function applyParams(parameters, userParameters, options) { aggregateParams.origin_referrer = originReferrer; } - aggregateParams._dt = Date.now(); + aggregateParams._dt = dateTime || Date.now(); aggregateParams.beacon = true; aggregateParams = helpers.cleanParams(aggregateParams); @@ -202,6 +203,7 @@ class Tracker { * @param {string} [userParameters.userIp] - Client user IP * @param {string} [userParameters.userAgent] - Client user agent * @param {string} [userParameters.acceptLanguage] - Client accept language + * @param {string} [userParameters.dateTime] - Time since epoch in milliseconds * @param {object} [networkParameters] - Parameters relevant to the network request * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds) * @returns {(true|Error)} @@ -242,6 +244,7 @@ class Tracker { * @param {string} [userParameters.userIp] - Client user IP * @param {string} [userParameters.userAgent] - Client user agent * @param {string} [userParameters.acceptLanguage] - Client accept language + * @param {string} [userParameters.dateTime] - Time since epoch in milliseconds * @param {object} [networkParameters] - Parameters relevant to the network request * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds) * @returns {(true|Error)} @@ -290,6 +293,7 @@ class Tracker { * @param {string} [userParameters.userIp] - Client user IP * @param {string} [userParameters.userAgent] - Client user agent * @param {string} [userParameters.acceptLanguage] - Client accept language + * @param {string} [userParameters.dateTime] - Time since epoch in milliseconds * @param {object} [networkParameters] - Parameters relevant to the network request * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds) * @returns {(true|Error)} @@ -390,6 +394,7 @@ class Tracker { * @param {string} [userParameters.userIp] - Client user IP * @param {string} [userParameters.userAgent] - Client user agent * @param {string} [userParameters.acceptLanguage] - Client accept language + * @param {string} [userParameters.dateTime] - Time since epoch in milliseconds * @param {object} [networkParameters] - Parameters relevant to the network request * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds) * @returns {(true|Error)} @@ -490,6 +495,7 @@ class Tracker { * @param {string} [userParameters.userIp] - Client user IP * @param {string} [userParameters.userAgent] - Client user agent * @param {string} [userParameters.acceptLanguage] - Client accept language + * @param {string} [userParameters.dateTime] - Time since epoch in milliseconds * @param {object} [networkParameters] - Parameters relevant to the network request * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds) * @returns {(true|Error)} @@ -576,6 +582,7 @@ class Tracker { * @param {string} [userParameters.userIp] - Client user IP * @param {string} [userParameters.userAgent] - Client user agent * @param {string} [userParameters.acceptLanguage] - Client accept language + * @param {string} [userParameters.dateTime] - Time since epoch in milliseconds * @param {object} [networkParameters] - Parameters relevant to the network request * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds) * @returns {(true|Error)} @@ -674,6 +681,7 @@ class Tracker { * @param {string} [userParameters.userIp] - Client user IP * @param {string} [userParameters.userAgent] - Client user agent * @param {string} [userParameters.acceptLanguage] - Client accept language + * @param {string} [userParameters.dateTime] - Time since epoch in milliseconds * @param {object} [networkParameters] - Parameters relevant to the network request * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds) * @returns {(true|Error)} @@ -789,6 +797,7 @@ class Tracker { * @param {string} [userParameters.userIp] - Client user IP * @param {string} [userParameters.userAgent] - Client user agent * @param {string} [userParameters.acceptLanguage] - Client accept language + * @param {string} [userParameters.dateTime] - Time since epoch in milliseconds * @param {object} [networkParameters] - Parameters relevant to the network request * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds) * @returns {(true|Error)} @@ -923,6 +932,7 @@ class Tracker { * @param {string} [userParameters.userIp] - Client user IP * @param {string} [userParameters.userAgent] - Client user agent * @param {string} [userParameters.acceptLanguage] - Client accept language + * @param {string} [userParameters.dateTime] - Time since epoch in milliseconds * @param {object} [networkParameters] - Parameters relevant to the network request * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds) * @returns {(true|Error)} @@ -1025,6 +1035,7 @@ class Tracker { * @param {string} [userParameters.userIp] - Client user IP * @param {string} [userParameters.userAgent] - Client user agent * @param {string} [userParameters.acceptLanguage] - Client accept language + * @param {string} [userParameters.dateTime] - Time since epoch in milliseconds * @param {object} [networkParameters] - Parameters relevant to the network request * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds) * @returns {(true|Error)} @@ -1156,6 +1167,7 @@ class Tracker { * @param {string} [userParameters.userIp] - Client user IP * @param {string} [userParameters.userAgent] - Client user agent * @param {string} [userParameters.acceptLanguage] - Client accept language + * @param {string} [userParameters.dateTime] - Time since epoch in milliseconds * @param {object} [networkParameters] - Parameters relevant to the network request * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds) * @returns {(true|Error)} @@ -1309,6 +1321,7 @@ class Tracker { * @param {string} [userParameters.userIp] - Client user IP * @param {string} [userParameters.userAgent] - Client user agent * @param {string} [userParameters.acceptLanguage] - Client accept language + * @param {string} [userParameters.dateTime] - Time since epoch in milliseconds * @param {object} [networkParameters] - Parameters relevant to the network request * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds) * @returns {(true|Error)} @@ -1461,6 +1474,7 @@ class Tracker { * @param {string} [userParameters.userIp] - Client user IP * @param {string} [userParameters.userAgent] - Client user agent * @param {string} [userParameters.acceptLanguage] - Client accept language + * @param {string} [userParameters.dateTime] - Time since epoch in milliseconds * @param {object} [networkParameters] - Parameters relevant to the network request * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds) * @returns {(true|Error)} @@ -1608,6 +1622,7 @@ class Tracker { * @param {string} [userParameters.userIp] - Client user IP * @param {string} [userParameters.userAgent] - Client user agent * @param {string} [userParameters.acceptLanguage] - Client accept language + * @param {string} [userParameters.dateTime] - Time since epoch in milliseconds * @param {object} [networkParameters] - Parameters relevant to the network request * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds) * @returns {(true|Error)} diff --git a/src/types/tracker.d.ts b/src/types/tracker.d.ts index 500be7e2..1b9e1d6d 100644 --- a/src/types/tracker.d.ts +++ b/src/types/tracker.d.ts @@ -14,6 +14,7 @@ export interface TrackerUserParameters { userIp?: string; userAgent?: string; acceptLanguage?: string; + dateTime?: number; } declare class Tracker { From a4a9471fb2caec15b104cda785d61fe395dc8851 Mon Sep 17 00:00:00 2001 From: Chris Gee Date: Thu, 18 Jan 2024 15:50:31 -0800 Subject: [PATCH 2/2] Address comments --- spec/src/modules/tracker.js | 72 ++++++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 28 deletions(-) diff --git a/spec/src/modules/tracker.js b/spec/src/modules/tracker.js index ad64a5b2..db005f3d 100644 --- a/spec/src/modules/tracker.js +++ b/spec/src/modules/tracker.js @@ -427,11 +427,11 @@ describe('ConstructorIO - Tracker', () => { }); tracker.on('success', (responseParams) => { - const requestedHeaders = helpers.extractHeadersFromFetch(fetchSpy); + const requestedParams = helpers.extractUrlParamsFromFetch(fetchSpy); // Request expect(fetchSpy).to.have.been.called; - expect(requestedHeaders).to.have.property('_dt').to.equal(dateTime); + expect(requestedParams).to.have.property('_dt').to.equal(dateTime.toString()); // Response expect(responseParams).to.have.property('method').to.equal('GET'); @@ -928,11 +928,11 @@ describe('ConstructorIO - Tracker', () => { }); tracker.on('success', (responseParams) => { - const requestedHeaders = helpers.extractHeadersFromFetch(fetchSpy); + const requestedParams = helpers.extractUrlParamsFromFetch(fetchSpy); // Request expect(fetchSpy).to.have.been.called; - expect(requestedHeaders).to.have.property('_dt').to.equal(dateTime); + expect(requestedParams).to.have.property('_dt').to.equal(dateTime.toString()); // Response expect(responseParams).to.have.property('method').to.equal('GET'); @@ -1450,11 +1450,11 @@ describe('ConstructorIO - Tracker', () => { }); tracker.on('success', (responseParams) => { - const requestedHeaders = helpers.extractHeadersFromFetch(fetchSpy); + const requestedParams = helpers.extractUrlParamsFromFetch(fetchSpy); // Request expect(fetchSpy).to.have.been.called; - expect(requestedHeaders).to.have.property('_dt').to.equal(dateTime); + expect(requestedParams).to.have.property('_dt').to.equal(dateTime.toString()); // Response expect(responseParams).to.have.property('method').to.equal('GET'); @@ -2102,11 +2102,13 @@ describe('ConstructorIO - Tracker', () => { }); tracker.on('success', (responseParams) => { - const requestedHeaders = helpers.extractHeadersFromFetch(fetchSpy); + const requestedParams = helpers.extractUrlParamsFromFetch(fetchSpy); + const requestedBody = helpers.extractBodyParamsFromFetch(fetchSpy); // Request expect(fetchSpy).to.have.been.called; - expect(requestedHeaders).to.have.property('_dt').to.equal(dateTime); + expect(requestedParams).to.have.property('_dt').to.equal(dateTime.toString()); + expect(requestedBody).to.have.property('_dt').to.equal(dateTime); // Response expect(responseParams).to.have.property('method').to.equal('POST'); @@ -2448,11 +2450,11 @@ describe('ConstructorIO - Tracker', () => { }); tracker.on('success', (responseParams) => { - const requestedHeaders = helpers.extractHeadersFromFetch(fetchSpy); + const requestedParams = helpers.extractUrlParamsFromFetch(fetchSpy); // Request expect(fetchSpy).to.have.been.called; - expect(requestedHeaders).to.have.property('_dt').to.equal(dateTime); + expect(requestedParams).to.have.property('_dt').to.equal(dateTime.toString()); // Response expect(responseParams).to.have.property('method').to.equal('GET'); @@ -2965,11 +2967,11 @@ describe('ConstructorIO - Tracker', () => { }); tracker.on('success', (responseParams) => { - const requestedHeaders = helpers.extractHeadersFromFetch(fetchSpy); + const requestedParams = helpers.extractUrlParamsFromFetch(fetchSpy); // Request expect(fetchSpy).to.have.been.called; - expect(requestedHeaders).to.have.property('_dt').to.equal(dateTime); + expect(requestedParams).to.have.property('_dt').to.equal(dateTime.toString()); // Response expect(responseParams).to.have.property('method').to.equal('GET'); @@ -3586,11 +3588,11 @@ describe('ConstructorIO - Tracker', () => { }); tracker.on('success', (responseParams) => { - const requestedHeaders = helpers.extractHeadersFromFetch(fetchSpy); + const requestedParams = helpers.extractUrlParamsFromFetch(fetchSpy); // Request expect(fetchSpy).to.have.been.called; - expect(requestedHeaders).to.have.property('_dt').to.equal(dateTime); + expect(requestedParams).to.have.property('_dt').to.equal(dateTime.toString()); // Response expect(responseParams).to.have.property('method').to.equal('GET'); @@ -4287,11 +4289,13 @@ describe('ConstructorIO - Tracker', () => { }); tracker.on('success', (responseParams) => { - const requestedHeaders = helpers.extractHeadersFromFetch(fetchSpy); + const requestedParams = helpers.extractUrlParamsFromFetch(fetchSpy); + const requestedBody = helpers.extractBodyParamsFromFetch(fetchSpy); // Request expect(fetchSpy).to.have.been.called; - expect(requestedHeaders).to.have.property('_dt').to.equal(dateTime); + expect(requestedParams).to.have.property('_dt').to.equal(dateTime.toString()); + expect(requestedBody).to.have.property('_dt').to.equal(dateTime); // Response expect(responseParams).to.have.property('method').to.equal('POST'); @@ -5017,11 +5021,13 @@ describe('ConstructorIO - Tracker', () => { }); tracker.on('success', (responseParams) => { - const requestedHeaders = helpers.extractHeadersFromFetch(fetchSpy); + const requestedParams = helpers.extractUrlParamsFromFetch(fetchSpy); + const requestedBody = helpers.extractBodyParamsFromFetch(fetchSpy); // Request expect(fetchSpy).to.have.been.called; - expect(requestedHeaders).to.have.property('_dt').to.equal(dateTime); + expect(requestedParams).to.have.property('_dt').to.equal(dateTime.toString()); + expect(requestedBody).to.have.property('_dt').to.equal(dateTime); // Response expect(responseParams).to.have.property('method').to.equal('POST'); @@ -5603,11 +5609,13 @@ describe('ConstructorIO - Tracker', () => { }); tracker.on('success', (responseParams) => { - const requestedHeaders = helpers.extractHeadersFromFetch(fetchSpy); + const requestedParams = helpers.extractUrlParamsFromFetch(fetchSpy); + const requestedBody = helpers.extractBodyParamsFromFetch(fetchSpy); // Request expect(fetchSpy).to.have.been.called; - expect(requestedHeaders).to.have.property('_dt').to.equal(dateTime); + expect(requestedParams).to.have.property('_dt').to.equal(dateTime.toString()); + expect(requestedBody).to.have.property('_dt').to.equal(dateTime); // Response expect(responseParams).to.have.property('method').to.equal('POST'); @@ -6139,11 +6147,13 @@ describe('ConstructorIO - Tracker', () => { }); tracker.on('success', (responseParams) => { - const requestedHeaders = helpers.extractHeadersFromFetch(fetchSpy); + const requestedParams = helpers.extractUrlParamsFromFetch(fetchSpy); + const requestedBody = helpers.extractBodyParamsFromFetch(fetchSpy); // Request expect(fetchSpy).to.have.been.called; - expect(requestedHeaders).to.have.property('_dt').to.equal(dateTime); + expect(requestedParams).to.have.property('_dt').to.equal(dateTime.toString()); + expect(requestedBody).to.have.property('_dt').to.equal(dateTime); // Response expect(responseParams).to.have.property('method').to.equal('POST'); @@ -6693,11 +6703,13 @@ describe('ConstructorIO - Tracker', () => { }); tracker.on('success', (responseParams) => { - const requestedHeaders = helpers.extractHeadersFromFetch(fetchSpy); + const requestedParams = helpers.extractUrlParamsFromFetch(fetchSpy); + const requestedBody = helpers.extractBodyParamsFromFetch(fetchSpy); // Request expect(fetchSpy).to.have.been.called; - expect(requestedHeaders).to.have.property('_dt').to.equal(dateTime); + expect(requestedParams).to.have.property('_dt').to.equal(dateTime.toString()); + expect(requestedBody).to.have.property('_dt').to.equal(dateTime); // Response expect(responseParams).to.have.property('method').to.equal('POST'); @@ -7266,11 +7278,13 @@ describe('ConstructorIO - Tracker', () => { }); tracker.on('success', (responseParams) => { - const requestedHeaders = helpers.extractHeadersFromFetch(fetchSpy); + const requestedParams = helpers.extractUrlParamsFromFetch(fetchSpy); + const requestedBody = helpers.extractBodyParamsFromFetch(fetchSpy); // Request expect(fetchSpy).to.have.been.called; - expect(requestedHeaders).to.have.property('_dt').to.equal(dateTime); + expect(requestedParams).to.have.property('_dt').to.equal(dateTime.toString()); + expect(requestedBody).to.have.property('_dt').to.equal(dateTime); // Response expect(responseParams).to.have.property('method').to.equal('POST'); @@ -7817,11 +7831,13 @@ describe('ConstructorIO - Tracker', () => { }); tracker.on('success', (responseParams) => { - const requestedHeaders = helpers.extractHeadersFromFetch(fetchSpy); + const requestedParams = helpers.extractUrlParamsFromFetch(fetchSpy); + const requestedBody = helpers.extractBodyParamsFromFetch(fetchSpy); // Request expect(fetchSpy).to.have.been.called; - expect(requestedHeaders).to.have.property('_dt').to.equal(dateTime); + expect(requestedParams).to.have.property('_dt').to.equal(dateTime.toString()); + expect(requestedBody).to.have.property('_dt').to.equal(dateTime); // Response expect(responseParams).to.have.property('method').to.equal('POST');