coveo.analytics 2.28.25 → 2.29.2

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/dist/browser.mjs CHANGED
@@ -596,7 +596,7 @@ function sha1(bytes) {
596
596
  const v5 = v35('v5', 0x50, sha1);
597
597
  var uuidv5 = v5;
598
598
 
599
- const libVersion = "2.28.25" ;
599
+ const libVersion = "2.29.2" ;
600
600
 
601
601
  const getFormattedLocation = (location) => `${location.protocol}//${location.hostname}${location.pathname.indexOf('/') === 0 ? location.pathname : `/${location.pathname}`}${location.search}`;
602
602
 
@@ -1052,8 +1052,8 @@ class AnalyticsBeaconClient {
1052
1052
  }
1053
1053
  encodeForEventType(eventType, payload) {
1054
1054
  return this.isEventTypeLegacy(eventType)
1055
- ? this.encodeForLegacyType(eventType, payload)
1056
- : this.encodeForFormUrlEncoded(Object.assign({ access_token: this.opts.token }, payload));
1055
+ ? this.encodeEventToJson(eventType, payload)
1056
+ : this.encodeEventToJson(eventType, payload, this.opts.token);
1057
1057
  }
1058
1058
  getQueryParamsForEventType(eventType) {
1059
1059
  return __awaiter(this, void 0, void 0, function* () {
@@ -1071,19 +1071,12 @@ class AnalyticsBeaconClient {
1071
1071
  isEventTypeLegacy(eventType) {
1072
1072
  return [EventType.click, EventType.custom, EventType.search, EventType.view].indexOf(eventType) !== -1;
1073
1073
  }
1074
- encodeForLegacyType(eventType, payload) {
1075
- return `${eventType}Event=${encodeURIComponent(JSON.stringify(payload))}`;
1076
- }
1077
- encodeForFormUrlEncoded(payload) {
1078
- return Object.keys(payload)
1079
- .filter((key) => !!payload[key])
1080
- .map((key) => `${encodeURIComponent(key)}=${encodeURIComponent(this.encodeValue(payload[key]))}`)
1081
- .join('&');
1082
- }
1083
- encodeValue(value) {
1084
- return typeof value === 'number' || typeof value === 'string' || typeof value === 'boolean'
1085
- ? value
1086
- : JSON.stringify(value);
1074
+ encodeEventToJson(eventType, payload, access_token) {
1075
+ let encoded = `${eventType}Event=${encodeURIComponent(JSON.stringify(payload))}`;
1076
+ if (access_token) {
1077
+ encoded = `access_token=${encodeURIComponent(access_token)}&${encoded}`;
1078
+ }
1079
+ return encoded;
1087
1080
  }
1088
1081
  }
1089
1082
 
@@ -1276,7 +1269,6 @@ class CoveoAnalyticsClient {
1276
1269
  };
1277
1270
  this.runtime = this.options.runtimeEnvironment || this.initRuntime(clientsOptions);
1278
1271
  if (doNotTrack()) {
1279
- this.clear();
1280
1272
  this.runtime.storage = new NullStorage();
1281
1273
  }
1282
1274
  this.addEventTypeMapping(EventType.view, { newEventType: EventType.view, addClientIdParameter: true });
@@ -1933,9 +1925,6 @@ class CoveoSearchPageClient {
1933
1925
  this.coveoAnalyticsClient = shouldDisableAnalytics ? new NoopAnalytics() : new CoveoAnalyticsClient(opts);
1934
1926
  }
1935
1927
  disable() {
1936
- if (this.coveoAnalyticsClient instanceof CoveoAnalyticsClient) {
1937
- this.coveoAnalyticsClient.clear();
1938
- }
1939
1928
  this.coveoAnalyticsClient = new NoopAnalytics();
1940
1929
  }
1941
1930
  enable() {
@@ -2838,9 +2827,6 @@ class CaseAssistClient {
2838
2827
  this.svc = new SVCPlugin({ client: this.coveoAnalyticsClient });
2839
2828
  }
2840
2829
  disable() {
2841
- if (this.coveoAnalyticsClient instanceof CoveoAnalyticsClient) {
2842
- this.coveoAnalyticsClient.clear();
2843
- }
2844
2830
  this.coveoAnalyticsClient = new NoopAnalytics();
2845
2831
  this.svc = new SVCPlugin({ client: this.coveoAnalyticsClient });
2846
2832
  }
@@ -2944,9 +2930,6 @@ class CoveoInsightClient {
2944
2930
  this.coveoAnalyticsClient = shouldDisableAnalytics ? new NoopAnalytics() : new CoveoAnalyticsClient(opts);
2945
2931
  }
2946
2932
  disable() {
2947
- if (this.coveoAnalyticsClient instanceof CoveoAnalyticsClient) {
2948
- this.coveoAnalyticsClient.clear();
2949
- }
2950
2933
  this.coveoAnalyticsClient = new NoopAnalytics();
2951
2934
  }
2952
2935
  enable() {