@constructor-io/constructorio-node 3.8.7 → 3.9.0
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
|
@@ -47,7 +47,7 @@ function createAutocompleteUrl(query, parameters, userParameters, options) {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
if (parameters) {
|
|
50
|
-
const { numResults, resultsPerSection, filters, hiddenFields } = parameters;
|
|
50
|
+
const { numResults, resultsPerSection, filters, hiddenFields, variationsMap } = parameters;
|
|
51
51
|
|
|
52
52
|
// Pull results number from parameters
|
|
53
53
|
if (numResults) {
|
|
@@ -74,6 +74,11 @@ function createAutocompleteUrl(query, parameters, userParameters, options) {
|
|
|
74
74
|
queryParams.fmt_options = { hidden_fields: hiddenFields };
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
+
|
|
78
|
+
// Pull variations map from parameters
|
|
79
|
+
if (variationsMap) {
|
|
80
|
+
queryParams.variations_map = JSON.stringify(variationsMap);
|
|
81
|
+
}
|
|
77
82
|
}
|
|
78
83
|
|
|
79
84
|
queryParams._dt = Date.now();
|
|
@@ -106,6 +111,7 @@ class Autocomplete {
|
|
|
106
111
|
* @param {object} [parameters.filters] - Filters used to refine search
|
|
107
112
|
* @param {object} [parameters.resultsPerSection] - Number of results to return (value) per section (key)
|
|
108
113
|
* @param {string[]} [parameters.hiddenFields] - Hidden metadata fields to return
|
|
114
|
+
* @param {object} [parameters.variationsMap] - The variations map object to aggregate variations. Please refer to https://docs.constructor.io/rest_api/variations_mapping for details
|
|
109
115
|
* @param {object} [userParameters] - Parameters relevant to the user request
|
|
110
116
|
* @param {number} [userParameters.sessionId] - Session ID, utilized to personalize results
|
|
111
117
|
* @param {number} [userParameters.clientId] - Client ID, utilized to personalize results
|
package/src/modules/browse.js
CHANGED
|
@@ -34,6 +34,7 @@ function createQueryParams(parameters, userParameters, options) {
|
|
|
34
34
|
fmtOptions,
|
|
35
35
|
hiddenFields,
|
|
36
36
|
hiddenFacets,
|
|
37
|
+
variationsMap,
|
|
37
38
|
} = parameters;
|
|
38
39
|
|
|
39
40
|
// Pull page from parameters
|
|
@@ -87,6 +88,11 @@ function createQueryParams(parameters, userParameters, options) {
|
|
|
87
88
|
queryParams.fmt_options = { hidden_facets: hiddenFacets };
|
|
88
89
|
}
|
|
89
90
|
}
|
|
91
|
+
|
|
92
|
+
// Pull variations map from parameters
|
|
93
|
+
if (variationsMap) {
|
|
94
|
+
queryParams.variations_map = JSON.stringify(variationsMap);
|
|
95
|
+
}
|
|
90
96
|
}
|
|
91
97
|
|
|
92
98
|
// Pull test cells from options
|
|
@@ -223,9 +229,11 @@ class Browse {
|
|
|
223
229
|
* @param {object} [parameters.filters] - Filters used to refine results
|
|
224
230
|
* @param {string} [parameters.sortBy='relevance'] - The sort method for results
|
|
225
231
|
* @param {string} [parameters.sortOrder='descending'] - The sort order for results
|
|
232
|
+
* @param {string} [parameters.section='Products'] - The section name for results
|
|
226
233
|
* @param {object} [parameters.fmtOptions] - The format options used to refine result groups
|
|
227
234
|
* @param {string[]} [parameters.hiddenFields] - Hidden metadata fields to return
|
|
228
235
|
* @param {string[]} [parameters.hiddenFacets] - Hidden facet fields to return
|
|
236
|
+
* @param {object} [parameters.variationsMap] - The variations map object to aggregate variations. Please refer to https://docs.constructor.io/rest_api/variations_mapping for details
|
|
229
237
|
* @param {object} [userParameters] - Parameters relevant to the user request
|
|
230
238
|
* @param {number} [userParameters.sessionId] - Session ID, utilized to personalize results
|
|
231
239
|
* @param {number} [userParameters.clientId] - Client ID, utilized to personalize results
|
|
@@ -305,9 +313,11 @@ class Browse {
|
|
|
305
313
|
* @param {object} [parameters.filters] - Filters used to refine results
|
|
306
314
|
* @param {string} [parameters.sortBy='relevance'] - The sort method for results
|
|
307
315
|
* @param {string} [parameters.sortOrder='descending'] - The sort order for results
|
|
316
|
+
* @param {string} [parameters.section='Products'] - The section name for results
|
|
308
317
|
* @param {object} [parameters.fmtOptions] - The format options used to refine result groups
|
|
309
318
|
* @param {string[]} [parameters.hiddenFields] - Hidden metadata fields to return
|
|
310
319
|
* @param {string[]} [parameters.hiddenFacets] - Hidden facet fields to return
|
|
320
|
+
* @param {object} [parameters.variationsMap] - The variations map object to aggregate variations. Please refer to https://docs.constructor.io/rest_api/variations_mapping for details
|
|
311
321
|
* @param {object} [userParameters] - Parameters relevant to the user request
|
|
312
322
|
* @param {number} [userParameters.sessionId] - Session ID, utilized to personalize results
|
|
313
323
|
* @param {number} [userParameters.clientId] - Client ID, utilized to personalize results
|
|
@@ -375,6 +385,7 @@ class Browse {
|
|
|
375
385
|
*
|
|
376
386
|
* @function getBrowseGroups
|
|
377
387
|
* @param {object} [parameters.filters] - Filters used to refine results
|
|
388
|
+
* @param {string} [parameters.section='Products'] - The section name for results
|
|
378
389
|
* @param {object} [parameters.fmtOptions] - The format options used to refine result groups
|
|
379
390
|
* @param {object} [userParameters] - Parameters relevant to the user request
|
|
380
391
|
* @param {number} [userParameters.sessionId] - Session ID, utilized to personalize results
|
|
@@ -433,6 +444,7 @@ class Browse {
|
|
|
433
444
|
* @function getBrowseFacets
|
|
434
445
|
* @param {object} [parameters] - Additional parameters to refine result set
|
|
435
446
|
* @param {number} [parameters.page] - The page number of the results
|
|
447
|
+
* @param {string} [parameters.section='Products'] - The section name for results
|
|
436
448
|
* @param {number} [parameters.resultsPerPage] - The number of results per page to return
|
|
437
449
|
* @param {object} [parameters.fmtOptions] - The format options used to refine result groups
|
|
438
450
|
* @param {boolean} [parameters.fmtOptions.show_hidden_facets] - Include facets configured as hidden
|
|
@@ -492,6 +504,7 @@ class Browse {
|
|
|
492
504
|
* @function getBrowseFacetOptions
|
|
493
505
|
* @param {string} facetName - Name of the facet whose options to return
|
|
494
506
|
* @param {object} [parameters] - Additional parameters to refine result set
|
|
507
|
+
* @param {string} [parameters.section='Products'] - The section name for results
|
|
495
508
|
* @param {object} [parameters.fmtOptions] - The format options used to refine result groups
|
|
496
509
|
* @param {boolean} [parameters.fmtOptions.show_hidden_facets] - Include facets configured as hidden
|
|
497
510
|
* @param {boolean} [parameters.fmtOptions.show_protected_facets] - Include facets configured as protected
|
|
@@ -39,7 +39,7 @@ function createRecommendationsUrl(podId, parameters, userParameters, options) {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
if (parameters) {
|
|
42
|
-
const { numResults, itemIds, section, term, filters } = parameters;
|
|
42
|
+
const { numResults, itemIds, section, term, filters, variationsMap } = parameters;
|
|
43
43
|
|
|
44
44
|
// Pull num results number from parameters
|
|
45
45
|
if (!helpers.isNil(numResults)) {
|
|
@@ -65,6 +65,11 @@ function createRecommendationsUrl(podId, parameters, userParameters, options) {
|
|
|
65
65
|
if (filters) {
|
|
66
66
|
queryParams.filters = filters;
|
|
67
67
|
}
|
|
68
|
+
|
|
69
|
+
// Pull variations map from parameters
|
|
70
|
+
if (variationsMap) {
|
|
71
|
+
queryParams.variations_map = JSON.stringify(variationsMap);
|
|
72
|
+
}
|
|
68
73
|
}
|
|
69
74
|
|
|
70
75
|
queryParams = helpers.cleanParams(queryParams);
|
|
@@ -97,6 +102,7 @@ class Recommendations {
|
|
|
97
102
|
* @param {string} [parameters.section] - The section to return results from
|
|
98
103
|
* @param {string} [parameters.term] - The term to use to refine results (strategy specific)
|
|
99
104
|
* @param {object} [parameters.filters] - Filters used to refine results (strategy specific)
|
|
105
|
+
* @param {object} [parameters.variationsMap] - The variations map object to aggregate variations. Please refer to https://docs.constructor.io/rest_api/variations_mapping for details
|
|
100
106
|
* @param {object} [userParameters] - Parameters relevant to the user request
|
|
101
107
|
* @param {number} [userParameters.sessionId] - Session ID, utilized to personalize results
|
|
102
108
|
* @param {number} [userParameters.clientId] - Client ID, utilized to personalize results
|
package/src/modules/search.js
CHANGED
|
@@ -57,6 +57,7 @@ function createSearchUrl(query, parameters, userParameters, options) {
|
|
|
57
57
|
fmtOptions,
|
|
58
58
|
hiddenFields,
|
|
59
59
|
hiddenFacets,
|
|
60
|
+
variationsMap,
|
|
60
61
|
} = parameters;
|
|
61
62
|
|
|
62
63
|
// Pull page from parameters
|
|
@@ -111,6 +112,11 @@ function createSearchUrl(query, parameters, userParameters, options) {
|
|
|
111
112
|
queryParams.fmt_options = { hidden_facets: hiddenFacets };
|
|
112
113
|
}
|
|
113
114
|
}
|
|
115
|
+
|
|
116
|
+
// Pull variations map from parameters
|
|
117
|
+
if (variationsMap) {
|
|
118
|
+
queryParams.variations_map = JSON.stringify(variationsMap);
|
|
119
|
+
}
|
|
114
120
|
}
|
|
115
121
|
|
|
116
122
|
queryParams._dt = Date.now();
|
|
@@ -148,6 +154,7 @@ class Search {
|
|
|
148
154
|
* @param {object} [parameters.fmtOptions] - The format options used to refine result groups
|
|
149
155
|
* @param {string[]} [parameters.hiddenFields] - Hidden metadata fields to return
|
|
150
156
|
* @param {string[]} [parameters.hiddenFacets] - Hidden facet fields to return
|
|
157
|
+
* @param {object} [parameters.variationsMap] - The variations map object to aggregate variations. Please refer to https://docs.constructor.io/rest_api/variations_mapping for details
|
|
151
158
|
* @param {object} [userParameters] - Parameters relevant to the user request
|
|
152
159
|
* @param {number} [userParameters.sessionId] - Session ID, utilized to personalize results
|
|
153
160
|
* @param {number} [userParameters.clientId] - Client ID, utilized to personalize results
|
package/src/modules/tracker.js
CHANGED
|
@@ -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
|
*
|