coveo.analytics 2.23.8 → 2.23.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.
@@ -487,7 +487,10 @@
487
487
  return rnds;
488
488
  };
489
489
 
490
- var keysOf = Object.keys;
490
+ var keysOf = Object.keys;
491
+ function isObject(o) {
492
+ return o !== null && typeof o === 'object' && !Array.isArray(o);
493
+ }
491
494
 
492
495
  var ticketKeysMapping = {
493
496
  id: 'svc_ticket_id',
@@ -1292,7 +1295,9 @@
1292
1295
  return usesMeasurementProtocol ? _this.removeUnknownParameters(currentPayload) : currentPayload;
1293
1296
  };
1294
1297
  processCustomParameters = function (currentPayload) {
1295
- return usesMeasurementProtocol ? _this.processCustomParameters(currentPayload) : currentPayload;
1298
+ return usesMeasurementProtocol
1299
+ ? _this.processCustomParameters(currentPayload)
1300
+ : _this.mapCustomParametersToCustomData(currentPayload);
1296
1301
  };
1297
1302
  return [4, [
1298
1303
  cleanPayloadStep,
@@ -1562,16 +1567,30 @@
1562
1567
  };
1563
1568
  CoveoAnalyticsClient.prototype.processCustomParameters = function (payload) {
1564
1569
  var custom = payload.custom, rest = __rest(payload, ["custom"]);
1565
- var lowercasedCustom = this.lowercaseKeys(custom);
1570
+ var lowercasedCustom = {};
1571
+ if (custom && isObject(custom)) {
1572
+ lowercasedCustom = this.lowercaseKeys(custom);
1573
+ }
1566
1574
  var newPayload = convertCustomMeasurementProtocolKeys(rest);
1567
1575
  return __assign(__assign({}, lowercasedCustom), newPayload);
1568
1576
  };
1577
+ CoveoAnalyticsClient.prototype.mapCustomParametersToCustomData = function (payload) {
1578
+ var custom = payload.custom, rest = __rest(payload, ["custom"]);
1579
+ if (custom && isObject(custom)) {
1580
+ var lowercasedCustom = this.lowercaseKeys(custom);
1581
+ return __assign(__assign({}, rest), { customData: __assign(__assign({}, lowercasedCustom), payload.customData) });
1582
+ }
1583
+ else {
1584
+ return payload;
1585
+ }
1586
+ };
1569
1587
  CoveoAnalyticsClient.prototype.lowercaseKeys = function (custom) {
1570
- var keys = Object.keys(custom || {});
1571
- return keys.reduce(function (all, key) {
1572
- var _a;
1573
- return (__assign(__assign({}, all), (_a = {}, _a[key.toLowerCase()] = custom[key], _a)));
1574
- }, {});
1588
+ var keys = Object.keys(custom);
1589
+ var result = {};
1590
+ keys.forEach(function (key) {
1591
+ result[key.toLowerCase()] = custom[key];
1592
+ });
1593
+ return result;
1575
1594
  };
1576
1595
  CoveoAnalyticsClient.prototype.validateParams = function (payload) {
1577
1596
  var anonymizeIp = payload.anonymizeIp, rest = __rest(payload, ["anonymizeIp"]);
@@ -1934,7 +1953,7 @@
1934
1953
  }
1935
1954
  var actionFunction = plugin[fn];
1936
1955
  if (!actionFunction) {
1937
- throw new Error("The function \"" + fn + "\" does not exists on the plugin \"" + name + "\".");
1956
+ throw new Error("The function \"" + fn + "\" does not exist on the plugin \"" + name + "\".");
1938
1957
  }
1939
1958
  if (typeof actionFunction !== 'function') {
1940
1959
  throw new Error("\"" + fn + "\" of the plugin \"" + name + "\" is not a function.");