@constructor-io/constructorio-client-javascript 2.27.8 → 2.27.11

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.
@@ -159,6 +159,69 @@ var Tracker = /*#__PURE__*/function () {
159
159
  this.requests.send();
160
160
  return true;
161
161
  }
162
+ /**
163
+ * Send item detail load event to API
164
+ *
165
+ * @function trackItemDetailLoad
166
+ * @param {object} parameters - Additional parameters to be sent with request
167
+ * @param {string} parameters.item_name - Product item name
168
+ * @param {string} parameters.item_id - Product item unique identifier
169
+ * @param {string} [parameters.variation_id] - Product item variation unique identifier
170
+ * @param {object} [networkParameters] - Parameters relevant to the network request
171
+ * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
172
+ * @returns {(true|Error)}
173
+ * @description User loaded an item detail page
174
+ * @example
175
+ * constructorio.tracker.trackItemDetailLoad(
176
+ * {
177
+ * item_name: 'Red T-Shirt',
178
+ * item_id: 'KMH876',
179
+ * },
180
+ * );
181
+ */
182
+
183
+ }, {
184
+ key: "trackItemDetailLoad",
185
+ value: function trackItemDetailLoad(parameters) {
186
+ var networkParameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
187
+
188
+ // Ensure parameters are provided (required)
189
+ if (parameters && (0, _typeof2["default"])(parameters) === 'object' && !Array.isArray(parameters)) {
190
+ var url = "".concat(this.options.serviceUrl, "/behavior?");
191
+ var queryParams = {
192
+ action: 'item_detail_load'
193
+ };
194
+ var item_name = parameters.item_name,
195
+ name = parameters.name,
196
+ item_id = parameters.item_id,
197
+ customer_id = parameters.customer_id,
198
+ variation_id = parameters.variation_id; // Ensure support for both item_name and name as parameters
199
+
200
+ if (item_name) {
201
+ queryParams.name = item_name;
202
+ } else if (name) {
203
+ queryParams.name = name;
204
+ } // Ensure support for both item_id and customer_id as parameters
205
+
206
+
207
+ if (item_id) {
208
+ queryParams.customer_id = item_id;
209
+ } else if (customer_id) {
210
+ queryParams.customer_id = customer_id;
211
+ }
212
+
213
+ if (variation_id) {
214
+ queryParams.variation_id = variation_id;
215
+ }
216
+
217
+ this.requests.queue("".concat(url).concat(applyParamsAsString(queryParams, this.options)), undefined, undefined, networkParameters);
218
+ this.requests.send();
219
+ return true;
220
+ }
221
+
222
+ this.requests.send();
223
+ return new Error('parameters are required of type object');
224
+ }
162
225
  /**
163
226
  * Send autocomplete select event to API
164
227
  *
@@ -456,7 +519,7 @@ var Tracker = /*#__PURE__*/function () {
456
519
  * @param {boolean} [parameters.is_custom_type] - Specify if type is custom conversion type
457
520
  * @param {string} [parameters.display_name] - Display name for the custom conversion type
458
521
  * @param {string} [parameters.result_id] - Result identifier (returned in response from Constructor)
459
- * @param {string} [parameters.section] - Index section
522
+ * @param {string} [parameters.section="Products"] - Index section
460
523
  * @param {object} [networkParameters] - Parameters relevant to the network request
461
524
  * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
462
525
  * @returns {(true|Error)}
@@ -563,7 +626,7 @@ var Tracker = /*#__PURE__*/function () {
563
626
  * @param {object[]} parameters.items - List of product item objects
564
627
  * @param {number} parameters.revenue - The subtotal (not including taxes, shipping, etc.) of the entire order
565
628
  * @param {string} [parameters.order_id] - Unique order identifier
566
- * @param {string} [parameters.section] - Index section
629
+ * @param {string} [parameters.section="Products"] - Index section
567
630
  * @param {object} [networkParameters] - Parameters relevant to the network request
568
631
  * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
569
632
  * @returns {(true|Error)}
@@ -640,6 +703,7 @@ var Tracker = /*#__PURE__*/function () {
640
703
  * @param {string} parameters.url - Current page URL
641
704
  * @param {string} parameters.pod_id - Pod identifier
642
705
  * @param {number} parameters.num_results_viewed - Number of results viewed
706
+ * @param {object[]} [parameters.items] - List of Product Item Objects
643
707
  * @param {number} [parameters.result_count] - Total number of results
644
708
  * @param {number} [parameters.result_page] - Page number of results
645
709
  * @param {string} [parameters.result_id] - Recommendation result identifier (returned in response from Constructor)
@@ -651,6 +715,7 @@ var Tracker = /*#__PURE__*/function () {
651
715
  * @example
652
716
  * constructorio.tracker.trackRecommendationView(
653
717
  * {
718
+ * items: [{ item_id: 'KMH876' }, { item_id: 'KMH140' }],
654
719
  * result_count: 22,
655
720
  * result_page: 2,
656
721
  * result_id: '019927c2-f955-4020-8b8d-6b21b93cb5a2',
@@ -676,7 +741,8 @@ var Tracker = /*#__PURE__*/function () {
676
741
  section = parameters.section,
677
742
  url = parameters.url,
678
743
  pod_id = parameters.pod_id,
679
- num_results_viewed = parameters.num_results_viewed;
744
+ num_results_viewed = parameters.num_results_viewed,
745
+ items = parameters.items;
680
746
 
681
747
  if (!helpers.isNil(result_count)) {
682
748
  bodyParams.result_count = result_count;
@@ -708,6 +774,10 @@ var Tracker = /*#__PURE__*/function () {
708
774
  bodyParams.num_results_viewed = num_results_viewed;
709
775
  }
710
776
 
777
+ if (items && Array.isArray(items)) {
778
+ bodyParams.items = items.slice(0, 100);
779
+ }
780
+
711
781
  var requestURL = "".concat(requestPath).concat(applyParamsAsString({}, this.options));
712
782
  var requestMethod = 'POST';
713
783
  var requestBody = applyParams(bodyParams, _objectSpread(_objectSpread({}, this.options), {}, {
@@ -843,7 +913,7 @@ var Tracker = /*#__PURE__*/function () {
843
913
  * @param {number} [parameters.result_count] - Total number of results
844
914
  * @param {number} [parameters.result_page] - Page number of results
845
915
  * @param {string} [parameters.result_id] - Browse result identifier (returned in response from Constructor)
846
- * @param {string} [parameters.selected_filters] - Selected filters
916
+ * @param {object} [parameters.selected_filters] - Selected filters
847
917
  * @param {string} [parameters.sort_order] - Sort order ('ascending' or 'descending')
848
918
  * @param {string} [parameters.sort_by] - Sorting method
849
919
  * @param {object[]} [parameters.items] - List of product item objects
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructor-io/constructorio-client-javascript",
3
- "version": "2.27.8",
3
+ "version": "2.27.11",
4
4
  "description": "Constructor.io JavaScript client",
5
5
  "main": "lib/constructorio.js",
6
6
  "scripts": {