@constructor-io/constructorio-node 3.6.0 → 3.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/src/constructorio.js
CHANGED
|
@@ -50,7 +50,7 @@ class ConstructorIO {
|
|
|
50
50
|
apiToken: apiToken || '',
|
|
51
51
|
securityToken: securityToken || '',
|
|
52
52
|
version: version || global.CLIENT_VERSION || `cio-node-${packageVersion}`,
|
|
53
|
-
serviceUrl: serviceUrl || 'https://ac.cnstrc.com',
|
|
53
|
+
serviceUrl: (serviceUrl && serviceUrl.replace(/\/$/, '')) || 'https://ac.cnstrc.com',
|
|
54
54
|
fetch,
|
|
55
55
|
networkParameters: networkParameters || {},
|
|
56
56
|
};
|
|
@@ -96,6 +96,7 @@ class Autocomplete {
|
|
|
96
96
|
* Retrieve autocomplete results from API
|
|
97
97
|
*
|
|
98
98
|
* @function getAutocompleteResults
|
|
99
|
+
* @param {string} query - Term to use to perform an autocomplete search
|
|
99
100
|
* @param {object} [parameters] - Additional parameters to refine result set
|
|
100
101
|
* @param {number} [parameters.numResults] - The total number of results to return
|
|
101
102
|
* @param {object} [parameters.filters] - Filters used to refine search
|
package/src/modules/tracker.js
CHANGED
|
@@ -477,6 +477,7 @@ class Tracker {
|
|
|
477
477
|
const url = `${this.options.serviceUrl}/behavior?`;
|
|
478
478
|
const queryParams = { action: 'search-results', term };
|
|
479
479
|
const { num_results, customer_ids, item_ids } = parameters;
|
|
480
|
+
let customerIDs;
|
|
480
481
|
|
|
481
482
|
if (!helpers.isNil(num_results)) {
|
|
482
483
|
queryParams.num_results = num_results;
|
|
@@ -484,9 +485,13 @@ class Tracker {
|
|
|
484
485
|
|
|
485
486
|
// Ensure support for both item_ids and customer_ids as parameters
|
|
486
487
|
if (item_ids && Array.isArray(item_ids)) {
|
|
487
|
-
|
|
488
|
+
customerIDs = item_ids;
|
|
488
489
|
} else if (customer_ids && Array.isArray(customer_ids)) {
|
|
489
|
-
|
|
490
|
+
customerIDs = customer_ids;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
if (customerIDs && Array.isArray(customerIDs) && customerIDs.length) {
|
|
494
|
+
queryParams.customer_ids = customerIDs.slice(0, 100).join(',');
|
|
490
495
|
}
|
|
491
496
|
|
|
492
497
|
const requestUrl = `${url}${applyParamsAsString(queryParams, userParameters, this.options)}`;
|
|
@@ -602,7 +607,7 @@ class Tracker {
|
|
|
602
607
|
* @param {string} [term] - Search results query term that led to conversion event
|
|
603
608
|
* @param {object} parameters - Additional parameters to be sent with request
|
|
604
609
|
* @param {string} parameters.item_id - Product item unique identifier
|
|
605
|
-
* @param {number} parameters.revenue -
|
|
610
|
+
* @param {number} [parameters.revenue] - Sale price if available, otherwise the regular (retail) price of item
|
|
606
611
|
* @param {string} [parameters.item_name] - Product item name
|
|
607
612
|
* @param {string} [parameters.variation_id] - Product item variation unique identifier
|
|
608
613
|
* @param {string} [parameters.type='add_to_cart'] - Conversion type
|
|
@@ -732,7 +737,7 @@ class Tracker {
|
|
|
732
737
|
* @function trackPurchase
|
|
733
738
|
* @param {object} parameters - Additional parameters to be sent with request
|
|
734
739
|
* @param {object[]} parameters.items - List of product item objects
|
|
735
|
-
* @param {number} parameters.revenue -
|
|
740
|
+
* @param {number} parameters.revenue - The subtotal (excluding taxes, shipping, etc.) of the entire order
|
|
736
741
|
* @param {string} [parameters.order_id] - Unique order identifier
|
|
737
742
|
* @param {string} [parameters.section] - Index section
|
|
738
743
|
* @param {object} userParameters - Parameters relevant to the user request
|
|
@@ -777,7 +782,7 @@ class Tracker {
|
|
|
777
782
|
}
|
|
778
783
|
|
|
779
784
|
if (items && Array.isArray(items)) {
|
|
780
|
-
bodyParams.items = items;
|
|
785
|
+
bodyParams.items = items.slice(0, 100);
|
|
781
786
|
}
|
|
782
787
|
|
|
783
788
|
if (revenue) {
|
|
@@ -1156,7 +1161,7 @@ class Tracker {
|
|
|
1156
1161
|
}
|
|
1157
1162
|
|
|
1158
1163
|
if (items && Array.isArray(items)) {
|
|
1159
|
-
bodyParams.items = items;
|
|
1164
|
+
bodyParams.items = items.slice(0, 100);
|
|
1160
1165
|
}
|
|
1161
1166
|
|
|
1162
1167
|
const requestUrl = `${requestPath}${applyParamsAsString({}, userParameters, this.options)}`;
|
package/src/utils/helpers.js
CHANGED
|
@@ -58,7 +58,9 @@ const utils = {
|
|
|
58
58
|
// Abort network request based on supplied timeout interval (in milliseconds)
|
|
59
59
|
// - method call parameter takes precedence over global options parameter
|
|
60
60
|
applyNetworkTimeout: (options = {}, networkParameters = {}, controller = undefined) => {
|
|
61
|
-
const
|
|
61
|
+
const optionsTimeout = options && options.networkParameters && options.networkParameters.timeout;
|
|
62
|
+
const networkParametersTimeout = networkParameters && networkParameters.timeout;
|
|
63
|
+
const timeout = optionsTimeout || networkParametersTimeout;
|
|
62
64
|
|
|
63
65
|
if (typeof timeout === 'number') {
|
|
64
66
|
setTimeout(() => controller.abort(), timeout);
|