@constructor-io/constructorio-node 3.8.6 → 3.8.9

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructor-io/constructorio-node",
3
- "version": "3.8.6",
3
+ "version": "3.8.9",
4
4
  "description": "Constructor.io Node.js client",
5
5
  "main": "src/constructorio.js",
6
6
  "scripts": {
@@ -223,6 +223,7 @@ class Browse {
223
223
  * @param {object} [parameters.filters] - Filters used to refine results
224
224
  * @param {string} [parameters.sortBy='relevance'] - The sort method for results
225
225
  * @param {string} [parameters.sortOrder='descending'] - The sort order for results
226
+ * @param {string} [parameters.section='Products'] - The section name for results
226
227
  * @param {object} [parameters.fmtOptions] - The format options used to refine result groups
227
228
  * @param {string[]} [parameters.hiddenFields] - Hidden metadata fields to return
228
229
  * @param {string[]} [parameters.hiddenFacets] - Hidden facet fields to return
@@ -305,6 +306,7 @@ class Browse {
305
306
  * @param {object} [parameters.filters] - Filters used to refine results
306
307
  * @param {string} [parameters.sortBy='relevance'] - The sort method for results
307
308
  * @param {string} [parameters.sortOrder='descending'] - The sort order for results
309
+ * @param {string} [parameters.section='Products'] - The section name for results
308
310
  * @param {object} [parameters.fmtOptions] - The format options used to refine result groups
309
311
  * @param {string[]} [parameters.hiddenFields] - Hidden metadata fields to return
310
312
  * @param {string[]} [parameters.hiddenFacets] - Hidden facet fields to return
@@ -375,6 +377,7 @@ class Browse {
375
377
  *
376
378
  * @function getBrowseGroups
377
379
  * @param {object} [parameters.filters] - Filters used to refine results
380
+ * @param {string} [parameters.section='Products'] - The section name for results
378
381
  * @param {object} [parameters.fmtOptions] - The format options used to refine result groups
379
382
  * @param {object} [userParameters] - Parameters relevant to the user request
380
383
  * @param {number} [userParameters.sessionId] - Session ID, utilized to personalize results
@@ -433,6 +436,7 @@ class Browse {
433
436
  * @function getBrowseFacets
434
437
  * @param {object} [parameters] - Additional parameters to refine result set
435
438
  * @param {number} [parameters.page] - The page number of the results
439
+ * @param {string} [parameters.section='Products'] - The section name for results
436
440
  * @param {number} [parameters.resultsPerPage] - The number of results per page to return
437
441
  * @param {object} [parameters.fmtOptions] - The format options used to refine result groups
438
442
  * @param {boolean} [parameters.fmtOptions.show_hidden_facets] - Include facets configured as hidden
@@ -492,6 +496,7 @@ class Browse {
492
496
  * @function getBrowseFacetOptions
493
497
  * @param {string} facetName - Name of the facet whose options to return
494
498
  * @param {object} [parameters] - Additional parameters to refine result set
499
+ * @param {string} [parameters.section='Products'] - The section name for results
495
500
  * @param {object} [parameters.fmtOptions] - The format options used to refine result groups
496
501
  * @param {boolean} [parameters.fmtOptions.show_hidden_facets] - Include facets configured as hidden
497
502
  * @param {boolean} [parameters.fmtOptions.show_protected_facets] - Include facets configured as protected
@@ -497,7 +497,11 @@ class Catalog {
497
497
  }
498
498
 
499
499
  try {
500
- requestUrl = createCatalogUrl(`item/${parameters.id}`, this.options, queryParams);
500
+ if (parameters.id) {
501
+ requestUrl = createCatalogUrl(`item/${parameters.id}`, this.options, queryParams);
502
+ } else {
503
+ requestUrl = createCatalogUrl('item', this.options, queryParams);
504
+ }
501
505
  } catch (e) {
502
506
  return Promise.reject(e);
503
507
  }
@@ -264,6 +264,77 @@ class Tracker {
264
264
  return true;
265
265
  }
266
266
 
267
+ /**
268
+ * Send item detail load event to API
269
+ *
270
+ * @function trackItemDetailLoad
271
+ * @param {object} parameters - Additional parameters to be sent with request
272
+ * @param {string} parameters.item_name - Product item name
273
+ * @param {string} parameters.item_id - Product item unique identifier
274
+ * @param {string} [parameters.variation_id] - Product item variation unique identifier
275
+ * @param {object} userParameters - Parameters relevant to the user request
276
+ * @param {number} userParameters.sessionId - Session ID, utilized to personalize results
277
+ * @param {number} userParameters.clientId - Client ID, utilized to personalize results
278
+ * @param {string} [userParameters.userId] - User ID, utilized to personalize results
279
+ * @param {string} [userParameters.segments] - User segments
280
+ * @param {object} [userParameters.testCells] - User test cells
281
+ * @param {string} [userParameters.originReferrer] - Client page URL (including path)
282
+ * @param {string} [userParameters.referer] - Client page URL (including path)
283
+ * @param {string} [userParameters.userIp] - Client user IP
284
+ * @param {string} [userParameters.userAgent] - Client user agent
285
+ * @param {string} [userParameters.acceptLanguage] - Client accept language
286
+ * @param {object} [networkParameters] - Parameters relevant to the network request
287
+ * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
288
+ * @returns {(true|Error)}
289
+ * @description User loaded an item detail page
290
+ * @example
291
+ * constructorio.tracker.trackItemDetailLoad(
292
+ * {
293
+ * item_name: 'Red T-Shirt',
294
+ * item_id: 'KMH876',
295
+ * },
296
+ * );
297
+ */
298
+ trackItemDetailLoad(parameters, userParameters, networkParameters = {}) {
299
+ // Ensure parameters are provided (required)
300
+ if (parameters && typeof parameters === 'object' && !Array.isArray(parameters)) {
301
+ const url = `${this.options.serviceUrl}/behavior?`;
302
+ const queryParams = { action: 'item_detail_load' };
303
+ const { item_name, name, item_id, customer_id, variation_id } = parameters;
304
+
305
+ // Ensure support for both item_name and name as parameters
306
+ if (item_name) {
307
+ queryParams.name = item_name;
308
+ } else if (name) {
309
+ queryParams.name = name;
310
+ }
311
+
312
+ // Ensure support for both item_id and customer_id as parameters
313
+ if (item_id) {
314
+ queryParams.customer_id = item_id;
315
+ } else if (customer_id) {
316
+ queryParams.customer_id = customer_id;
317
+ }
318
+
319
+ if (variation_id) {
320
+ queryParams.variation_id = variation_id;
321
+ }
322
+
323
+ const requestUrl = `${url}${applyParamsAsString(queryParams, userParameters, this.options)}`;
324
+
325
+ send.call(
326
+ this,
327
+ requestUrl,
328
+ userParameters,
329
+ networkParameters,
330
+ );
331
+
332
+ return true;
333
+ }
334
+
335
+ return new Error('parameters are required of type object');
336
+ }
337
+
267
338
  /**
268
339
  * Send autocomplete select event to API
269
340
  *