coveo.analytics 2.23.8 → 2.23.10

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.");
@@ -2105,6 +2124,11 @@
2105
2124
  (function (InsightEvents) {
2106
2125
  InsightEvents["contextChanged"] = "contextChanged";
2107
2126
  InsightEvents["expandToFullUI"] = "expandToFullUI";
2127
+ InsightEvents["openUserActions"] = "openUserActions";
2128
+ InsightEvents["showPrecedingSessions"] = "showPrecedingSessions";
2129
+ InsightEvents["showFollowingSessions"] = "showFollowingSessions";
2130
+ InsightEvents["clickViewedDocument"] = "clickViewedDocument";
2131
+ InsightEvents["clickPageView"] = "clickPageView";
2108
2132
  })(InsightEvents || (InsightEvents = {}));
2109
2133
 
2110
2134
  var _a;
@@ -2215,6 +2239,11 @@
2215
2239
  _a[SearchPageEvents.clearRecentResults] = 'recentlyClickedDocuments',
2216
2240
  _a[SearchPageEvents.showLessFoldedResults] = 'folding',
2217
2241
  _a[InsightEvents.expandToFullUI] = 'interface',
2242
+ _a[InsightEvents.openUserActions] = 'User Actions',
2243
+ _a[InsightEvents.showPrecedingSessions] = 'User Actions',
2244
+ _a[InsightEvents.showFollowingSessions] = 'User Actions',
2245
+ _a[InsightEvents.clickViewedDocument] = 'User Actions',
2246
+ _a[InsightEvents.clickPageView] = 'User Actions',
2218
2247
  _a[SearchPageEvents.caseDetach] = 'case',
2219
2248
  _a);
2220
2249
 
@@ -3753,6 +3782,24 @@
3753
3782
  var metadataToSend = generateMetadataToSend(metadata);
3754
3783
  return this.logCustomEvent(InsightEvents.expandToFullUI, metadataToSend);
3755
3784
  };
3785
+ CoveoInsightClient.prototype.logOpenUserActions = function (metadata) {
3786
+ var metadataToSend = generateMetadataToSend(metadata, false);
3787
+ return this.logCustomEvent(InsightEvents.openUserActions, metadataToSend);
3788
+ };
3789
+ CoveoInsightClient.prototype.logShowPrecedingSessions = function (metadata) {
3790
+ var metadataToSend = generateMetadataToSend(metadata, false);
3791
+ return this.logCustomEvent(InsightEvents.showPrecedingSessions, metadataToSend);
3792
+ };
3793
+ CoveoInsightClient.prototype.logShowFollowingSessions = function (metadata) {
3794
+ var metadataToSend = generateMetadataToSend(metadata, false);
3795
+ return this.logCustomEvent(InsightEvents.showFollowingSessions, metadataToSend);
3796
+ };
3797
+ CoveoInsightClient.prototype.logViewedDocumentClick = function (document, metadata) {
3798
+ return this.logCustomEvent(InsightEvents.clickViewedDocument, __assign(__assign({}, generateMetadataToSend(metadata, false)), { document: document }));
3799
+ };
3800
+ CoveoInsightClient.prototype.logPageViewClick = function (pageView, metadata) {
3801
+ return this.logCustomEvent(InsightEvents.clickPageView, __assign(__assign({}, generateMetadataToSend(metadata, false)), { pageView: pageView }));
3802
+ };
3756
3803
  CoveoInsightClient.prototype.logDocumentOpen = function (info, identifier, metadata) {
3757
3804
  return this.logClickEvent(SearchPageEvents.documentOpen, info, identifier, metadata ? generateMetadataToSend(metadata, false) : undefined);
3758
3805
  };