coveo.analytics 2.23.10 → 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.
Files changed (38) hide show
  1. package/dist/coveoua.browser.js +1 -1
  2. package/dist/coveoua.browser.js.map +1 -1
  3. package/dist/coveoua.debug.js +330 -56
  4. package/dist/coveoua.debug.js.map +1 -1
  5. package/dist/coveoua.js +1 -1
  6. package/dist/coveoua.js.map +1 -1
  7. package/dist/definitions/client/analytics.d.ts +3 -0
  8. package/dist/definitions/client/noopAnalytics.d.ts +1 -0
  9. package/dist/definitions/cookieutils.d.ts +1 -1
  10. package/dist/definitions/coveoua/simpleanalytics.d.ts +1 -0
  11. package/dist/definitions/plugins/BasePlugin.d.ts +1 -1
  12. package/dist/definitions/src/coveoua/simpleanalytics.d.ts +1 -0
  13. package/dist/definitions/storage.d.ts +1 -1
  14. package/dist/definitions/version.d.ts +1 -0
  15. package/dist/library.es.js +309 -53
  16. package/dist/library.js +324 -53
  17. package/dist/react-native.es.js +81819 -59
  18. package/package.json +5 -2
  19. package/src/client/analytics.spec.ts +42 -12
  20. package/src/client/analytics.ts +22 -1
  21. package/src/client/analyticsBeaconClient.spec.ts +1 -1
  22. package/src/client/noopAnalytics.ts +4 -0
  23. package/src/cookieutils.ts +21 -42
  24. package/src/coveoua/browser.ts +2 -2
  25. package/src/coveoua/plugins.ts +1 -1
  26. package/src/coveoua/simpleanalytics.spec.ts +11 -5
  27. package/src/coveoua/simpleanalytics.ts +6 -0
  28. package/src/plugins/BasePlugin.ts +3 -4
  29. package/src/plugins/ec.spec.ts +1 -1
  30. package/src/plugins/ec.ts +1 -1
  31. package/src/plugins/svc.spec.ts +1 -1
  32. package/src/plugins/svc.ts +1 -1
  33. package/src/react-native/react-native-runtime.ts +1 -1
  34. package/src/storage.spec.ts +8 -0
  35. package/src/storage.ts +3 -3
  36. package/src/version.ts +1 -0
  37. package/dist/definitions/client/crypto.d.ts +0 -1
  38. package/src/client/crypto.ts +0 -21
@@ -46,6 +46,7 @@ export interface AnalyticsClient {
46
46
  registerAfterSendEventHook(hook: AnalyticsClientSendEventHook): void;
47
47
  addEventTypeMapping(eventType: string, eventConfig: EventTypeConfig): void;
48
48
  runtime: IRuntimeEnvironment;
49
+ version: string;
49
50
  readonly currentVisitorId: string;
50
51
  getCurrentVisitorId?(): Promise<string>;
51
52
  }
@@ -57,6 +58,7 @@ export declare function buildBaseUrl(endpoint?: string, apiVersion?: string): st
57
58
  export declare class CoveoAnalyticsClient implements AnalyticsClient, VisitorIdProvider {
58
59
  private get defaultOptions();
59
60
  runtime: IRuntimeEnvironment;
61
+ get version(): string;
60
62
  private visitorId;
61
63
  private bufferedRequests;
62
64
  private beforeSendHooks;
@@ -69,6 +71,7 @@ export declare class CoveoAnalyticsClient implements AnalyticsClient, VisitorIdP
69
71
  private determineVisitorId;
70
72
  getCurrentVisitorId(): Promise<string>;
71
73
  setCurrentVisitorId(visitorId: string): Promise<void>;
74
+ setClientId(value: string, namespace?: string): Promise<void>;
72
75
  getParameters(eventType: EventType | string, ...payload: VariableArgumentsPayload): Promise<VariableArgumentsPayload>;
73
76
  getPayload(eventType: EventType | string, ...payload: VariableArgumentsPayload): Promise<any>;
74
77
  get currentVisitorId(): string;
@@ -20,5 +20,6 @@ export declare class NoopAnalytics implements AnalyticsClient {
20
20
  registerAfterSendEventHook(): void;
21
21
  addEventTypeMapping(): void;
22
22
  runtime: NoopRuntime;
23
+ get version(): string;
23
24
  currentVisitorId: string;
24
25
  }
@@ -1,5 +1,5 @@
1
1
  export declare class Cookie {
2
- static set(name: string, value: string, expiration?: number): void;
2
+ static set(name: string, value: string, expire?: number): void;
3
3
  static get(name: string): string | null;
4
4
  static erase(name: string): void;
5
5
  }
@@ -23,6 +23,7 @@ export declare class CoveoUA {
23
23
  require(name: string, options: Omit<PluginOptions, 'client'>): void;
24
24
  callPlugin(pluginName: string, fn: string, ...args: any): void;
25
25
  reset(): void;
26
+ version(): string;
26
27
  }
27
28
  export declare const coveoua: CoveoUA;
28
29
  export declare const getCurrentClient: () => AnalyticsClient | undefined;
@@ -1,5 +1,5 @@
1
1
  import { AnalyticsClient } from '../client/analytics';
2
- import { uuidv4 } from '../client/crypto';
2
+ import { v4 as uuidv4 } from 'uuid';
3
3
  declare type PluginWithId = {
4
4
  readonly Id: string;
5
5
  };
@@ -23,6 +23,7 @@ export declare class CoveoUA {
23
23
  require(name: string, options: Omit<PluginOptions, 'client'>): void;
24
24
  callPlugin(pluginName: string, fn: string, ...args: any): void;
25
25
  reset(): void;
26
+ version(): string;
26
27
  }
27
28
  export declare const coveoua: CoveoUA;
28
29
  export declare const getCurrentClient: () => AnalyticsClient | undefined;
@@ -9,7 +9,7 @@ export declare class CookieStorage implements WebStorage {
9
9
  static prefix: string;
10
10
  getItem(key: string): string | null;
11
11
  removeItem(key: string): void;
12
- setItem(key: string, data: string): void;
12
+ setItem(key: string, data: string, expire?: number): void;
13
13
  }
14
14
  export declare class CookieAndLocalStorage implements WebStorage {
15
15
  private cookieStorage;
@@ -0,0 +1 @@
1
+ export declare const libVersion = "2.25.1";
@@ -1,4 +1,4 @@
1
- /*! *****************************************************************************
1
+ /******************************************************************************
2
2
  Copyright (c) Microsoft Corporation.
3
3
 
4
4
  Permission to use, copy, modify, and/or distribute this software for any
@@ -71,12 +71,6 @@ function hasSessionStorage() {
71
71
  }
72
72
  function hasCookieStorage() {
73
73
  return hasNavigator() && navigator.cookieEnabled;
74
- }
75
- function hasCrypto() {
76
- return typeof crypto !== 'undefined';
77
- }
78
- function hasCryptoRandomValues() {
79
- return hasCrypto() && typeof crypto.getRandomValues !== 'undefined';
80
74
  }
81
75
 
82
76
  const eventTypesForDefaultValues = [EventType.click, EventType.custom, EventType.search, EventType.view];
@@ -86,29 +80,20 @@ const addDefaultValues = (eventType, payload) => {
86
80
  };
87
81
 
88
82
  class Cookie {
89
- static set(name, value, expiration) {
90
- var domain, domainParts, date, expires, host;
91
- if (expiration) {
92
- date = new Date();
93
- date.setTime(date.getTime() + expiration);
94
- expires = '; expires=' + date.toGMTString();
95
- }
96
- else {
97
- expires = '';
83
+ static set(name, value, expire) {
84
+ var domain, expirationDate, domainParts, host;
85
+ if (expire) {
86
+ expirationDate = new Date();
87
+ expirationDate.setTime(expirationDate.getTime() + expire);
98
88
  }
99
89
  host = window.location.hostname;
100
90
  if (host.indexOf('.') === -1) {
101
- document.cookie = name + '=' + value + expires + '; path=/';
91
+ writeCookie(name, value, expirationDate);
102
92
  }
103
93
  else {
104
94
  domainParts = host.split('.');
105
- domainParts.shift();
106
- domain = '.' + domainParts.join('.');
107
- writeCookie({ name, value, expires, domain });
108
- if (Cookie.get(name) == null || Cookie.get(name) != value) {
109
- domain = '.' + host;
110
- writeCookie({ name, value, expires, domain });
111
- }
95
+ domain = domainParts[domainParts.length - 2] + '.' + domainParts[domainParts.length - 1];
96
+ writeCookie(name, value, expirationDate, domain);
112
97
  }
113
98
  }
114
99
  static get(name) {
@@ -117,7 +102,7 @@ class Cookie {
117
102
  for (var i = 0; i < cookieArray.length; i++) {
118
103
  var cookie = cookieArray[i];
119
104
  cookie = cookie.replace(/^\s+/, '');
120
- if (cookie.indexOf(cookiePrefix) == 0) {
105
+ if (cookie.lastIndexOf(cookiePrefix, 0) === 0) {
121
106
  return cookie.substring(cookiePrefix.length, cookie.length);
122
107
  }
123
108
  }
@@ -127,9 +112,12 @@ class Cookie {
127
112
  Cookie.set(name, '', -1);
128
113
  }
129
114
  }
130
- function writeCookie(details) {
131
- const { name, value, expires, domain } = details;
132
- document.cookie = `${name}=${value}${expires}; path=/; domain=${domain}; SameSite=Lax`;
115
+ function writeCookie(name, value, expirationDate, domain) {
116
+ document.cookie =
117
+ `${name}=${value}` +
118
+ (expirationDate ? `;expires=${expirationDate.toUTCString()}` : '') +
119
+ (domain ? `;domain=${domain}` : '') +
120
+ ';SameSite=Lax';
133
121
  }
134
122
 
135
123
  function getAvailableStorage() {
@@ -151,8 +139,8 @@ class CookieStorage {
151
139
  removeItem(key) {
152
140
  Cookie.erase(`${CookieStorage.prefix}${key}`);
153
141
  }
154
- setItem(key, data) {
155
- Cookie.set(`${CookieStorage.prefix}${key}`, data);
142
+ setItem(key, data, expire) {
143
+ Cookie.set(`${CookieStorage.prefix}${key}`, data, expire);
156
144
  }
157
145
  }
158
146
  CookieStorage.prefix = 'coveo_';
@@ -169,7 +157,7 @@ class CookieAndLocalStorage {
169
157
  }
170
158
  setItem(key, data) {
171
159
  localStorage.setItem(key, data);
172
- this.cookieStorage.setItem(key, data);
160
+ this.cookieStorage.setItem(key, data, 31556926000);
173
161
  }
174
162
  }
175
163
  class NullStorage {
@@ -340,25 +328,273 @@ const addPageViewToHistory = (pageViewValue) => __awaiter(void 0, void 0, void 0
340
328
  yield store.addElementAsync(historyElement);
341
329
  });
342
330
 
343
- const uuidv4 = (a) => {
344
- if (!!a) {
345
- return (Number(a) ^ (getRandomValues(new Uint8Array(1))[0] % 16 >> (Number(a) / 4))).toString(16);
346
- }
347
- return (`${1e7}` + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, uuidv4);
348
- };
349
- const getRandomValues = (rnds) => {
350
- if (hasCryptoRandomValues()) {
351
- return crypto.getRandomValues(rnds);
352
- }
353
- for (var i = 0, r = 0; i < rnds.length; i++) {
354
- if ((i & 0x03) === 0) {
355
- r = Math.random() * 0x100000000;
356
- }
357
- rnds[i] = (r >>> ((i & 0x03) << 3)) & 0xff;
358
- }
359
- return rnds;
331
+ // Unique ID creation requires a high quality random # generator. In the browser we therefore
332
+ // require the crypto API and do not support built-in fallback to lower quality random number
333
+ // generators (like Math.random()).
334
+ let getRandomValues;
335
+ const rnds8 = new Uint8Array(16);
336
+ function rng() {
337
+ // lazy load so that environments that need to polyfill have a chance to do so
338
+ if (!getRandomValues) {
339
+ // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
340
+ getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
341
+
342
+ if (!getRandomValues) {
343
+ throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
344
+ }
345
+ }
346
+
347
+ return getRandomValues(rnds8);
348
+ }
349
+
350
+ 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;
351
+
352
+ function validate(uuid) {
353
+ return typeof uuid === 'string' && REGEX.test(uuid);
354
+ }
355
+
356
+ /**
357
+ * Convert array of 16 byte values to UUID string format of the form:
358
+ * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
359
+ */
360
+
361
+ const byteToHex = [];
362
+
363
+ for (let i = 0; i < 256; ++i) {
364
+ byteToHex.push((i + 0x100).toString(16).slice(1));
365
+ }
366
+
367
+ function unsafeStringify(arr, offset = 0) {
368
+ // Note: Be careful editing this code! It's been tuned for performance
369
+ // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
370
+ return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
371
+ }
372
+
373
+ function parse(uuid) {
374
+ if (!validate(uuid)) {
375
+ throw TypeError('Invalid UUID');
376
+ }
377
+
378
+ let v;
379
+ const arr = new Uint8Array(16); // Parse ########-....-....-....-............
380
+
381
+ arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
382
+ arr[1] = v >>> 16 & 0xff;
383
+ arr[2] = v >>> 8 & 0xff;
384
+ arr[3] = v & 0xff; // Parse ........-####-....-....-............
385
+
386
+ arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;
387
+ arr[5] = v & 0xff; // Parse ........-....-####-....-............
388
+
389
+ arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;
390
+ arr[7] = v & 0xff; // Parse ........-....-....-####-............
391
+
392
+ arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;
393
+ arr[9] = v & 0xff; // Parse ........-....-....-....-############
394
+ // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes)
395
+
396
+ arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;
397
+ arr[11] = v / 0x100000000 & 0xff;
398
+ arr[12] = v >>> 24 & 0xff;
399
+ arr[13] = v >>> 16 & 0xff;
400
+ arr[14] = v >>> 8 & 0xff;
401
+ arr[15] = v & 0xff;
402
+ return arr;
403
+ }
404
+
405
+ function stringToBytes(str) {
406
+ str = unescape(encodeURIComponent(str)); // UTF8 escape
407
+
408
+ const bytes = [];
409
+
410
+ for (let i = 0; i < str.length; ++i) {
411
+ bytes.push(str.charCodeAt(i));
412
+ }
413
+
414
+ return bytes;
415
+ }
416
+
417
+ const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
418
+ const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
419
+ function v35(name, version, hashfunc) {
420
+ function generateUUID(value, namespace, buf, offset) {
421
+ var _namespace;
422
+
423
+ if (typeof value === 'string') {
424
+ value = stringToBytes(value);
425
+ }
426
+
427
+ if (typeof namespace === 'string') {
428
+ namespace = parse(namespace);
429
+ }
430
+
431
+ if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) {
432
+ throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');
433
+ } // Compute hash of namespace and value, Per 4.3
434
+ // Future: Use spread syntax when supported on all platforms, e.g. `bytes =
435
+ // hashfunc([...namespace, ... value])`
436
+
437
+
438
+ let bytes = new Uint8Array(16 + value.length);
439
+ bytes.set(namespace);
440
+ bytes.set(value, namespace.length);
441
+ bytes = hashfunc(bytes);
442
+ bytes[6] = bytes[6] & 0x0f | version;
443
+ bytes[8] = bytes[8] & 0x3f | 0x80;
444
+
445
+ if (buf) {
446
+ offset = offset || 0;
447
+
448
+ for (let i = 0; i < 16; ++i) {
449
+ buf[offset + i] = bytes[i];
450
+ }
451
+
452
+ return buf;
453
+ }
454
+
455
+ return unsafeStringify(bytes);
456
+ } // Function#name is not settable on some platforms (#270)
457
+
458
+
459
+ try {
460
+ generateUUID.name = name; // eslint-disable-next-line no-empty
461
+ } catch (err) {} // For CommonJS default export support
462
+
463
+
464
+ generateUUID.DNS = DNS;
465
+ generateUUID.URL = URL;
466
+ return generateUUID;
467
+ }
468
+
469
+ const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
470
+ var native = {
471
+ randomUUID
360
472
  };
361
473
 
474
+ function v4(options, buf, offset) {
475
+ if (native.randomUUID && !buf && !options) {
476
+ return native.randomUUID();
477
+ }
478
+
479
+ options = options || {};
480
+ const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
481
+
482
+ rnds[6] = rnds[6] & 0x0f | 0x40;
483
+ rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
484
+
485
+ if (buf) {
486
+ offset = offset || 0;
487
+
488
+ for (let i = 0; i < 16; ++i) {
489
+ buf[offset + i] = rnds[i];
490
+ }
491
+
492
+ return buf;
493
+ }
494
+
495
+ return unsafeStringify(rnds);
496
+ }
497
+
498
+ // Adapted from Chris Veness' SHA1 code at
499
+ // http://www.movable-type.co.uk/scripts/sha1.html
500
+ function f(s, x, y, z) {
501
+ switch (s) {
502
+ case 0:
503
+ return x & y ^ ~x & z;
504
+
505
+ case 1:
506
+ return x ^ y ^ z;
507
+
508
+ case 2:
509
+ return x & y ^ x & z ^ y & z;
510
+
511
+ case 3:
512
+ return x ^ y ^ z;
513
+ }
514
+ }
515
+
516
+ function ROTL(x, n) {
517
+ return x << n | x >>> 32 - n;
518
+ }
519
+
520
+ function sha1(bytes) {
521
+ const K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];
522
+ const H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
523
+
524
+ if (typeof bytes === 'string') {
525
+ const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
526
+
527
+ bytes = [];
528
+
529
+ for (let i = 0; i < msg.length; ++i) {
530
+ bytes.push(msg.charCodeAt(i));
531
+ }
532
+ } else if (!Array.isArray(bytes)) {
533
+ // Convert Array-like to Array
534
+ bytes = Array.prototype.slice.call(bytes);
535
+ }
536
+
537
+ bytes.push(0x80);
538
+ const l = bytes.length / 4 + 2;
539
+ const N = Math.ceil(l / 16);
540
+ const M = new Array(N);
541
+
542
+ for (let i = 0; i < N; ++i) {
543
+ const arr = new Uint32Array(16);
544
+
545
+ for (let j = 0; j < 16; ++j) {
546
+ arr[j] = bytes[i * 64 + j * 4] << 24 | bytes[i * 64 + j * 4 + 1] << 16 | bytes[i * 64 + j * 4 + 2] << 8 | bytes[i * 64 + j * 4 + 3];
547
+ }
548
+
549
+ M[i] = arr;
550
+ }
551
+
552
+ M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32);
553
+ M[N - 1][14] = Math.floor(M[N - 1][14]);
554
+ M[N - 1][15] = (bytes.length - 1) * 8 & 0xffffffff;
555
+
556
+ for (let i = 0; i < N; ++i) {
557
+ const W = new Uint32Array(80);
558
+
559
+ for (let t = 0; t < 16; ++t) {
560
+ W[t] = M[i][t];
561
+ }
562
+
563
+ for (let t = 16; t < 80; ++t) {
564
+ W[t] = ROTL(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1);
565
+ }
566
+
567
+ let a = H[0];
568
+ let b = H[1];
569
+ let c = H[2];
570
+ let d = H[3];
571
+ let e = H[4];
572
+
573
+ for (let t = 0; t < 80; ++t) {
574
+ const s = Math.floor(t / 20);
575
+ const T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[t] >>> 0;
576
+ e = d;
577
+ d = c;
578
+ c = ROTL(b, 30) >>> 0;
579
+ b = a;
580
+ a = T;
581
+ }
582
+
583
+ H[0] = H[0] + a >>> 0;
584
+ H[1] = H[1] + b >>> 0;
585
+ H[2] = H[2] + c >>> 0;
586
+ H[3] = H[3] + d >>> 0;
587
+ H[4] = H[4] + e >>> 0;
588
+ }
589
+
590
+ return [H[0] >> 24 & 0xff, H[0] >> 16 & 0xff, H[0] >> 8 & 0xff, H[0] & 0xff, H[1] >> 24 & 0xff, H[1] >> 16 & 0xff, H[1] >> 8 & 0xff, H[1] & 0xff, H[2] >> 24 & 0xff, H[2] >> 16 & 0xff, H[2] >> 8 & 0xff, H[2] & 0xff, H[3] >> 24 & 0xff, H[3] >> 16 & 0xff, H[3] >> 8 & 0xff, H[3] & 0xff, H[4] >> 24 & 0xff, H[4] >> 16 & 0xff, H[4] >> 8 & 0xff, H[4] & 0xff];
591
+ }
592
+
593
+ const v5 = v35('v5', 0x50, sha1);
594
+ var uuidv5 = v5;
595
+
596
+ const libVersion = "2.25.1" ;
597
+
362
598
  const keysOf = Object.keys;
363
599
  function isObject(o) {
364
600
  return o !== null && typeof o === 'object' && !Array.isArray(o);
@@ -779,6 +1015,7 @@ function buildBaseUrl(endpoint = Endpoints.default, apiVersion = Version) {
779
1015
  const endpointIsCoveoProxy = endpoint.indexOf('.cloud.coveo.com') !== -1;
780
1016
  return `${endpoint}${endpointIsCoveoProxy ? '' : '/rest'}/${apiVersion}`;
781
1017
  }
1018
+ const COVEO_NAMESPACE = '38824e1f-37f5-42d3-8372-a4b8fa9df946';
782
1019
  class CoveoAnalyticsClient {
783
1020
  constructor(opts) {
784
1021
  if (!opts) {
@@ -811,6 +1048,9 @@ class CoveoAnalyticsClient {
811
1048
  afterSendHooks: [],
812
1049
  };
813
1050
  }
1051
+ get version() {
1052
+ return libVersion;
1053
+ }
814
1054
  initRuntime(clientsOptions) {
815
1055
  if (hasWindow() && hasDocument()) {
816
1056
  return new BrowserRuntime(clientsOptions, () => {
@@ -830,11 +1070,11 @@ class CoveoAnalyticsClient {
830
1070
  determineVisitorId() {
831
1071
  return __awaiter(this, void 0, void 0, function* () {
832
1072
  try {
833
- return (yield this.storage.getItem('visitorId')) || uuidv4();
1073
+ return (yield this.storage.getItem('visitorId')) || v4();
834
1074
  }
835
1075
  catch (err) {
836
1076
  console.log('Could not get visitor ID from the current runtime environment storage. Using a random ID instead.', err);
837
- return uuidv4();
1077
+ return v4();
838
1078
  }
839
1079
  });
840
1080
  }
@@ -853,6 +1093,19 @@ class CoveoAnalyticsClient {
853
1093
  yield this.storage.setItem('visitorId', visitorId);
854
1094
  });
855
1095
  }
1096
+ setClientId(value, namespace) {
1097
+ return __awaiter(this, void 0, void 0, function* () {
1098
+ if (validate(value)) {
1099
+ this.setCurrentVisitorId(value);
1100
+ }
1101
+ else {
1102
+ if (!namespace) {
1103
+ throw Error('Cannot generate uuid client id without a specific namespace string.');
1104
+ }
1105
+ this.setCurrentVisitorId(uuidv5(value, uuidv5(namespace, COVEO_NAMESPACE)));
1106
+ }
1107
+ });
1108
+ }
856
1109
  getParameters(eventType, ...payload) {
857
1110
  return __awaiter(this, void 0, void 0, function* () {
858
1111
  return yield this.resolveParameters(eventType, ...payload);
@@ -867,7 +1120,7 @@ class CoveoAnalyticsClient {
867
1120
  get currentVisitorId() {
868
1121
  const visitorId = this.visitorId || this.storage.getItem('visitorId');
869
1122
  if (typeof visitorId !== 'string') {
870
- this.setCurrentVisitorId(uuidv4());
1123
+ this.setCurrentVisitorId(v4());
871
1124
  }
872
1125
  return this.visitorId;
873
1126
  }
@@ -1308,6 +1561,9 @@ class NoopAnalytics {
1308
1561
  registerBeforeSendEventHook() { }
1309
1562
  registerAfterSendEventHook() { }
1310
1563
  addEventTypeMapping() { }
1564
+ get version() {
1565
+ return libVersion;
1566
+ }
1311
1567
  }
1312
1568
 
1313
1569
  function filterConsecutiveRepeatedValues(rawData) {
@@ -2063,7 +2319,7 @@ const BasePluginEventTypes = {
2063
2319
  event: 'event',
2064
2320
  };
2065
2321
  class BasePlugin {
2066
- constructor({ client, uuidGenerator = uuidv4 }) {
2322
+ constructor({ client, uuidGenerator = v4 }) {
2067
2323
  this.actionData = {};
2068
2324
  this.client = client;
2069
2325
  this.uuidGenerator = uuidGenerator;
@@ -2143,7 +2399,7 @@ class BasePlugin {
2143
2399
  const SVCPluginEventTypes = Object.assign({}, BasePluginEventTypes);
2144
2400
  const allSVCEventTypes = Object.keys(SVCPluginEventTypes).map((key) => SVCPluginEventTypes[key]);
2145
2401
  class SVCPlugin extends BasePlugin {
2146
- constructor({ client, uuidGenerator = uuidv4 }) {
2402
+ constructor({ client, uuidGenerator = v4 }) {
2147
2403
  super({ client, uuidGenerator });
2148
2404
  this.ticket = {};
2149
2405
  }