@constructor-io/constructorio-client-javascript 2.34.7 → 2.34.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/lib/modules/tracker.js +840 -7
- package/lib/types/tracker.d.ts +46 -0
- package/package.json +1 -1
- package/lib/types/types.d.ts +0 -126
package/lib/modules/tracker.js
CHANGED
|
@@ -106,20 +106,41 @@ var Tracker = /*#__PURE__*/function () {
|
|
|
106
106
|
this.options = options || {};
|
|
107
107
|
this.eventemitter = new EventEmitter();
|
|
108
108
|
this.requests = new RequestQueue(options, this.eventemitter);
|
|
109
|
+
this.behavioralV2Url = 'https://ac.cnstrc.com/v2/behavioral_action/';
|
|
109
110
|
}
|
|
110
111
|
/**
|
|
111
112
|
* Send session start event to API
|
|
112
|
-
*
|
|
113
|
-
* @function
|
|
113
|
+
* @private
|
|
114
|
+
* @function trackSessionStartV2
|
|
114
115
|
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
115
116
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
116
117
|
* @returns {(true|Error)}
|
|
117
118
|
* @example
|
|
118
|
-
* constructorio.tracker.
|
|
119
|
+
* constructorio.tracker.trackSessionStartV2();
|
|
119
120
|
*/
|
|
120
121
|
|
|
121
122
|
|
|
122
123
|
(0, _createClass2["default"])(Tracker, [{
|
|
124
|
+
key: "trackSessionStartV2",
|
|
125
|
+
value: function trackSessionStartV2() {
|
|
126
|
+
var networkParameters = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
127
|
+
var url = "".concat(this.behavioralV2Url, "session_start?");
|
|
128
|
+
this.requests.queue("".concat(url).concat(applyParamsAsString({}, this.options)), 'POST', undefined, networkParameters);
|
|
129
|
+
this.requests.send();
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Send session start event to API
|
|
134
|
+
*
|
|
135
|
+
* @function trackSessionStart
|
|
136
|
+
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
137
|
+
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
138
|
+
* @returns {(true|Error)}
|
|
139
|
+
* @example
|
|
140
|
+
* constructorio.tracker.trackSessionStart();
|
|
141
|
+
*/
|
|
142
|
+
|
|
143
|
+
}, {
|
|
123
144
|
key: "trackSessionStart",
|
|
124
145
|
value: function trackSessionStart() {
|
|
125
146
|
var networkParameters = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -131,6 +152,43 @@ var Tracker = /*#__PURE__*/function () {
|
|
|
131
152
|
this.requests.send();
|
|
132
153
|
return true;
|
|
133
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* Send input focus event to API
|
|
157
|
+
* @private
|
|
158
|
+
* @function trackInputFocusV2
|
|
159
|
+
* @param {string} user_input - Input at the time user focused on the search bar
|
|
160
|
+
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
161
|
+
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
162
|
+
* @returns {(true|Error)}
|
|
163
|
+
* @description User focused on search input element
|
|
164
|
+
* @example
|
|
165
|
+
* constructorio.tracker.trackInputFocusV2("text");
|
|
166
|
+
*/
|
|
167
|
+
|
|
168
|
+
}, {
|
|
169
|
+
key: "trackInputFocusV2",
|
|
170
|
+
value: function trackInputFocusV2() {
|
|
171
|
+
var user_input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
172
|
+
var networkParameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
173
|
+
var baseUrl = "".concat(this.behavioralV2Url, "focus?");
|
|
174
|
+
var bodyParams = {};
|
|
175
|
+
var networkParametersNew = networkParameters;
|
|
176
|
+
var userInputNew = user_input;
|
|
177
|
+
|
|
178
|
+
if ((0, _typeof2["default"])(user_input) === 'object') {
|
|
179
|
+
networkParametersNew = user_input;
|
|
180
|
+
userInputNew = '';
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
bodyParams.user_input = userInputNew;
|
|
184
|
+
var requestMethod = 'POST';
|
|
185
|
+
var requestBody = applyParams(bodyParams, _objectSpread(_objectSpread({}, this.options), {}, {
|
|
186
|
+
requestMethod: requestMethod
|
|
187
|
+
}));
|
|
188
|
+
this.requests.queue("".concat(baseUrl).concat(applyParamsAsString({}, this.options)), requestMethod, requestBody, networkParametersNew);
|
|
189
|
+
this.requests.send();
|
|
190
|
+
return true;
|
|
191
|
+
}
|
|
134
192
|
/**
|
|
135
193
|
* Send input focus event to API
|
|
136
194
|
*
|
|
@@ -229,6 +287,88 @@ var Tracker = /*#__PURE__*/function () {
|
|
|
229
287
|
this.requests.send();
|
|
230
288
|
return new Error('parameters are required of type object');
|
|
231
289
|
}
|
|
290
|
+
/**
|
|
291
|
+
* Send autocomplete select event to API
|
|
292
|
+
* @private
|
|
293
|
+
* @function trackAutocompleteSelectV2
|
|
294
|
+
* @param {string} item_name - Name of selected autocomplete item
|
|
295
|
+
* @param {object} parameters - Additional parameters to be sent with request
|
|
296
|
+
* @param {string} parameters.user_input - The current autocomplete search query
|
|
297
|
+
* @param {string} [parameters.section] - Section the selected item resides within
|
|
298
|
+
* @param {string} [parameters.tr] - Trigger used to select the item (click, etc.)
|
|
299
|
+
* @param {string} [parameters.item_id] - Item id of the selected item
|
|
300
|
+
* @param {string} [parameters.variation_id] - Variation id of the selected item
|
|
301
|
+
* @param {string} [parameters.group_id] - Group identifier of selected item
|
|
302
|
+
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
303
|
+
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
304
|
+
* @returns {(true|Error)}
|
|
305
|
+
* @description User selected (clicked, or navigated to via keyboard) a result that appeared within autocomplete
|
|
306
|
+
* @example
|
|
307
|
+
* constructorio.tracker.trackAutocompleteSelectV2(
|
|
308
|
+
* 'T-Shirt',
|
|
309
|
+
* {
|
|
310
|
+
* user_input: 'Shirt',
|
|
311
|
+
* section: 'Products',
|
|
312
|
+
* tr: 'click',
|
|
313
|
+
* group_id: '88JU230',
|
|
314
|
+
* item_id: '12345',
|
|
315
|
+
* variation_id: '12345-A',
|
|
316
|
+
* },
|
|
317
|
+
* );
|
|
318
|
+
*/
|
|
319
|
+
|
|
320
|
+
}, {
|
|
321
|
+
key: "trackAutocompleteSelectV2",
|
|
322
|
+
value: function trackAutocompleteSelectV2(item_name, parameters) {
|
|
323
|
+
var networkParameters = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
324
|
+
|
|
325
|
+
// Ensure term is provided (required)
|
|
326
|
+
if (item_name && typeof item_name === 'string') {
|
|
327
|
+
// Ensure parameters are provided (required)
|
|
328
|
+
if (parameters && (0, _typeof2["default"])(parameters) === 'object' && !Array.isArray(parameters)) {
|
|
329
|
+
var baseUrl = "".concat(this.behavioralV2Url, "autocomplete_select?");
|
|
330
|
+
var original_query = parameters.original_query,
|
|
331
|
+
_parameters$user_inpu = parameters.user_input,
|
|
332
|
+
user_input = _parameters$user_inpu === void 0 ? original_query : _parameters$user_inpu,
|
|
333
|
+
original_section = parameters.original_section,
|
|
334
|
+
_parameters$section = parameters.section,
|
|
335
|
+
section = _parameters$section === void 0 ? original_section : _parameters$section,
|
|
336
|
+
tr = parameters.tr,
|
|
337
|
+
group_id = parameters.group_id,
|
|
338
|
+
item_id = parameters.item_id,
|
|
339
|
+
variation_id = parameters.variation_id;
|
|
340
|
+
var queryParams = {};
|
|
341
|
+
var bodyParams = {
|
|
342
|
+
user_input: user_input,
|
|
343
|
+
tr: tr,
|
|
344
|
+
group_id: group_id,
|
|
345
|
+
item_id: item_id,
|
|
346
|
+
variation_id: variation_id,
|
|
347
|
+
item_name: item_name,
|
|
348
|
+
section: section
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
if (section) {
|
|
352
|
+
queryParams.section = section;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
var requestURL = "".concat(baseUrl).concat(applyParamsAsString(queryParams, this.options));
|
|
356
|
+
var requestMethod = 'POST';
|
|
357
|
+
var requestBody = applyParams(bodyParams, _objectSpread(_objectSpread({}, this.options), {}, {
|
|
358
|
+
requestMethod: requestMethod
|
|
359
|
+
}));
|
|
360
|
+
this.requests.queue(requestURL, requestMethod, requestBody, networkParameters);
|
|
361
|
+
this.requests.send();
|
|
362
|
+
return true;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
this.requests.send();
|
|
366
|
+
return new Error('parameters are required of type object');
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
this.requests.send();
|
|
370
|
+
return new Error('term is a required parameter of type string');
|
|
371
|
+
}
|
|
232
372
|
/**
|
|
233
373
|
* Send autocomplete select event to API
|
|
234
374
|
*
|
|
@@ -306,6 +446,77 @@ var Tracker = /*#__PURE__*/function () {
|
|
|
306
446
|
this.requests.send();
|
|
307
447
|
return new Error('term is a required parameter of type string');
|
|
308
448
|
}
|
|
449
|
+
/**
|
|
450
|
+
* Send autocomplete search event to API
|
|
451
|
+
* @private
|
|
452
|
+
* @function trackSearchSubmitV2
|
|
453
|
+
* @param {string} search_term - Term of submitted autocomplete event
|
|
454
|
+
* @param {object} parameters - Additional parameters to be sent with request
|
|
455
|
+
* @param {string} parameters.user_input - The current autocomplete search query
|
|
456
|
+
* @param {string} [parameters.group_id] - Group identifier of selected item
|
|
457
|
+
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
458
|
+
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
459
|
+
* @returns {(true|Error)}
|
|
460
|
+
* @description User submitted a search (pressing enter within input element, or clicking submit element)
|
|
461
|
+
* @example
|
|
462
|
+
* constructorio.tracker.trackSearchSubmitV2(
|
|
463
|
+
* 'T-Shirt',
|
|
464
|
+
* {
|
|
465
|
+
* user_input: 'Shirt',
|
|
466
|
+
* group_id: '88JU230',
|
|
467
|
+
* },
|
|
468
|
+
* );
|
|
469
|
+
*/
|
|
470
|
+
|
|
471
|
+
}, {
|
|
472
|
+
key: "trackSearchSubmitV2",
|
|
473
|
+
value: function trackSearchSubmitV2(search_term, parameters) {
|
|
474
|
+
var networkParameters = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
475
|
+
|
|
476
|
+
// Ensure term is provided (required)
|
|
477
|
+
if (search_term && typeof search_term === 'string') {
|
|
478
|
+
// Ensure parameters are provided (required)
|
|
479
|
+
if (parameters && (0, _typeof2["default"])(parameters) === 'object' && !Array.isArray(parameters)) {
|
|
480
|
+
var baseUrl = "".concat(this.behavioralV2Url, "search_submit?");
|
|
481
|
+
var original_query = parameters.original_query,
|
|
482
|
+
_parameters$user_inpu2 = parameters.user_input,
|
|
483
|
+
user_input = _parameters$user_inpu2 === void 0 ? original_query : _parameters$user_inpu2,
|
|
484
|
+
group_id = parameters.group_id,
|
|
485
|
+
section = parameters.section;
|
|
486
|
+
var queryParams = {};
|
|
487
|
+
var bodyParams = {
|
|
488
|
+
user_input: user_input,
|
|
489
|
+
search_term: search_term,
|
|
490
|
+
section: section
|
|
491
|
+
};
|
|
492
|
+
|
|
493
|
+
if (group_id) {
|
|
494
|
+
bodyParams.filters = {
|
|
495
|
+
group_id: group_id
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
if (section) {
|
|
500
|
+
queryParams.section = section;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
var requestURL = "".concat(baseUrl).concat(applyParamsAsString(queryParams, this.options));
|
|
504
|
+
var requestMethod = 'POST';
|
|
505
|
+
var requestBody = applyParams(bodyParams, _objectSpread(_objectSpread({}, this.options), {}, {
|
|
506
|
+
requestMethod: requestMethod
|
|
507
|
+
}));
|
|
508
|
+
this.requests.queue(requestURL, requestMethod, requestBody, networkParameters);
|
|
509
|
+
this.requests.send();
|
|
510
|
+
return true;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
this.requests.send();
|
|
514
|
+
return new Error('parameters are required of type object');
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
this.requests.send();
|
|
518
|
+
return new Error('term is a required parameter of type string');
|
|
519
|
+
}
|
|
309
520
|
/**
|
|
310
521
|
* Send autocomplete search event to API
|
|
311
522
|
*
|
|
@@ -368,6 +579,110 @@ var Tracker = /*#__PURE__*/function () {
|
|
|
368
579
|
this.requests.send();
|
|
369
580
|
return new Error('term is a required parameter of type string');
|
|
370
581
|
}
|
|
582
|
+
/**
|
|
583
|
+
* Send search results loaded v2 event to API
|
|
584
|
+
* @private
|
|
585
|
+
* @function trackSearchResultsLoadedV2
|
|
586
|
+
* @param {string} search_term - Search results query term
|
|
587
|
+
* @param {object} parameters - Additional parameters to be sent with request
|
|
588
|
+
* @param {string} parameters.url - URL of the search results page
|
|
589
|
+
* @param {number} [parameters.result_count] - Total number of results
|
|
590
|
+
* @param {number} [parameters.result_page] - Current page of search results
|
|
591
|
+
* @param {string} [parameters.result_id] - Browse result identifier (returned in response from Constructor)
|
|
592
|
+
* @param {object} [parameters.selected_filters] - Selected filters
|
|
593
|
+
* @param {string} [parameters.sort_order] - Sort order ('ascending' or 'descending')
|
|
594
|
+
* @param {string} [parameters.sort_by] - Sorting method
|
|
595
|
+
* @param {object[]} [parameters.items] - List of product item unique identifiers in search results listing
|
|
596
|
+
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
597
|
+
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
598
|
+
* @returns {(true|Error)}
|
|
599
|
+
* @description User viewed a search product listing page
|
|
600
|
+
* @example
|
|
601
|
+
* constructorio.tracker.trackSearchResultsLoadedV2(
|
|
602
|
+
* 'T-Shirt',
|
|
603
|
+
* {
|
|
604
|
+
* result_count: 167,
|
|
605
|
+
* items: [{item_id: 'KMH876'}, {item_id: 'KMH140'}, {item_id: 'KMH437'}],
|
|
606
|
+
* sort_order: 'ascending'
|
|
607
|
+
* sort_by: 'price',
|
|
608
|
+
* result_page: 3,
|
|
609
|
+
* result_count: 20
|
|
610
|
+
* },
|
|
611
|
+
* );
|
|
612
|
+
*/
|
|
613
|
+
|
|
614
|
+
}, {
|
|
615
|
+
key: "trackSearchResultsLoadedV2",
|
|
616
|
+
value: function trackSearchResultsLoadedV2(search_term, parameters) {
|
|
617
|
+
var networkParameters = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
618
|
+
|
|
619
|
+
// Ensure term is provided (required)
|
|
620
|
+
if (search_term && typeof search_term === 'string') {
|
|
621
|
+
// Ensure parameters are provided (required)
|
|
622
|
+
if (parameters && (0, _typeof2["default"])(parameters) === 'object' && !Array.isArray(parameters)) {
|
|
623
|
+
var baseUrl = "".concat(this.behavioralV2Url, "search_result_load?");
|
|
624
|
+
var num_results = parameters.num_results,
|
|
625
|
+
_parameters$result_co = parameters.result_count,
|
|
626
|
+
result_count = _parameters$result_co === void 0 ? num_results : _parameters$result_co,
|
|
627
|
+
customer_ids = parameters.customer_ids,
|
|
628
|
+
item_ids = parameters.item_ids,
|
|
629
|
+
_parameters$items = parameters.items,
|
|
630
|
+
items = _parameters$items === void 0 ? customer_ids || item_ids : _parameters$items,
|
|
631
|
+
result_page = parameters.result_page,
|
|
632
|
+
result_id = parameters.result_id,
|
|
633
|
+
sort_order = parameters.sort_order,
|
|
634
|
+
sort_by = parameters.sort_by,
|
|
635
|
+
selected_filters = parameters.selected_filters,
|
|
636
|
+
url = parameters.url,
|
|
637
|
+
section = parameters.section;
|
|
638
|
+
var queryParams = {};
|
|
639
|
+
var transformedItems;
|
|
640
|
+
|
|
641
|
+
if (items && Array.isArray(items) && items.length !== 0) {
|
|
642
|
+
transformedItems = items;
|
|
643
|
+
|
|
644
|
+
if (typeof items[0] === 'string' || typeof items[0] === 'number') {
|
|
645
|
+
transformedItems = items.map(function (itemId) {
|
|
646
|
+
return {
|
|
647
|
+
item_id: String(itemId)
|
|
648
|
+
};
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
if (section) {
|
|
654
|
+
queryParams.section = section;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
var bodyParams = {
|
|
658
|
+
search_term: search_term,
|
|
659
|
+
result_count: result_count,
|
|
660
|
+
items: transformedItems,
|
|
661
|
+
result_page: result_page,
|
|
662
|
+
result_id: result_id,
|
|
663
|
+
sort_order: sort_order,
|
|
664
|
+
sort_by: sort_by,
|
|
665
|
+
selected_filters: selected_filters,
|
|
666
|
+
url: url,
|
|
667
|
+
section: section
|
|
668
|
+
};
|
|
669
|
+
var requestURL = "".concat(baseUrl).concat(applyParamsAsString(queryParams, this.options));
|
|
670
|
+
var requestMethod = 'POST';
|
|
671
|
+
var requestBody = applyParams(bodyParams, _objectSpread(_objectSpread({}, this.options), {}, {
|
|
672
|
+
requestMethod: requestMethod
|
|
673
|
+
}));
|
|
674
|
+
this.requests.queue(requestURL, requestMethod, requestBody, networkParameters);
|
|
675
|
+
this.requests.send();
|
|
676
|
+
return true;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
this.requests.send();
|
|
680
|
+
return new Error('parameters are required of type object');
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
this.requests.send();
|
|
684
|
+
return new Error('term is a required parameter of type string');
|
|
685
|
+
}
|
|
371
686
|
/**
|
|
372
687
|
* Send search results loaded event to API
|
|
373
688
|
*
|
|
@@ -436,6 +751,97 @@ var Tracker = /*#__PURE__*/function () {
|
|
|
436
751
|
this.requests.send();
|
|
437
752
|
return new Error('term is a required parameter of type string');
|
|
438
753
|
}
|
|
754
|
+
/**
|
|
755
|
+
* Send click through event to API
|
|
756
|
+
* @private
|
|
757
|
+
* @function trackSearchResultClickV2
|
|
758
|
+
* @param {string} term - Search results query term
|
|
759
|
+
* @param {object} parameters - Additional parameters to be sent with request
|
|
760
|
+
* @param {string} parameters.item_name - Product item name (Either item_name or item_id is required)
|
|
761
|
+
* @param {string} parameters.item_id - Product item unique identifier
|
|
762
|
+
* @param {string} [parameters.variation_id] - Product item variation unique identifier
|
|
763
|
+
* @param {string} [parameters.result_id] - Search result identifier (returned in response from Constructor)
|
|
764
|
+
* @param {number} [parameters.result_count] - Number of results in total
|
|
765
|
+
* @param {number} [parameters.result_page] - Current page of results
|
|
766
|
+
* @param {string} [parameters.result_position_on_page] - Position of selected items on page
|
|
767
|
+
* @param {string} [parameters.num_results_per_page] - Number of results per page
|
|
768
|
+
* @param {object} [parameters.selected_filters] - Key - Value map of selected filters
|
|
769
|
+
* @param {string} [parameters.section] - The section name for the item Ex. "Products"
|
|
770
|
+
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
771
|
+
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
772
|
+
* @returns {(true|Error)}
|
|
773
|
+
* @description User clicked a result that appeared within a search product listing page
|
|
774
|
+
* @example
|
|
775
|
+
* constructorio.tracker.trackSearchResultClickV2(
|
|
776
|
+
* 'T-Shirt',
|
|
777
|
+
* {
|
|
778
|
+
* item_name: 'Red T-Shirt',
|
|
779
|
+
* item_id: 'KMH876',
|
|
780
|
+
* result_id: '019927c2-f955-4020-8b8d-6b21b93cb5a2',
|
|
781
|
+
* },
|
|
782
|
+
* );
|
|
783
|
+
*/
|
|
784
|
+
|
|
785
|
+
}, {
|
|
786
|
+
key: "trackSearchResultClickV2",
|
|
787
|
+
value: function trackSearchResultClickV2(term, parameters) {
|
|
788
|
+
var networkParameters = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
789
|
+
|
|
790
|
+
// Ensure term is provided (required)
|
|
791
|
+
if (term && typeof term === 'string') {
|
|
792
|
+
// Ensure parameters are provided (required)
|
|
793
|
+
if (parameters && (0, _typeof2["default"])(parameters) === 'object' && !Array.isArray(parameters)) {
|
|
794
|
+
var baseUrl = "".concat(this.behavioralV2Url, "search_result_click?");
|
|
795
|
+
var customer_id = parameters.customer_id,
|
|
796
|
+
_parameters$item_id = parameters.item_id,
|
|
797
|
+
item_id = _parameters$item_id === void 0 ? customer_id : _parameters$item_id,
|
|
798
|
+
name = parameters.name,
|
|
799
|
+
_parameters$item_name = parameters.item_name,
|
|
800
|
+
item_name = _parameters$item_name === void 0 ? name : _parameters$item_name,
|
|
801
|
+
variation_id = parameters.variation_id,
|
|
802
|
+
result_id = parameters.result_id,
|
|
803
|
+
result_count = parameters.result_count,
|
|
804
|
+
result_page = parameters.result_page,
|
|
805
|
+
result_position_on_page = parameters.result_position_on_page,
|
|
806
|
+
num_results_per_page = parameters.num_results_per_page,
|
|
807
|
+
selected_filters = parameters.selected_filters,
|
|
808
|
+
section = parameters.section;
|
|
809
|
+
var bodyParams = {
|
|
810
|
+
item_name: item_name,
|
|
811
|
+
item_id: item_id,
|
|
812
|
+
variation_id: variation_id,
|
|
813
|
+
result_id: result_id,
|
|
814
|
+
result_count: result_count,
|
|
815
|
+
result_page: result_page,
|
|
816
|
+
result_position_on_page: result_position_on_page,
|
|
817
|
+
num_results_per_page: num_results_per_page,
|
|
818
|
+
selected_filters: selected_filters,
|
|
819
|
+
section: section,
|
|
820
|
+
search_term: term
|
|
821
|
+
};
|
|
822
|
+
var queryParams = {};
|
|
823
|
+
|
|
824
|
+
if (section) {
|
|
825
|
+
queryParams.section = section;
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
var requestURL = "".concat(baseUrl).concat(applyParamsAsString(queryParams, this.options));
|
|
829
|
+
var requestMethod = 'POST';
|
|
830
|
+
var requestBody = applyParams(bodyParams, _objectSpread(_objectSpread({}, this.options), {}, {
|
|
831
|
+
requestMethod: requestMethod
|
|
832
|
+
}));
|
|
833
|
+
this.requests.queue(requestURL, requestMethod, requestBody, networkParameters);
|
|
834
|
+
this.requests.send();
|
|
835
|
+
return true;
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
this.requests.send();
|
|
839
|
+
return new Error('parameters are required of type object');
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
this.requests.send();
|
|
843
|
+
return new Error('term is a required parameter of type string');
|
|
844
|
+
}
|
|
439
845
|
/**
|
|
440
846
|
* Send click through event to API
|
|
441
847
|
*
|
|
@@ -480,8 +886,8 @@ var Tracker = /*#__PURE__*/function () {
|
|
|
480
886
|
customer_id = parameters.customer_id,
|
|
481
887
|
variation_id = parameters.variation_id,
|
|
482
888
|
result_id = parameters.result_id,
|
|
483
|
-
|
|
484
|
-
|
|
889
|
+
section = parameters.section,
|
|
890
|
+
item_is_convertible = parameters.item_is_convertible; // Ensure support for both item_name and name as parameters
|
|
485
891
|
|
|
486
892
|
if (item_name) {
|
|
487
893
|
queryParams.name = item_name;
|
|
@@ -576,8 +982,8 @@ var Tracker = /*#__PURE__*/function () {
|
|
|
576
982
|
customer_id = parameters.customer_id,
|
|
577
983
|
variation_id = parameters.variation_id,
|
|
578
984
|
revenue = parameters.revenue,
|
|
579
|
-
_parameters$
|
|
580
|
-
section = _parameters$
|
|
985
|
+
_parameters$section2 = parameters.section,
|
|
986
|
+
section = _parameters$section2 === void 0 ? 'Products' : _parameters$section2,
|
|
581
987
|
display_name = parameters.display_name,
|
|
582
988
|
type = parameters.type,
|
|
583
989
|
is_custom_type = parameters.is_custom_type; // Ensure support for both item_id and customer_id as parameters
|
|
@@ -1235,6 +1641,433 @@ var Tracker = /*#__PURE__*/function () {
|
|
|
1235
1641
|
this.requests.send();
|
|
1236
1642
|
return new Error('A parameters object with an "item_id" property is required.');
|
|
1237
1643
|
}
|
|
1644
|
+
/**
|
|
1645
|
+
* Send quiz results loaded event to API
|
|
1646
|
+
*
|
|
1647
|
+
* @function trackQuizResultsLoaded
|
|
1648
|
+
* @param {object} parameters - Additional parameters to be sent with request
|
|
1649
|
+
* @param {string} parameters.quiz_id - Quiz identifier
|
|
1650
|
+
* @param {string} parameters.quiz_version_id - Quiz version identifier
|
|
1651
|
+
* @param {string} parameters.quiz_session_id - Quiz session identifier associated with this conversion event
|
|
1652
|
+
* @param {string} parameters.url - Current page url
|
|
1653
|
+
* @param {string} [parameters.section='Products'] - Index section
|
|
1654
|
+
* @param {number} [parameters.result_count] - Total number of results
|
|
1655
|
+
* @param {number} [parameters.result_page] - The page of the results
|
|
1656
|
+
* @param {string} [parameters.result_id] - Quiz result identifier (returned in response from Constructor)
|
|
1657
|
+
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
1658
|
+
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
1659
|
+
* @returns {(true|Error)}
|
|
1660
|
+
* @description User viewed a quiz results page
|
|
1661
|
+
* @example
|
|
1662
|
+
* constructorio.tracker.trackQuizResultsLoaded(
|
|
1663
|
+
* {
|
|
1664
|
+
* quiz_id: 'coffee-quiz',
|
|
1665
|
+
* quiz_version_id: '1231244',
|
|
1666
|
+
* quiz_session_id: '3123',
|
|
1667
|
+
* url: 'www.example.com',
|
|
1668
|
+
* result_count: 167,
|
|
1669
|
+
* },
|
|
1670
|
+
* );
|
|
1671
|
+
*/
|
|
1672
|
+
|
|
1673
|
+
}, {
|
|
1674
|
+
key: "trackQuizResultsLoaded",
|
|
1675
|
+
value: function trackQuizResultsLoaded(parameters) {
|
|
1676
|
+
var networkParameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1677
|
+
|
|
1678
|
+
// Ensure parameters are provided (required)
|
|
1679
|
+
if (parameters && (0, _typeof2["default"])(parameters) === 'object' && !Array.isArray(parameters)) {
|
|
1680
|
+
var requestPath = "".concat(this.options.serviceUrl, "/v2/behavioral_action/quiz_result_load?");
|
|
1681
|
+
var quiz_id = parameters.quiz_id,
|
|
1682
|
+
quiz_version_id = parameters.quiz_version_id,
|
|
1683
|
+
quiz_session_id = parameters.quiz_session_id,
|
|
1684
|
+
url = parameters.url,
|
|
1685
|
+
_parameters$section3 = parameters.section,
|
|
1686
|
+
section = _parameters$section3 === void 0 ? 'Products' : _parameters$section3,
|
|
1687
|
+
result_count = parameters.result_count,
|
|
1688
|
+
result_id = parameters.result_id,
|
|
1689
|
+
result_page = parameters.result_page;
|
|
1690
|
+
var queryParams = {};
|
|
1691
|
+
var bodyParams = {};
|
|
1692
|
+
|
|
1693
|
+
if (typeof quiz_id !== 'string') {
|
|
1694
|
+
return new Error('"quiz_id" is a required parameter of type string');
|
|
1695
|
+
}
|
|
1696
|
+
|
|
1697
|
+
if (typeof quiz_version_id !== 'string') {
|
|
1698
|
+
return new Error('"quiz_version_id" is a required parameter of type string');
|
|
1699
|
+
}
|
|
1700
|
+
|
|
1701
|
+
if (typeof quiz_session_id !== 'string') {
|
|
1702
|
+
return new Error('"quiz_session_id" is a required parameter of type string');
|
|
1703
|
+
}
|
|
1704
|
+
|
|
1705
|
+
if (typeof url !== 'string') {
|
|
1706
|
+
return new Error('"url" is a required parameter of type string');
|
|
1707
|
+
}
|
|
1708
|
+
|
|
1709
|
+
bodyParams.quiz_id = quiz_id;
|
|
1710
|
+
bodyParams.quiz_version_id = quiz_version_id;
|
|
1711
|
+
bodyParams.quiz_session_id = quiz_session_id;
|
|
1712
|
+
bodyParams.url = url;
|
|
1713
|
+
|
|
1714
|
+
if (!helpers.isNil(section)) {
|
|
1715
|
+
if (typeof section !== 'string') {
|
|
1716
|
+
return new Error('"section" must be a string');
|
|
1717
|
+
}
|
|
1718
|
+
|
|
1719
|
+
queryParams.section = section;
|
|
1720
|
+
bodyParams.section = section;
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1723
|
+
if (!helpers.isNil(result_count)) {
|
|
1724
|
+
if (typeof result_count !== 'number') {
|
|
1725
|
+
return new Error('"result_count" must be a number');
|
|
1726
|
+
}
|
|
1727
|
+
|
|
1728
|
+
bodyParams.result_count = result_count;
|
|
1729
|
+
}
|
|
1730
|
+
|
|
1731
|
+
if (!helpers.isNil(result_id)) {
|
|
1732
|
+
if (typeof result_id !== 'string') {
|
|
1733
|
+
return new Error('"result_id" must be a string');
|
|
1734
|
+
}
|
|
1735
|
+
|
|
1736
|
+
bodyParams.result_id = result_id;
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1739
|
+
if (!helpers.isNil(result_page)) {
|
|
1740
|
+
if (typeof result_page !== 'number') {
|
|
1741
|
+
return new Error('"result_page" must be a number');
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1744
|
+
bodyParams.result_page = result_page;
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1747
|
+
bodyParams.action_class = 'result_load';
|
|
1748
|
+
var requestURL = "".concat(requestPath).concat(applyParamsAsString(queryParams, this.options));
|
|
1749
|
+
var requestMethod = 'POST';
|
|
1750
|
+
var requestBody = applyParams(bodyParams, _objectSpread(_objectSpread({}, this.options), {}, {
|
|
1751
|
+
requestMethod: requestMethod
|
|
1752
|
+
}));
|
|
1753
|
+
this.requests.queue(requestURL, requestMethod, requestBody, networkParameters);
|
|
1754
|
+
this.requests.send();
|
|
1755
|
+
return true;
|
|
1756
|
+
}
|
|
1757
|
+
|
|
1758
|
+
this.requests.send();
|
|
1759
|
+
return new Error('parameters are required of type object');
|
|
1760
|
+
}
|
|
1761
|
+
/**
|
|
1762
|
+
* Send quiz result click event to API
|
|
1763
|
+
*
|
|
1764
|
+
* @function trackQuizResultClick
|
|
1765
|
+
* @param {object} parameters - Additional parameters to be sent with request
|
|
1766
|
+
* @param {string} parameters.quiz_id - Quiz identifier
|
|
1767
|
+
* @param {string} parameters.quiz_version_id - Quiz version identifier
|
|
1768
|
+
* @param {string} parameters.quiz_session_id - Quiz session identifier associated with this conversion event
|
|
1769
|
+
* @param {string} [parameters.item_id] - Product item unique identifier (Either item_id or item_name is required)
|
|
1770
|
+
* @param {string} [parameters.item_name] - Product item name
|
|
1771
|
+
* @param {string} [parameters.section='Products'] - Index section
|
|
1772
|
+
* @param {number} [parameters.result_count] - Total number of results
|
|
1773
|
+
* @param {number} [parameters.result_page] - The page of the results
|
|
1774
|
+
* @param {string} [parameters.result_id] - Quiz result identifier (returned in response from Constructor)
|
|
1775
|
+
* @param {number} [parameters.result_position_on_page] - Position of clicked item
|
|
1776
|
+
* @param {number} [parameters.num_results_per_page] - Number of results shown
|
|
1777
|
+
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
1778
|
+
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
1779
|
+
* @returns {(true|Error)}
|
|
1780
|
+
* @description User viewed a quiz results page
|
|
1781
|
+
* @example
|
|
1782
|
+
* constructorio.tracker.trackQuizResultClick(
|
|
1783
|
+
* {
|
|
1784
|
+
* quiz_id: 'coffee-quiz',
|
|
1785
|
+
* quiz_version_id: '1231244',
|
|
1786
|
+
* quiz_session_id: '123',
|
|
1787
|
+
* item_id: '123',
|
|
1788
|
+
* item_name: 'espresso'
|
|
1789
|
+
* },
|
|
1790
|
+
* );
|
|
1791
|
+
*/
|
|
1792
|
+
// eslint-disable-next-line complexity
|
|
1793
|
+
|
|
1794
|
+
}, {
|
|
1795
|
+
key: "trackQuizResultClick",
|
|
1796
|
+
value: function trackQuizResultClick(parameters) {
|
|
1797
|
+
var networkParameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1798
|
+
|
|
1799
|
+
// Ensure parameters are provided (required)
|
|
1800
|
+
if (parameters && (0, _typeof2["default"])(parameters) === 'object' && !Array.isArray(parameters)) {
|
|
1801
|
+
var requestPath = "".concat(this.options.serviceUrl, "/v2/behavioral_action/quiz_result_click?");
|
|
1802
|
+
var quiz_id = parameters.quiz_id,
|
|
1803
|
+
quiz_version_id = parameters.quiz_version_id,
|
|
1804
|
+
quiz_session_id = parameters.quiz_session_id,
|
|
1805
|
+
item_id = parameters.item_id,
|
|
1806
|
+
item_name = parameters.item_name,
|
|
1807
|
+
result_count = parameters.result_count,
|
|
1808
|
+
result_id = parameters.result_id,
|
|
1809
|
+
result_page = parameters.result_page,
|
|
1810
|
+
num_results_per_page = parameters.num_results_per_page,
|
|
1811
|
+
result_position_on_page = parameters.result_position_on_page,
|
|
1812
|
+
_parameters$section4 = parameters.section,
|
|
1813
|
+
section = _parameters$section4 === void 0 ? 'Products' : _parameters$section4;
|
|
1814
|
+
var queryParams = {};
|
|
1815
|
+
var bodyParams = {}; // Ensure required parameters provided
|
|
1816
|
+
|
|
1817
|
+
if (typeof quiz_id !== 'string') {
|
|
1818
|
+
return new Error('"quiz_id" is a required parameter of type string');
|
|
1819
|
+
}
|
|
1820
|
+
|
|
1821
|
+
if (typeof quiz_version_id !== 'string') {
|
|
1822
|
+
return new Error('"quiz_version_id" is a required parameter of type string');
|
|
1823
|
+
}
|
|
1824
|
+
|
|
1825
|
+
if (typeof quiz_session_id !== 'string') {
|
|
1826
|
+
return new Error('"quiz_session_id" is a required parameter of type string');
|
|
1827
|
+
}
|
|
1828
|
+
|
|
1829
|
+
if (typeof item_id !== 'string' && typeof item_name !== 'string') {
|
|
1830
|
+
return new Error('"item_id" or "item_name" is a required parameter of type string');
|
|
1831
|
+
}
|
|
1832
|
+
|
|
1833
|
+
bodyParams.quiz_id = quiz_id;
|
|
1834
|
+
bodyParams.quiz_version_id = quiz_version_id;
|
|
1835
|
+
bodyParams.quiz_session_id = quiz_session_id;
|
|
1836
|
+
|
|
1837
|
+
if (!helpers.isNil(item_id)) {
|
|
1838
|
+
if (typeof item_id !== 'string') {
|
|
1839
|
+
return new Error('"item_id" must be a string');
|
|
1840
|
+
}
|
|
1841
|
+
|
|
1842
|
+
bodyParams.item_id = item_id;
|
|
1843
|
+
}
|
|
1844
|
+
|
|
1845
|
+
if (!helpers.isNil(item_name)) {
|
|
1846
|
+
if (typeof item_name !== 'string') {
|
|
1847
|
+
return new Error('"item_name" must be a string');
|
|
1848
|
+
}
|
|
1849
|
+
|
|
1850
|
+
bodyParams.item_name = item_name;
|
|
1851
|
+
}
|
|
1852
|
+
|
|
1853
|
+
if (!helpers.isNil(section)) {
|
|
1854
|
+
if (typeof section !== 'string') {
|
|
1855
|
+
return new Error('"section" must be a string');
|
|
1856
|
+
}
|
|
1857
|
+
|
|
1858
|
+
queryParams.section = section;
|
|
1859
|
+
}
|
|
1860
|
+
|
|
1861
|
+
if (!helpers.isNil(result_count)) {
|
|
1862
|
+
if (typeof result_count !== 'number') {
|
|
1863
|
+
return new Error('"result_count" must be a number');
|
|
1864
|
+
}
|
|
1865
|
+
|
|
1866
|
+
bodyParams.result_count = result_count;
|
|
1867
|
+
}
|
|
1868
|
+
|
|
1869
|
+
if (!helpers.isNil(result_id)) {
|
|
1870
|
+
if (typeof result_id !== 'string') {
|
|
1871
|
+
return new Error('"result_id" must be a string');
|
|
1872
|
+
}
|
|
1873
|
+
|
|
1874
|
+
bodyParams.result_id = result_id;
|
|
1875
|
+
}
|
|
1876
|
+
|
|
1877
|
+
if (!helpers.isNil(result_page)) {
|
|
1878
|
+
if (typeof result_page !== 'number') {
|
|
1879
|
+
return new Error('"result_page" must be a number');
|
|
1880
|
+
}
|
|
1881
|
+
|
|
1882
|
+
bodyParams.result_page = result_page;
|
|
1883
|
+
}
|
|
1884
|
+
|
|
1885
|
+
if (!helpers.isNil(num_results_per_page)) {
|
|
1886
|
+
if (typeof num_results_per_page !== 'number') {
|
|
1887
|
+
return new Error('"num_results_per_page" must be a number');
|
|
1888
|
+
}
|
|
1889
|
+
|
|
1890
|
+
bodyParams.num_results_per_page = num_results_per_page;
|
|
1891
|
+
}
|
|
1892
|
+
|
|
1893
|
+
if (!helpers.isNil(result_position_on_page)) {
|
|
1894
|
+
if (typeof result_position_on_page !== 'number') {
|
|
1895
|
+
return new Error('"result_position_on_page" must be a number');
|
|
1896
|
+
}
|
|
1897
|
+
|
|
1898
|
+
bodyParams.result_position_on_page = result_position_on_page;
|
|
1899
|
+
}
|
|
1900
|
+
|
|
1901
|
+
bodyParams.action_class = 'result_click';
|
|
1902
|
+
var requestURL = "".concat(requestPath).concat(applyParamsAsString(queryParams, this.options));
|
|
1903
|
+
var requestMethod = 'POST';
|
|
1904
|
+
var requestBody = applyParams(bodyParams, _objectSpread(_objectSpread({}, this.options), {}, {
|
|
1905
|
+
requestMethod: requestMethod
|
|
1906
|
+
}));
|
|
1907
|
+
this.requests.queue(requestURL, requestMethod, requestBody, networkParameters);
|
|
1908
|
+
this.requests.send();
|
|
1909
|
+
return true;
|
|
1910
|
+
}
|
|
1911
|
+
|
|
1912
|
+
this.requests.send();
|
|
1913
|
+
return new Error('parameters are required of type object');
|
|
1914
|
+
}
|
|
1915
|
+
/**
|
|
1916
|
+
* Send quiz conversion event to API
|
|
1917
|
+
*
|
|
1918
|
+
* @function trackQuizConversion
|
|
1919
|
+
* @param {object} parameters - Additional parameters to be sent with request
|
|
1920
|
+
* @param {string} parameters.quiz_id - Quiz identifier
|
|
1921
|
+
* @param {string} parameters.quiz_version_id - Quiz version identifier
|
|
1922
|
+
* @param {string} parameters.quiz_session_id - Quiz session identifier associated with this conversion event
|
|
1923
|
+
* @param {string} [parameters.item_id] - Product item unique identifier (Either item_id or item_name is required)
|
|
1924
|
+
* @param {string} [parameters.item_name] - Product item name
|
|
1925
|
+
* @param {string} [parameters.variation_id] - Product item variation unique identifier
|
|
1926
|
+
* @param {string} [parameters.revenue] - Sale price if available, otherwise the regular (retail) price of item
|
|
1927
|
+
* @param {string} [parameters.section='Products'] - Index section
|
|
1928
|
+
* @param {string} [parameters.type='add_to_cart'] - Conversion type
|
|
1929
|
+
* @param {boolean} [parameters.is_custom_type] - Specify if type is custom conversion type
|
|
1930
|
+
* @param {string} [parameters.display_name] - Display name for the custom conversion type
|
|
1931
|
+
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
1932
|
+
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
1933
|
+
* @returns {(true|Error)}
|
|
1934
|
+
* @description User viewed a quiz results page
|
|
1935
|
+
* @example
|
|
1936
|
+
* constructorio.tracker.trackQuizConversion(
|
|
1937
|
+
* {
|
|
1938
|
+
* quiz_id: 'coffee-quiz',
|
|
1939
|
+
* quiz_version_id: '1231244',
|
|
1940
|
+
* quiz_session_id: '3123',
|
|
1941
|
+
* item_name: 'espresso',
|
|
1942
|
+
* variation_id: '167',
|
|
1943
|
+
* type: 'add_to_cart",
|
|
1944
|
+
* revenue: '1.0"
|
|
1945
|
+
* },
|
|
1946
|
+
* );
|
|
1947
|
+
*/
|
|
1948
|
+
// eslint-disable-next-line complexity
|
|
1949
|
+
|
|
1950
|
+
}, {
|
|
1951
|
+
key: "trackQuizConversion",
|
|
1952
|
+
value: function trackQuizConversion(parameters) {
|
|
1953
|
+
var networkParameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1954
|
+
|
|
1955
|
+
// Ensure parameters are provided (required)
|
|
1956
|
+
if (parameters && (0, _typeof2["default"])(parameters) === 'object' && !Array.isArray(parameters)) {
|
|
1957
|
+
var requestPath = "".concat(this.options.serviceUrl, "/v2/behavioral_action/quiz_conversion?");
|
|
1958
|
+
var quiz_id = parameters.quiz_id,
|
|
1959
|
+
quiz_version_id = parameters.quiz_version_id,
|
|
1960
|
+
quiz_session_id = parameters.quiz_session_id,
|
|
1961
|
+
item_id = parameters.item_id,
|
|
1962
|
+
item_name = parameters.item_name,
|
|
1963
|
+
variation_id = parameters.variation_id,
|
|
1964
|
+
revenue = parameters.revenue,
|
|
1965
|
+
_parameters$section5 = parameters.section,
|
|
1966
|
+
section = _parameters$section5 === void 0 ? 'Products' : _parameters$section5,
|
|
1967
|
+
type = parameters.type,
|
|
1968
|
+
is_custom_type = parameters.is_custom_type,
|
|
1969
|
+
display_name = parameters.display_name;
|
|
1970
|
+
var queryParams = {};
|
|
1971
|
+
var bodyParams = {}; // Ensure required parameters provided
|
|
1972
|
+
|
|
1973
|
+
if (typeof quiz_id !== 'string') {
|
|
1974
|
+
return new Error('"quiz_id" is a required parameter of type string');
|
|
1975
|
+
}
|
|
1976
|
+
|
|
1977
|
+
if (typeof quiz_version_id !== 'string') {
|
|
1978
|
+
return new Error('"quiz_version_id" is a required parameter of type string');
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1981
|
+
if (typeof quiz_session_id !== 'string') {
|
|
1982
|
+
return new Error('"quiz_session_id" is a required parameter of type string');
|
|
1983
|
+
}
|
|
1984
|
+
|
|
1985
|
+
if (typeof item_id !== 'string' && typeof item_name !== 'string') {
|
|
1986
|
+
return new Error('"item_id" or "item_name" is a required parameter of type string');
|
|
1987
|
+
}
|
|
1988
|
+
|
|
1989
|
+
bodyParams.quiz_id = quiz_id;
|
|
1990
|
+
bodyParams.quiz_version_id = quiz_version_id;
|
|
1991
|
+
bodyParams.quiz_session_id = quiz_session_id;
|
|
1992
|
+
|
|
1993
|
+
if (!helpers.isNil(item_id)) {
|
|
1994
|
+
if (typeof item_id !== 'string') {
|
|
1995
|
+
return new Error('"item_id" must be a string');
|
|
1996
|
+
}
|
|
1997
|
+
|
|
1998
|
+
bodyParams.item_id = item_id;
|
|
1999
|
+
}
|
|
2000
|
+
|
|
2001
|
+
if (!helpers.isNil(item_name)) {
|
|
2002
|
+
if (typeof item_name !== 'string') {
|
|
2003
|
+
return new Error('"item_name" must be a string');
|
|
2004
|
+
}
|
|
2005
|
+
|
|
2006
|
+
bodyParams.item_name = item_name;
|
|
2007
|
+
}
|
|
2008
|
+
|
|
2009
|
+
if (!helpers.isNil(variation_id)) {
|
|
2010
|
+
if (typeof variation_id !== 'string') {
|
|
2011
|
+
return new Error('"variation_id" must be a string');
|
|
2012
|
+
}
|
|
2013
|
+
|
|
2014
|
+
bodyParams.variation_id = variation_id;
|
|
2015
|
+
}
|
|
2016
|
+
|
|
2017
|
+
if (!helpers.isNil(revenue)) {
|
|
2018
|
+
if (typeof revenue !== 'string') {
|
|
2019
|
+
return new Error('"revenue" must be a string');
|
|
2020
|
+
}
|
|
2021
|
+
|
|
2022
|
+
bodyParams.revenue = revenue;
|
|
2023
|
+
}
|
|
2024
|
+
|
|
2025
|
+
if (!helpers.isNil(section)) {
|
|
2026
|
+
if (typeof section !== 'string') {
|
|
2027
|
+
return new Error('"section" must be a string');
|
|
2028
|
+
}
|
|
2029
|
+
|
|
2030
|
+
bodyParams.section = section;
|
|
2031
|
+
}
|
|
2032
|
+
|
|
2033
|
+
if (!helpers.isNil(type)) {
|
|
2034
|
+
if (typeof type !== 'string') {
|
|
2035
|
+
return new Error('"type" must be a string');
|
|
2036
|
+
}
|
|
2037
|
+
|
|
2038
|
+
bodyParams.type = type;
|
|
2039
|
+
}
|
|
2040
|
+
|
|
2041
|
+
if (!helpers.isNil(is_custom_type)) {
|
|
2042
|
+
if (typeof is_custom_type !== 'boolean') {
|
|
2043
|
+
return new Error('"is_custom_type" must be a boolean');
|
|
2044
|
+
}
|
|
2045
|
+
|
|
2046
|
+
bodyParams.is_custom_type = is_custom_type;
|
|
2047
|
+
}
|
|
2048
|
+
|
|
2049
|
+
if (!helpers.isNil(display_name)) {
|
|
2050
|
+
if (typeof display_name !== 'string') {
|
|
2051
|
+
return new Error('"display_name" must be a string');
|
|
2052
|
+
}
|
|
2053
|
+
|
|
2054
|
+
bodyParams.display_name = display_name;
|
|
2055
|
+
}
|
|
2056
|
+
|
|
2057
|
+
bodyParams.action_class = 'conversion';
|
|
2058
|
+
var requestURL = "".concat(requestPath).concat(applyParamsAsString(queryParams, this.options));
|
|
2059
|
+
var requestMethod = 'POST';
|
|
2060
|
+
var requestBody = applyParams(bodyParams, _objectSpread(_objectSpread({}, this.options), {}, {
|
|
2061
|
+
requestMethod: requestMethod
|
|
2062
|
+
}));
|
|
2063
|
+
this.requests.queue(requestURL, requestMethod, requestBody, networkParameters);
|
|
2064
|
+
this.requests.send();
|
|
2065
|
+
return true;
|
|
2066
|
+
}
|
|
2067
|
+
|
|
2068
|
+
this.requests.send();
|
|
2069
|
+
return new Error('parameters are required of type object');
|
|
2070
|
+
}
|
|
1238
2071
|
/**
|
|
1239
2072
|
* Subscribe to success or error messages emitted by tracking requests
|
|
1240
2073
|
*
|
package/lib/types/tracker.d.ts
CHANGED
|
@@ -171,5 +171,51 @@ declare class Tracker {
|
|
|
171
171
|
networkParameters?: NetworkParameters
|
|
172
172
|
): true | Error;
|
|
173
173
|
|
|
174
|
+
trackQuizResultsLoaded(
|
|
175
|
+
parameters: {
|
|
176
|
+
quiz_id: string;
|
|
177
|
+
quiz_version_id: string;
|
|
178
|
+
url: string;
|
|
179
|
+
section?: string;
|
|
180
|
+
result_count?: number;
|
|
181
|
+
result_page?: number;
|
|
182
|
+
result_id?: string;
|
|
183
|
+
},
|
|
184
|
+
networkParameters?: NetworkParameters
|
|
185
|
+
): true | Error;
|
|
186
|
+
|
|
187
|
+
trackQuizResultClick(
|
|
188
|
+
parameters: {
|
|
189
|
+
quiz_id: string;
|
|
190
|
+
quiz_version_id: string;
|
|
191
|
+
item_id?: string;
|
|
192
|
+
item_name?: string;
|
|
193
|
+
section?: string;
|
|
194
|
+
result_count?: number;
|
|
195
|
+
result_page?: number;
|
|
196
|
+
result_id?: string;
|
|
197
|
+
result_position_on_page?: number;
|
|
198
|
+
num_results_per_page?: number;
|
|
199
|
+
},
|
|
200
|
+
networkParameters?: NetworkParameters
|
|
201
|
+
): true | Error;
|
|
202
|
+
|
|
203
|
+
trackQuizConversion(
|
|
204
|
+
parameters: {
|
|
205
|
+
quiz_id: string;
|
|
206
|
+
quiz_version_id: string;
|
|
207
|
+
quiz_session_id: string;
|
|
208
|
+
item_id?: string;
|
|
209
|
+
item_name?: string;
|
|
210
|
+
section?: string;
|
|
211
|
+
variation_id?: string;
|
|
212
|
+
revenue?: string;
|
|
213
|
+
type?: string;
|
|
214
|
+
is_custom_type?: boolean;
|
|
215
|
+
display_name?: string;
|
|
216
|
+
},
|
|
217
|
+
networkParameters?: NetworkParameters
|
|
218
|
+
): true | Error;
|
|
219
|
+
|
|
174
220
|
on(messageType: string, callback: Function): true | Error;
|
|
175
221
|
}
|
package/package.json
CHANGED
package/lib/types/types.d.ts
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import EventDispatcher from './event-dispatcher';
|
|
2
|
-
|
|
3
|
-
export interface ConstructorClientOptions {
|
|
4
|
-
apiKey: string;
|
|
5
|
-
version?: string;
|
|
6
|
-
serviceUrl?: string;
|
|
7
|
-
// session id is of type string in jsdocs but of type number in code usage
|
|
8
|
-
sessionId?: string;
|
|
9
|
-
clientId?: string;
|
|
10
|
-
userId?: string;
|
|
11
|
-
segments?: string[];
|
|
12
|
-
testCells?: Record<string, string>;
|
|
13
|
-
fetch?: any;
|
|
14
|
-
trackingSendDelay?: number;
|
|
15
|
-
sendTrackingEvents?: boolean;
|
|
16
|
-
sendReferrerWithTrackingEvents?: boolean;
|
|
17
|
-
eventDispatcher?: EventDispatcher;
|
|
18
|
-
beaconMode?: boolean;
|
|
19
|
-
networkParameters?: {
|
|
20
|
-
timeout: number;
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface RequestFeature extends Record<string, any> {
|
|
25
|
-
query_items: boolean;
|
|
26
|
-
auto_generated_refined_query_rules: boolean;
|
|
27
|
-
manual_searchandizing: boolean;
|
|
28
|
-
personalization: boolean;
|
|
29
|
-
filter_items: boolean;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface RequestFeatureVariant extends Record<string, any> {
|
|
33
|
-
query_items: string;
|
|
34
|
-
auto_generated_refined_query_rules: string;
|
|
35
|
-
manual_searchandizing: string | null;
|
|
36
|
-
personalization: string;
|
|
37
|
-
filter_items: string;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export type ErrorData = {
|
|
41
|
-
message: string;
|
|
42
|
-
[key: string]: any;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export interface ResultSources extends Record<string, any> {
|
|
46
|
-
token_match: { count: number; [key: string]: any };
|
|
47
|
-
embeddings_match: { count: number; [key: string]: any };
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export interface SortOption extends Record<string, any> {
|
|
51
|
-
sort_by: string;
|
|
52
|
-
display_name: string;
|
|
53
|
-
sort_order: string;
|
|
54
|
-
status: string;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export interface Feature extends Record<string, any> {
|
|
58
|
-
feature_name: string;
|
|
59
|
-
display_name: string;
|
|
60
|
-
enabled: boolean;
|
|
61
|
-
variant: {
|
|
62
|
-
name: string;
|
|
63
|
-
display_name: string;
|
|
64
|
-
[key: string]: any;
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export interface FmtOption extends Record<string, any> {
|
|
69
|
-
groups_start: string;
|
|
70
|
-
groups_max_depth: number;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
type Facet = RangeFacet | OptionFacet;
|
|
74
|
-
|
|
75
|
-
export interface BaseFacet extends Record<string, any> {
|
|
76
|
-
data: Record<string, any>;
|
|
77
|
-
status: Record<string, any>;
|
|
78
|
-
display_name: string;
|
|
79
|
-
name: string;
|
|
80
|
-
hidden: boolean;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export interface RangeFacet extends BaseFacet, Record<string, any> {
|
|
84
|
-
max: number;
|
|
85
|
-
min: number;
|
|
86
|
-
type: "range";
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export interface OptionFacet extends BaseFacet, Record<string, any> {
|
|
90
|
-
options: FacetOption[];
|
|
91
|
-
type: "multiple" | "single" | "hierarchical";
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export interface FacetOption extends Record<string, any> {
|
|
95
|
-
count: number;
|
|
96
|
-
display_name: string;
|
|
97
|
-
value: string;
|
|
98
|
-
options?: FacetOption[];
|
|
99
|
-
range?: ["-inf" | number, "inf" | number];
|
|
100
|
-
status: string;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export interface Group extends BaseGroup, Record<string, any> {
|
|
104
|
-
count: number;
|
|
105
|
-
data: Record<string, any>;
|
|
106
|
-
parents: BaseGroup[];
|
|
107
|
-
children: Group[];
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export interface Collection extends Record<string, any> {
|
|
111
|
-
collection_id: string,
|
|
112
|
-
display_name: string,
|
|
113
|
-
data: Record<string, any>
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export interface BaseGroup extends Record<string, any> {
|
|
117
|
-
display_name: string;
|
|
118
|
-
group_id: string;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export interface FmtOptions extends Record<string, any> {
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export type Nullable<T> = T | null;
|
|
126
|
-
|