@constructor-io/constructorio-client-javascript 2.34.6 → 2.34.8

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.
@@ -17,6 +17,7 @@ var helpers = require('../utils/helpers'); // Create URL from supplied query (te
17
17
 
18
18
 
19
19
  function createSearchUrl(query, parameters, options) {
20
+ var isVoiceSearch = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
20
21
  var apiKey = options.apiKey,
21
22
  version = options.version,
22
23
  serviceUrl = options.serviceUrl,
@@ -148,7 +149,8 @@ function createSearchUrl(query, parameters, options) {
148
149
  queryParams._dt = Date.now();
149
150
  queryParams = helpers.cleanParams(queryParams);
150
151
  var queryString = helpers.stringify(queryParams);
151
- return "".concat(serviceUrl, "/search/").concat(helpers.encodeURIComponentRFC3986(helpers.trimNonBreakingSpaces(query)), "?").concat(queryString);
152
+ var searchUrl = isVoiceSearch ? 'search/natural_language' : 'search';
153
+ return "".concat(serviceUrl, "/").concat(searchUrl, "/").concat(helpers.encodeURIComponentRFC3986(helpers.trimNonBreakingSpaces(query)), "?").concat(queryString);
152
154
  }
153
155
  /**
154
156
  * Interface to search related API calls
@@ -256,6 +258,89 @@ var Search = /*#__PURE__*/function () {
256
258
  throw new Error('getSearchResults response data is malformed');
257
259
  });
258
260
  }
261
+ /**
262
+ * Retrieve voice search results from API
263
+ *
264
+ * @function getVoiceSearchResults
265
+ * @description Retrieve voice search results from Constructor.io API
266
+ * @param {string} query - Term to use to perform a voice search
267
+ * @param {object} [parameters] - Additional parameters to refine result set
268
+ * @param {number} [parameters.page] - The page number of the results (Can't be used together with offset)
269
+ * @param {number} [parameters.offset] - The number of results to skip from the beginning (Can't be used together with page)
270
+ * @param {number} [parameters.resultsPerPage] - The number of results per page to return
271
+ * @param {string} [parameters.section='Products'] - The section name for results
272
+ * @param {object} [parameters.fmtOptions] - The format options used to refine result groups. Please refer to https://docs.constructor.io/rest_api/search/queries for details
273
+ * @param {object} [parameters.preFilterExpression] - Faceting expression to scope search results. Please refer to https://docs.constructor.io/rest_api/collections#add-items-dynamically
274
+ * @param {object} [parameters.variationsMap] - The variations map object to aggregate variations. Please refer to https://docs.constructor.io/rest_api/variations_mapping for details
275
+ * @param {string[]} [parameters.hiddenFields] - Hidden metadata fields to return
276
+ * @param {string[]} [parameters.hiddenFacets] - Hidden facets to return
277
+ * @param {object} [parameters.qs] - Parameters listed above can be serialized into a JSON object and parsed through this parameter. Please refer to https://docs.constructor.io/rest_api/search/queries/
278
+ * @param {object} [networkParameters] - Parameters relevant to the network request
279
+ * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
280
+ * @returns {Promise}
281
+ * @see https://docs.constructor.io/rest_api/search/natural_language_search/
282
+ * @example
283
+ * constructorio.search.getVoiceSearchResults('show me lipstick');
284
+ */
285
+
286
+ }, {
287
+ key: "getVoiceSearchResults",
288
+ value: function getVoiceSearchResults(query, parameters) {
289
+ var _this2 = this;
290
+
291
+ var networkParameters = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
292
+ var requestUrl;
293
+ var fetch = this.options.fetch;
294
+ var signal;
295
+
296
+ if (typeof AbortController === 'function') {
297
+ var controller = new AbortController();
298
+ signal = controller && controller.signal; // Handle network timeout if specified
299
+
300
+ helpers.applyNetworkTimeout(this.options, networkParameters, controller);
301
+ }
302
+
303
+ try {
304
+ var isVoiceSearch = true;
305
+ requestUrl = createSearchUrl(query, parameters, this.options, isVoiceSearch);
306
+ } catch (e) {
307
+ return Promise.reject(e);
308
+ }
309
+
310
+ return fetch(requestUrl, {
311
+ signal: signal
312
+ }).then(function (response) {
313
+ if (response.ok) {
314
+ return response.json();
315
+ }
316
+
317
+ return helpers.throwHttpErrorFromResponse(new Error(), response);
318
+ }).then(function (json) {
319
+ // Search results
320
+ if (json.response && json.response.results) {
321
+ if (json.result_id) {
322
+ // Append `result_id` to each result item
323
+ json.response.results.forEach(function (result) {
324
+ // eslint-disable-next-line no-param-reassign
325
+ result.result_id = json.result_id;
326
+ });
327
+ }
328
+
329
+ _this2.eventDispatcher.queue('search.getVoiceSearchResults.completed', json);
330
+
331
+ return json;
332
+ } // Redirect rules
333
+
334
+
335
+ if (json.response && json.response.redirect) {
336
+ _this2.eventDispatcher.queue('search.getVoiceSearchResults.completed', json);
337
+
338
+ return json;
339
+ }
340
+
341
+ throw new Error('getVoiceSearchResults response data is malformed');
342
+ });
343
+ }
259
344
  }]);
260
345
  return Search;
261
346
  }();
@@ -1235,6 +1235,433 @@ var Tracker = /*#__PURE__*/function () {
1235
1235
  this.requests.send();
1236
1236
  return new Error('A parameters object with an "item_id" property is required.');
1237
1237
  }
1238
+ /**
1239
+ * Send quiz results loaded event to API
1240
+ *
1241
+ * @function trackQuizResultsLoaded
1242
+ * @param {object} parameters - Additional parameters to be sent with request
1243
+ * @param {string} parameters.quiz_id - Quiz identifier
1244
+ * @param {string} parameters.quiz_version_id - Quiz version identifier
1245
+ * @param {string} parameters.quiz_session_id - Quiz session identifier associated with this conversion event
1246
+ * @param {string} parameters.url - Current page url
1247
+ * @param {string} [parameters.section='Products'] - Index section
1248
+ * @param {number} [parameters.result_count] - Total number of results
1249
+ * @param {number} [parameters.result_page] - The page of the results
1250
+ * @param {string} [parameters.result_id] - Quiz result identifier (returned in response from Constructor)
1251
+ * @param {object} [networkParameters] - Parameters relevant to the network request
1252
+ * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
1253
+ * @returns {(true|Error)}
1254
+ * @description User viewed a quiz results page
1255
+ * @example
1256
+ * constructorio.tracker.trackQuizResultsLoaded(
1257
+ * {
1258
+ * quiz_id: 'coffee-quiz',
1259
+ * quiz_version_id: '1231244',
1260
+ * quiz_session_id: '3123',
1261
+ * url: 'www.example.com',
1262
+ * result_count: 167,
1263
+ * },
1264
+ * );
1265
+ */
1266
+
1267
+ }, {
1268
+ key: "trackQuizResultsLoaded",
1269
+ value: function trackQuizResultsLoaded(parameters) {
1270
+ var networkParameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1271
+
1272
+ // Ensure parameters are provided (required)
1273
+ if (parameters && (0, _typeof2["default"])(parameters) === 'object' && !Array.isArray(parameters)) {
1274
+ var requestPath = "".concat(this.options.serviceUrl, "/v2/behavioral_action/quiz_result_load?");
1275
+ var quiz_id = parameters.quiz_id,
1276
+ quiz_version_id = parameters.quiz_version_id,
1277
+ quiz_session_id = parameters.quiz_session_id,
1278
+ url = parameters.url,
1279
+ _parameters$section2 = parameters.section,
1280
+ section = _parameters$section2 === void 0 ? 'Products' : _parameters$section2,
1281
+ result_count = parameters.result_count,
1282
+ result_id = parameters.result_id,
1283
+ result_page = parameters.result_page;
1284
+ var queryParams = {};
1285
+ var bodyParams = {};
1286
+
1287
+ if (typeof quiz_id !== 'string') {
1288
+ return new Error('"quiz_id" is a required parameter of type string');
1289
+ }
1290
+
1291
+ if (typeof quiz_version_id !== 'string') {
1292
+ return new Error('"quiz_version_id" is a required parameter of type string');
1293
+ }
1294
+
1295
+ if (typeof quiz_session_id !== 'string') {
1296
+ return new Error('"quiz_session_id" is a required parameter of type string');
1297
+ }
1298
+
1299
+ if (typeof url !== 'string') {
1300
+ return new Error('"url" is a required parameter of type string');
1301
+ }
1302
+
1303
+ bodyParams.quiz_id = quiz_id;
1304
+ bodyParams.quiz_version_id = quiz_version_id;
1305
+ bodyParams.quiz_session_id = quiz_session_id;
1306
+ bodyParams.url = url;
1307
+
1308
+ if (!helpers.isNil(section)) {
1309
+ if (typeof section !== 'string') {
1310
+ return new Error('"section" must be a string');
1311
+ }
1312
+
1313
+ queryParams.section = section;
1314
+ bodyParams.section = section;
1315
+ }
1316
+
1317
+ if (!helpers.isNil(result_count)) {
1318
+ if (typeof result_count !== 'number') {
1319
+ return new Error('"result_count" must be a number');
1320
+ }
1321
+
1322
+ bodyParams.result_count = result_count;
1323
+ }
1324
+
1325
+ if (!helpers.isNil(result_id)) {
1326
+ if (typeof result_id !== 'string') {
1327
+ return new Error('"result_id" must be a string');
1328
+ }
1329
+
1330
+ bodyParams.result_id = result_id;
1331
+ }
1332
+
1333
+ if (!helpers.isNil(result_page)) {
1334
+ if (typeof result_page !== 'number') {
1335
+ return new Error('"result_page" must be a number');
1336
+ }
1337
+
1338
+ bodyParams.result_page = result_page;
1339
+ }
1340
+
1341
+ bodyParams.action_class = 'result_load';
1342
+ var requestURL = "".concat(requestPath).concat(applyParamsAsString(queryParams, this.options));
1343
+ var requestMethod = 'POST';
1344
+ var requestBody = applyParams(bodyParams, _objectSpread(_objectSpread({}, this.options), {}, {
1345
+ requestMethod: requestMethod
1346
+ }));
1347
+ this.requests.queue(requestURL, requestMethod, requestBody, networkParameters);
1348
+ this.requests.send();
1349
+ return true;
1350
+ }
1351
+
1352
+ this.requests.send();
1353
+ return new Error('parameters are required of type object');
1354
+ }
1355
+ /**
1356
+ * Send quiz result click event to API
1357
+ *
1358
+ * @function trackQuizResultClick
1359
+ * @param {object} parameters - Additional parameters to be sent with request
1360
+ * @param {string} parameters.quiz_id - Quiz identifier
1361
+ * @param {string} parameters.quiz_version_id - Quiz version identifier
1362
+ * @param {string} parameters.quiz_session_id - Quiz session identifier associated with this conversion event
1363
+ * @param {string} [parameters.item_id] - Product item unique identifier (Either item_id or item_name is required)
1364
+ * @param {string} [parameters.item_name] - Product item name
1365
+ * @param {string} [parameters.section='Products'] - Index section
1366
+ * @param {number} [parameters.result_count] - Total number of results
1367
+ * @param {number} [parameters.result_page] - The page of the results
1368
+ * @param {string} [parameters.result_id] - Quiz result identifier (returned in response from Constructor)
1369
+ * @param {number} [parameters.result_position_on_page] - Position of clicked item
1370
+ * @param {number} [parameters.num_results_per_page] - Number of results shown
1371
+ * @param {object} [networkParameters] - Parameters relevant to the network request
1372
+ * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
1373
+ * @returns {(true|Error)}
1374
+ * @description User viewed a quiz results page
1375
+ * @example
1376
+ * constructorio.tracker.trackQuizResultClick(
1377
+ * {
1378
+ * quiz_id: 'coffee-quiz',
1379
+ * quiz_version_id: '1231244',
1380
+ * quiz_session_id: '123',
1381
+ * item_id: '123',
1382
+ * item_name: 'espresso'
1383
+ * },
1384
+ * );
1385
+ */
1386
+ // eslint-disable-next-line complexity
1387
+
1388
+ }, {
1389
+ key: "trackQuizResultClick",
1390
+ value: function trackQuizResultClick(parameters) {
1391
+ var networkParameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1392
+
1393
+ // Ensure parameters are provided (required)
1394
+ if (parameters && (0, _typeof2["default"])(parameters) === 'object' && !Array.isArray(parameters)) {
1395
+ var requestPath = "".concat(this.options.serviceUrl, "/v2/behavioral_action/quiz_result_click?");
1396
+ var quiz_id = parameters.quiz_id,
1397
+ quiz_version_id = parameters.quiz_version_id,
1398
+ quiz_session_id = parameters.quiz_session_id,
1399
+ item_id = parameters.item_id,
1400
+ item_name = parameters.item_name,
1401
+ result_count = parameters.result_count,
1402
+ result_id = parameters.result_id,
1403
+ result_page = parameters.result_page,
1404
+ num_results_per_page = parameters.num_results_per_page,
1405
+ result_position_on_page = parameters.result_position_on_page,
1406
+ _parameters$section3 = parameters.section,
1407
+ section = _parameters$section3 === void 0 ? 'Products' : _parameters$section3;
1408
+ var queryParams = {};
1409
+ var bodyParams = {}; // Ensure required parameters provided
1410
+
1411
+ if (typeof quiz_id !== 'string') {
1412
+ return new Error('"quiz_id" is a required parameter of type string');
1413
+ }
1414
+
1415
+ if (typeof quiz_version_id !== 'string') {
1416
+ return new Error('"quiz_version_id" is a required parameter of type string');
1417
+ }
1418
+
1419
+ if (typeof quiz_session_id !== 'string') {
1420
+ return new Error('"quiz_session_id" is a required parameter of type string');
1421
+ }
1422
+
1423
+ if (typeof item_id !== 'string' && typeof item_name !== 'string') {
1424
+ return new Error('"item_id" or "item_name" is a required parameter of type string');
1425
+ }
1426
+
1427
+ bodyParams.quiz_id = quiz_id;
1428
+ bodyParams.quiz_version_id = quiz_version_id;
1429
+ bodyParams.quiz_session_id = quiz_session_id;
1430
+
1431
+ if (!helpers.isNil(item_id)) {
1432
+ if (typeof item_id !== 'string') {
1433
+ return new Error('"item_id" must be a string');
1434
+ }
1435
+
1436
+ bodyParams.item_id = item_id;
1437
+ }
1438
+
1439
+ if (!helpers.isNil(item_name)) {
1440
+ if (typeof item_name !== 'string') {
1441
+ return new Error('"item_name" must be a string');
1442
+ }
1443
+
1444
+ bodyParams.item_name = item_name;
1445
+ }
1446
+
1447
+ if (!helpers.isNil(section)) {
1448
+ if (typeof section !== 'string') {
1449
+ return new Error('"section" must be a string');
1450
+ }
1451
+
1452
+ queryParams.section = section;
1453
+ }
1454
+
1455
+ if (!helpers.isNil(result_count)) {
1456
+ if (typeof result_count !== 'number') {
1457
+ return new Error('"result_count" must be a number');
1458
+ }
1459
+
1460
+ bodyParams.result_count = result_count;
1461
+ }
1462
+
1463
+ if (!helpers.isNil(result_id)) {
1464
+ if (typeof result_id !== 'string') {
1465
+ return new Error('"result_id" must be a string');
1466
+ }
1467
+
1468
+ bodyParams.result_id = result_id;
1469
+ }
1470
+
1471
+ if (!helpers.isNil(result_page)) {
1472
+ if (typeof result_page !== 'number') {
1473
+ return new Error('"result_page" must be a number');
1474
+ }
1475
+
1476
+ bodyParams.result_page = result_page;
1477
+ }
1478
+
1479
+ if (!helpers.isNil(num_results_per_page)) {
1480
+ if (typeof num_results_per_page !== 'number') {
1481
+ return new Error('"num_results_per_page" must be a number');
1482
+ }
1483
+
1484
+ bodyParams.num_results_per_page = num_results_per_page;
1485
+ }
1486
+
1487
+ if (!helpers.isNil(result_position_on_page)) {
1488
+ if (typeof result_position_on_page !== 'number') {
1489
+ return new Error('"result_position_on_page" must be a number');
1490
+ }
1491
+
1492
+ bodyParams.result_position_on_page = result_position_on_page;
1493
+ }
1494
+
1495
+ bodyParams.action_class = 'result_click';
1496
+ var requestURL = "".concat(requestPath).concat(applyParamsAsString(queryParams, this.options));
1497
+ var requestMethod = 'POST';
1498
+ var requestBody = applyParams(bodyParams, _objectSpread(_objectSpread({}, this.options), {}, {
1499
+ requestMethod: requestMethod
1500
+ }));
1501
+ this.requests.queue(requestURL, requestMethod, requestBody, networkParameters);
1502
+ this.requests.send();
1503
+ return true;
1504
+ }
1505
+
1506
+ this.requests.send();
1507
+ return new Error('parameters are required of type object');
1508
+ }
1509
+ /**
1510
+ * Send quiz conversion event to API
1511
+ *
1512
+ * @function trackQuizConversion
1513
+ * @param {object} parameters - Additional parameters to be sent with request
1514
+ * @param {string} parameters.quiz_id - Quiz identifier
1515
+ * @param {string} parameters.quiz_version_id - Quiz version identifier
1516
+ * @param {string} parameters.quiz_session_id - Quiz session identifier associated with this conversion event
1517
+ * @param {string} [parameters.item_id] - Product item unique identifier (Either item_id or item_name is required)
1518
+ * @param {string} [parameters.item_name] - Product item name
1519
+ * @param {string} [parameters.variation_id] - Product item variation unique identifier
1520
+ * @param {string} [parameters.revenue] - Sale price if available, otherwise the regular (retail) price of item
1521
+ * @param {string} [parameters.section='Products'] - Index section
1522
+ * @param {string} [parameters.type='add_to_cart'] - Conversion type
1523
+ * @param {boolean} [parameters.is_custom_type] - Specify if type is custom conversion type
1524
+ * @param {string} [parameters.display_name] - Display name for the custom conversion type
1525
+ * @param {object} [networkParameters] - Parameters relevant to the network request
1526
+ * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
1527
+ * @returns {(true|Error)}
1528
+ * @description User viewed a quiz results page
1529
+ * @example
1530
+ * constructorio.tracker.trackQuizConversion(
1531
+ * {
1532
+ * quiz_id: 'coffee-quiz',
1533
+ * quiz_version_id: '1231244',
1534
+ * quiz_session_id: '3123',
1535
+ * item_name: 'espresso',
1536
+ * variation_id: '167',
1537
+ * type: 'add_to_cart",
1538
+ * revenue: '1.0"
1539
+ * },
1540
+ * );
1541
+ */
1542
+ // eslint-disable-next-line complexity
1543
+
1544
+ }, {
1545
+ key: "trackQuizConversion",
1546
+ value: function trackQuizConversion(parameters) {
1547
+ var networkParameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1548
+
1549
+ // Ensure parameters are provided (required)
1550
+ if (parameters && (0, _typeof2["default"])(parameters) === 'object' && !Array.isArray(parameters)) {
1551
+ var requestPath = "".concat(this.options.serviceUrl, "/v2/behavioral_action/quiz_conversion?");
1552
+ var quiz_id = parameters.quiz_id,
1553
+ quiz_version_id = parameters.quiz_version_id,
1554
+ quiz_session_id = parameters.quiz_session_id,
1555
+ item_id = parameters.item_id,
1556
+ item_name = parameters.item_name,
1557
+ variation_id = parameters.variation_id,
1558
+ revenue = parameters.revenue,
1559
+ _parameters$section4 = parameters.section,
1560
+ section = _parameters$section4 === void 0 ? 'Products' : _parameters$section4,
1561
+ type = parameters.type,
1562
+ is_custom_type = parameters.is_custom_type,
1563
+ display_name = parameters.display_name;
1564
+ var queryParams = {};
1565
+ var bodyParams = {}; // Ensure required parameters provided
1566
+
1567
+ if (typeof quiz_id !== 'string') {
1568
+ return new Error('"quiz_id" is a required parameter of type string');
1569
+ }
1570
+
1571
+ if (typeof quiz_version_id !== 'string') {
1572
+ return new Error('"quiz_version_id" is a required parameter of type string');
1573
+ }
1574
+
1575
+ if (typeof quiz_session_id !== 'string') {
1576
+ return new Error('"quiz_session_id" is a required parameter of type string');
1577
+ }
1578
+
1579
+ if (typeof item_id !== 'string' && typeof item_name !== 'string') {
1580
+ return new Error('"item_id" or "item_name" is a required parameter of type string');
1581
+ }
1582
+
1583
+ bodyParams.quiz_id = quiz_id;
1584
+ bodyParams.quiz_version_id = quiz_version_id;
1585
+ bodyParams.quiz_session_id = quiz_session_id;
1586
+
1587
+ if (!helpers.isNil(item_id)) {
1588
+ if (typeof item_id !== 'string') {
1589
+ return new Error('"item_id" must be a string');
1590
+ }
1591
+
1592
+ bodyParams.item_id = item_id;
1593
+ }
1594
+
1595
+ if (!helpers.isNil(item_name)) {
1596
+ if (typeof item_name !== 'string') {
1597
+ return new Error('"item_name" must be a string');
1598
+ }
1599
+
1600
+ bodyParams.item_name = item_name;
1601
+ }
1602
+
1603
+ if (!helpers.isNil(variation_id)) {
1604
+ if (typeof variation_id !== 'string') {
1605
+ return new Error('"variation_id" must be a string');
1606
+ }
1607
+
1608
+ bodyParams.variation_id = variation_id;
1609
+ }
1610
+
1611
+ if (!helpers.isNil(revenue)) {
1612
+ if (typeof revenue !== 'string') {
1613
+ return new Error('"revenue" must be a string');
1614
+ }
1615
+
1616
+ bodyParams.revenue = revenue;
1617
+ }
1618
+
1619
+ if (!helpers.isNil(section)) {
1620
+ if (typeof section !== 'string') {
1621
+ return new Error('"section" must be a string');
1622
+ }
1623
+
1624
+ bodyParams.section = section;
1625
+ }
1626
+
1627
+ if (!helpers.isNil(type)) {
1628
+ if (typeof type !== 'string') {
1629
+ return new Error('"type" must be a string');
1630
+ }
1631
+
1632
+ bodyParams.type = type;
1633
+ }
1634
+
1635
+ if (!helpers.isNil(is_custom_type)) {
1636
+ if (typeof is_custom_type !== 'boolean') {
1637
+ return new Error('"is_custom_type" must be a boolean');
1638
+ }
1639
+
1640
+ bodyParams.is_custom_type = is_custom_type;
1641
+ }
1642
+
1643
+ if (!helpers.isNil(display_name)) {
1644
+ if (typeof display_name !== 'string') {
1645
+ return new Error('"display_name" must be a string');
1646
+ }
1647
+
1648
+ bodyParams.display_name = display_name;
1649
+ }
1650
+
1651
+ bodyParams.action_class = 'conversion';
1652
+ var requestURL = "".concat(requestPath).concat(applyParamsAsString(queryParams, this.options));
1653
+ var requestMethod = 'POST';
1654
+ var requestBody = applyParams(bodyParams, _objectSpread(_objectSpread({}, this.options), {}, {
1655
+ requestMethod: requestMethod
1656
+ }));
1657
+ this.requests.queue(requestURL, requestMethod, requestBody, networkParameters);
1658
+ this.requests.send();
1659
+ return true;
1660
+ }
1661
+
1662
+ this.requests.send();
1663
+ return new Error('parameters are required of type object');
1664
+ }
1238
1665
  /**
1239
1666
  * Subscribe to success or error messages emitted by tracking requests
1240
1667
  *
@@ -41,6 +41,12 @@ declare class Search {
41
41
  parameters?: SearchParameters,
42
42
  networkParameters?: NetworkParameters
43
43
  ): Promise<SearchResponse>;
44
+
45
+ getVoiceSearchResults(
46
+ query: string,
47
+ parameters?: Omit<SearchParameters, 'filters' | 'sortBy' | 'sortOrder'>,
48
+ networkParameters?: NetworkParameters
49
+ ): Promise<SearchResponse>;
44
50
  }
45
51
 
46
52
  /** *********
@@ -75,6 +81,7 @@ export interface SearchRequestType extends Record<string, any> {
75
81
  features: Partial<RequestFeature>;
76
82
  feature_variants: Partial<RequestFeatureVariant>;
77
83
  searchandized_items: Record<string, any>;
84
+ original_query?: string;
78
85
  }
79
86
 
80
87
  export interface Result extends Record<string, any> {
@@ -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
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@constructor-io/constructorio-client-javascript",
3
- "version": "2.34.6",
3
+ "version": "2.34.8",
4
4
  "description": "Constructor.io JavaScript client",
5
5
  "main": "lib/constructorio.js",
6
6
  "types": "lib/types/constructorio.d.ts",
7
7
  "scripts": {
8
8
  "clean": "sudo rm -rf node_modules package-lock.json",
9
- "verify-node-version": "chmod +x ./scripts/verify-node-version.sh && ./scripts/verify-node-version.sh",
10
9
  "version": "npm run verify-node-version && npm run docs && git add ./docs/* && npm run bundle && git add -A ./dist",
11
- "check-lisc": "license-checker --production --onlyAllow 'Apache-2.0;BSD-3-Clause;MIT'",
10
+ "check-license": "license-checker --production --onlyAllow 'Apache-2.0;BSD-3-Clause;MIT;0BSD;BSD-2-Clause'",
11
+ "verify-node-version": "chmod +x ./scripts/verify-node-version.sh && ./scripts/verify-node-version.sh",
12
12
  "lint": "eslint 'src/**/*.js' 'spec/**/*.js' 'src/**/*.d.ts'",
13
13
  "test": "npm run compile && mkdir -p test && cp -rf lib/* test && mocha ./spec/*",
14
14
  "test:types": "tsd .",