coveo.analytics 2.24.1 → 2.25.1

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.
@@ -141,12 +141,6 @@
141
141
  }
142
142
  function hasCookieStorage() {
143
143
  return hasNavigator() && navigator.cookieEnabled;
144
- }
145
- function hasCrypto() {
146
- return typeof crypto !== 'undefined';
147
- }
148
- function hasCryptoRandomValues() {
149
- return hasCrypto() && typeof crypto.getRandomValues !== 'undefined';
150
144
  }
151
145
 
152
146
  var eventTypesForDefaultValues = [EventType.click, EventType.custom, EventType.search, EventType.view];
@@ -465,24 +459,24 @@
465
459
  });
466
460
  }); };
467
461
 
468
- var uuidv4 = function (a) {
469
- if (!!a) {
470
- return (Number(a) ^ (getRandomValues(new Uint8Array(1))[0] % 16 >> (Number(a) / 4))).toString(16);
471
- }
472
- return ("" + 1e7 + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, uuidv4);
473
- };
474
- var getRandomValues = function (rnds) {
475
- if (hasCryptoRandomValues()) {
476
- return crypto.getRandomValues(rnds);
477
- }
478
- for (var i = 0, r = 0; i < rnds.length; i++) {
479
- if ((i & 0x03) === 0) {
480
- r = Math.random() * 0x100000000;
481
- }
482
- rnds[i] = (r >>> ((i & 0x03) << 3)) & 0xff;
483
- }
484
- return rnds;
485
- };
462
+ // Unique ID creation requires a high quality random # generator. In the browser we therefore
463
+ // require the crypto API and do not support built-in fallback to lower quality random number
464
+ // generators (like Math.random()).
465
+ let getRandomValues;
466
+ const rnds8 = new Uint8Array(16);
467
+ function rng() {
468
+ // lazy load so that environments that need to polyfill have a chance to do so
469
+ if (!getRandomValues) {
470
+ // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
471
+ getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
472
+
473
+ if (!getRandomValues) {
474
+ throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
475
+ }
476
+ }
477
+
478
+ return getRandomValues(rnds8);
479
+ }
486
480
 
487
481
  var REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
488
482
 
@@ -603,6 +597,35 @@
603
597
  return generateUUID;
604
598
  }
605
599
 
600
+ const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
601
+ var native = {
602
+ randomUUID
603
+ };
604
+
605
+ function v4(options, buf, offset) {
606
+ if (native.randomUUID && !buf && !options) {
607
+ return native.randomUUID();
608
+ }
609
+
610
+ options = options || {};
611
+ const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
612
+
613
+ rnds[6] = rnds[6] & 0x0f | 0x40;
614
+ rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
615
+
616
+ if (buf) {
617
+ offset = offset || 0;
618
+
619
+ for (let i = 0; i < 16; ++i) {
620
+ buf[offset + i] = rnds[i];
621
+ }
622
+
623
+ return buf;
624
+ }
625
+
626
+ return unsafeStringify(rnds);
627
+ }
628
+
606
629
  // Adapted from Chris Veness' SHA1 code at
607
630
  // http://www.movable-type.co.uk/scripts/sha1.html
608
631
  function f(s, x, y, z) {
@@ -701,7 +724,7 @@
701
724
  const v5 = v35('v5', 0x50, sha1);
702
725
  var uuidv5 = v5;
703
726
 
704
- var libVersion = "2.24.1" ;
727
+ var libVersion = "2.25.1" ;
705
728
 
706
729
  var keysOf = Object.keys;
707
730
  function isObject(o) {
@@ -1318,11 +1341,11 @@
1318
1341
  case 0:
1319
1342
  _a.trys.push([0, 2, , 3]);
1320
1343
  return [4, this.storage.getItem('visitorId')];
1321
- case 1: return [2, (_a.sent()) || uuidv4()];
1344
+ case 1: return [2, (_a.sent()) || v4()];
1322
1345
  case 2:
1323
1346
  err_1 = _a.sent();
1324
1347
  console.log('Could not get visitor ID from the current runtime environment storage. Using a random ID instead.', err_1);
1325
- return [2, uuidv4()];
1348
+ return [2, v4()];
1326
1349
  case 3: return [2];
1327
1350
  }
1328
1351
  });
@@ -1413,7 +1436,7 @@
1413
1436
  get: function () {
1414
1437
  var visitorId = this.visitorId || this.storage.getItem('visitorId');
1415
1438
  if (typeof visitorId !== 'string') {
1416
- this.setCurrentVisitorId(uuidv4());
1439
+ this.setCurrentVisitorId(v4());
1417
1440
  }
1418
1441
  return this.visitorId;
1419
1442
  },
@@ -1880,7 +1903,7 @@
1880
1903
  };
1881
1904
  var BasePlugin = (function () {
1882
1905
  function BasePlugin(_a) {
1883
- var client = _a.client, _b = _a.uuidGenerator, uuidGenerator = _b === void 0 ? uuidv4 : _b;
1906
+ var client = _a.client, _b = _a.uuidGenerator, uuidGenerator = _b === void 0 ? v4 : _b;
1884
1907
  this.actionData = {};
1885
1908
  this.client = client;
1886
1909
  this.uuidGenerator = uuidGenerator;
@@ -1963,7 +1986,7 @@
1963
1986
  var ECPlugin = (function (_super) {
1964
1987
  __extends(ECPlugin, _super);
1965
1988
  function ECPlugin(_a) {
1966
- var client = _a.client, _b = _a.uuidGenerator, uuidGenerator = _b === void 0 ? uuidv4 : _b;
1989
+ var client = _a.client, _b = _a.uuidGenerator, uuidGenerator = _b === void 0 ? v4 : _b;
1967
1990
  var _this = _super.call(this, { client: client, uuidGenerator: uuidGenerator }) || this;
1968
1991
  _this.products = [];
1969
1992
  _this.impressions = [];
@@ -2091,7 +2114,7 @@
2091
2114
  var SVCPlugin = (function (_super) {
2092
2115
  __extends(SVCPlugin, _super);
2093
2116
  function SVCPlugin(_a) {
2094
- var client = _a.client, _b = _a.uuidGenerator, uuidGenerator = _b === void 0 ? uuidv4 : _b;
2117
+ var client = _a.client, _b = _a.uuidGenerator, uuidGenerator = _b === void 0 ? v4 : _b;
2095
2118
  var _this = _super.call(this, { client: client, uuidGenerator: uuidGenerator }) || this;
2096
2119
  _this.ticket = {};
2097
2120
  return _this;