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.
- package/dist/coveoua.browser.js +1 -1
- package/dist/coveoua.browser.js.map +1 -1
- package/dist/coveoua.debug.js +54 -31
- package/dist/coveoua.debug.js.map +1 -1
- package/dist/coveoua.js +1 -1
- package/dist/coveoua.js.map +1 -1
- package/dist/definitions/plugins/BasePlugin.d.ts +1 -1
- package/dist/definitions/version.d.ts +1 -1
- package/dist/library.es.js +53 -30
- package/dist/library.js +54 -31
- package/dist/react-native.es.js +272 -249
- package/package.json +1 -1
- package/src/client/analytics.spec.ts +4 -5
- package/src/client/analytics.ts +1 -2
- package/src/coveoua/simpleanalytics.spec.ts +2 -4
- package/src/plugins/BasePlugin.ts +3 -4
- package/src/plugins/ec.spec.ts +1 -1
- package/src/plugins/ec.ts +1 -1
- package/src/plugins/svc.spec.ts +1 -1
- package/src/plugins/svc.ts +1 -1
- package/src/react-native/react-native-runtime.ts +1 -1
- package/dist/definitions/client/crypto.d.ts +0 -1
- package/src/client/crypto.ts +0 -21
package/dist/react-native.es.js
CHANGED
|
@@ -81609,6 +81609,271 @@ class AnalyticsFetchClient {
|
|
|
81609
81609
|
}
|
|
81610
81610
|
}
|
|
81611
81611
|
|
|
81612
|
+
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
|
81613
|
+
// require the crypto API and do not support built-in fallback to lower quality random number
|
|
81614
|
+
// generators (like Math.random()).
|
|
81615
|
+
let getRandomValues;
|
|
81616
|
+
const rnds8 = new Uint8Array(16);
|
|
81617
|
+
function rng() {
|
|
81618
|
+
// lazy load so that environments that need to polyfill have a chance to do so
|
|
81619
|
+
if (!getRandomValues) {
|
|
81620
|
+
// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
|
|
81621
|
+
getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
|
81622
|
+
|
|
81623
|
+
if (!getRandomValues) {
|
|
81624
|
+
throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
|
|
81625
|
+
}
|
|
81626
|
+
}
|
|
81627
|
+
|
|
81628
|
+
return getRandomValues(rnds8);
|
|
81629
|
+
}
|
|
81630
|
+
|
|
81631
|
+
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;
|
|
81632
|
+
|
|
81633
|
+
function validate(uuid) {
|
|
81634
|
+
return typeof uuid === 'string' && REGEX.test(uuid);
|
|
81635
|
+
}
|
|
81636
|
+
|
|
81637
|
+
/**
|
|
81638
|
+
* Convert array of 16 byte values to UUID string format of the form:
|
|
81639
|
+
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
81640
|
+
*/
|
|
81641
|
+
|
|
81642
|
+
const byteToHex = [];
|
|
81643
|
+
|
|
81644
|
+
for (let i = 0; i < 256; ++i) {
|
|
81645
|
+
byteToHex.push((i + 0x100).toString(16).slice(1));
|
|
81646
|
+
}
|
|
81647
|
+
|
|
81648
|
+
function unsafeStringify(arr, offset = 0) {
|
|
81649
|
+
// Note: Be careful editing this code! It's been tuned for performance
|
|
81650
|
+
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
|
81651
|
+
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();
|
|
81652
|
+
}
|
|
81653
|
+
|
|
81654
|
+
function parse(uuid) {
|
|
81655
|
+
if (!validate(uuid)) {
|
|
81656
|
+
throw TypeError('Invalid UUID');
|
|
81657
|
+
}
|
|
81658
|
+
|
|
81659
|
+
let v;
|
|
81660
|
+
const arr = new Uint8Array(16); // Parse ########-....-....-....-............
|
|
81661
|
+
|
|
81662
|
+
arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
|
|
81663
|
+
arr[1] = v >>> 16 & 0xff;
|
|
81664
|
+
arr[2] = v >>> 8 & 0xff;
|
|
81665
|
+
arr[3] = v & 0xff; // Parse ........-####-....-....-............
|
|
81666
|
+
|
|
81667
|
+
arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;
|
|
81668
|
+
arr[5] = v & 0xff; // Parse ........-....-####-....-............
|
|
81669
|
+
|
|
81670
|
+
arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;
|
|
81671
|
+
arr[7] = v & 0xff; // Parse ........-....-....-####-............
|
|
81672
|
+
|
|
81673
|
+
arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;
|
|
81674
|
+
arr[9] = v & 0xff; // Parse ........-....-....-....-############
|
|
81675
|
+
// (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes)
|
|
81676
|
+
|
|
81677
|
+
arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;
|
|
81678
|
+
arr[11] = v / 0x100000000 & 0xff;
|
|
81679
|
+
arr[12] = v >>> 24 & 0xff;
|
|
81680
|
+
arr[13] = v >>> 16 & 0xff;
|
|
81681
|
+
arr[14] = v >>> 8 & 0xff;
|
|
81682
|
+
arr[15] = v & 0xff;
|
|
81683
|
+
return arr;
|
|
81684
|
+
}
|
|
81685
|
+
|
|
81686
|
+
function stringToBytes(str) {
|
|
81687
|
+
str = unescape(encodeURIComponent(str)); // UTF8 escape
|
|
81688
|
+
|
|
81689
|
+
const bytes = [];
|
|
81690
|
+
|
|
81691
|
+
for (let i = 0; i < str.length; ++i) {
|
|
81692
|
+
bytes.push(str.charCodeAt(i));
|
|
81693
|
+
}
|
|
81694
|
+
|
|
81695
|
+
return bytes;
|
|
81696
|
+
}
|
|
81697
|
+
|
|
81698
|
+
const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
|
|
81699
|
+
const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
|
|
81700
|
+
function v35(name, version, hashfunc) {
|
|
81701
|
+
function generateUUID(value, namespace, buf, offset) {
|
|
81702
|
+
var _namespace;
|
|
81703
|
+
|
|
81704
|
+
if (typeof value === 'string') {
|
|
81705
|
+
value = stringToBytes(value);
|
|
81706
|
+
}
|
|
81707
|
+
|
|
81708
|
+
if (typeof namespace === 'string') {
|
|
81709
|
+
namespace = parse(namespace);
|
|
81710
|
+
}
|
|
81711
|
+
|
|
81712
|
+
if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) {
|
|
81713
|
+
throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');
|
|
81714
|
+
} // Compute hash of namespace and value, Per 4.3
|
|
81715
|
+
// Future: Use spread syntax when supported on all platforms, e.g. `bytes =
|
|
81716
|
+
// hashfunc([...namespace, ... value])`
|
|
81717
|
+
|
|
81718
|
+
|
|
81719
|
+
let bytes = new Uint8Array(16 + value.length);
|
|
81720
|
+
bytes.set(namespace);
|
|
81721
|
+
bytes.set(value, namespace.length);
|
|
81722
|
+
bytes = hashfunc(bytes);
|
|
81723
|
+
bytes[6] = bytes[6] & 0x0f | version;
|
|
81724
|
+
bytes[8] = bytes[8] & 0x3f | 0x80;
|
|
81725
|
+
|
|
81726
|
+
if (buf) {
|
|
81727
|
+
offset = offset || 0;
|
|
81728
|
+
|
|
81729
|
+
for (let i = 0; i < 16; ++i) {
|
|
81730
|
+
buf[offset + i] = bytes[i];
|
|
81731
|
+
}
|
|
81732
|
+
|
|
81733
|
+
return buf;
|
|
81734
|
+
}
|
|
81735
|
+
|
|
81736
|
+
return unsafeStringify(bytes);
|
|
81737
|
+
} // Function#name is not settable on some platforms (#270)
|
|
81738
|
+
|
|
81739
|
+
|
|
81740
|
+
try {
|
|
81741
|
+
generateUUID.name = name; // eslint-disable-next-line no-empty
|
|
81742
|
+
} catch (err) {} // For CommonJS default export support
|
|
81743
|
+
|
|
81744
|
+
|
|
81745
|
+
generateUUID.DNS = DNS;
|
|
81746
|
+
generateUUID.URL = URL;
|
|
81747
|
+
return generateUUID;
|
|
81748
|
+
}
|
|
81749
|
+
|
|
81750
|
+
const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
81751
|
+
var native = {
|
|
81752
|
+
randomUUID
|
|
81753
|
+
};
|
|
81754
|
+
|
|
81755
|
+
function v4(options, buf, offset) {
|
|
81756
|
+
if (native.randomUUID && !buf && !options) {
|
|
81757
|
+
return native.randomUUID();
|
|
81758
|
+
}
|
|
81759
|
+
|
|
81760
|
+
options = options || {};
|
|
81761
|
+
const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
81762
|
+
|
|
81763
|
+
rnds[6] = rnds[6] & 0x0f | 0x40;
|
|
81764
|
+
rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
|
|
81765
|
+
|
|
81766
|
+
if (buf) {
|
|
81767
|
+
offset = offset || 0;
|
|
81768
|
+
|
|
81769
|
+
for (let i = 0; i < 16; ++i) {
|
|
81770
|
+
buf[offset + i] = rnds[i];
|
|
81771
|
+
}
|
|
81772
|
+
|
|
81773
|
+
return buf;
|
|
81774
|
+
}
|
|
81775
|
+
|
|
81776
|
+
return unsafeStringify(rnds);
|
|
81777
|
+
}
|
|
81778
|
+
|
|
81779
|
+
// Adapted from Chris Veness' SHA1 code at
|
|
81780
|
+
// http://www.movable-type.co.uk/scripts/sha1.html
|
|
81781
|
+
function f(s, x, y, z) {
|
|
81782
|
+
switch (s) {
|
|
81783
|
+
case 0:
|
|
81784
|
+
return x & y ^ ~x & z;
|
|
81785
|
+
|
|
81786
|
+
case 1:
|
|
81787
|
+
return x ^ y ^ z;
|
|
81788
|
+
|
|
81789
|
+
case 2:
|
|
81790
|
+
return x & y ^ x & z ^ y & z;
|
|
81791
|
+
|
|
81792
|
+
case 3:
|
|
81793
|
+
return x ^ y ^ z;
|
|
81794
|
+
}
|
|
81795
|
+
}
|
|
81796
|
+
|
|
81797
|
+
function ROTL(x, n) {
|
|
81798
|
+
return x << n | x >>> 32 - n;
|
|
81799
|
+
}
|
|
81800
|
+
|
|
81801
|
+
function sha1(bytes) {
|
|
81802
|
+
const K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];
|
|
81803
|
+
const H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
|
|
81804
|
+
|
|
81805
|
+
if (typeof bytes === 'string') {
|
|
81806
|
+
const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
|
|
81807
|
+
|
|
81808
|
+
bytes = [];
|
|
81809
|
+
|
|
81810
|
+
for (let i = 0; i < msg.length; ++i) {
|
|
81811
|
+
bytes.push(msg.charCodeAt(i));
|
|
81812
|
+
}
|
|
81813
|
+
} else if (!Array.isArray(bytes)) {
|
|
81814
|
+
// Convert Array-like to Array
|
|
81815
|
+
bytes = Array.prototype.slice.call(bytes);
|
|
81816
|
+
}
|
|
81817
|
+
|
|
81818
|
+
bytes.push(0x80);
|
|
81819
|
+
const l = bytes.length / 4 + 2;
|
|
81820
|
+
const N = Math.ceil(l / 16);
|
|
81821
|
+
const M = new Array(N);
|
|
81822
|
+
|
|
81823
|
+
for (let i = 0; i < N; ++i) {
|
|
81824
|
+
const arr = new Uint32Array(16);
|
|
81825
|
+
|
|
81826
|
+
for (let j = 0; j < 16; ++j) {
|
|
81827
|
+
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];
|
|
81828
|
+
}
|
|
81829
|
+
|
|
81830
|
+
M[i] = arr;
|
|
81831
|
+
}
|
|
81832
|
+
|
|
81833
|
+
M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32);
|
|
81834
|
+
M[N - 1][14] = Math.floor(M[N - 1][14]);
|
|
81835
|
+
M[N - 1][15] = (bytes.length - 1) * 8 & 0xffffffff;
|
|
81836
|
+
|
|
81837
|
+
for (let i = 0; i < N; ++i) {
|
|
81838
|
+
const W = new Uint32Array(80);
|
|
81839
|
+
|
|
81840
|
+
for (let t = 0; t < 16; ++t) {
|
|
81841
|
+
W[t] = M[i][t];
|
|
81842
|
+
}
|
|
81843
|
+
|
|
81844
|
+
for (let t = 16; t < 80; ++t) {
|
|
81845
|
+
W[t] = ROTL(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1);
|
|
81846
|
+
}
|
|
81847
|
+
|
|
81848
|
+
let a = H[0];
|
|
81849
|
+
let b = H[1];
|
|
81850
|
+
let c = H[2];
|
|
81851
|
+
let d = H[3];
|
|
81852
|
+
let e = H[4];
|
|
81853
|
+
|
|
81854
|
+
for (let t = 0; t < 80; ++t) {
|
|
81855
|
+
const s = Math.floor(t / 20);
|
|
81856
|
+
const T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[t] >>> 0;
|
|
81857
|
+
e = d;
|
|
81858
|
+
d = c;
|
|
81859
|
+
c = ROTL(b, 30) >>> 0;
|
|
81860
|
+
b = a;
|
|
81861
|
+
a = T;
|
|
81862
|
+
}
|
|
81863
|
+
|
|
81864
|
+
H[0] = H[0] + a >>> 0;
|
|
81865
|
+
H[1] = H[1] + b >>> 0;
|
|
81866
|
+
H[2] = H[2] + c >>> 0;
|
|
81867
|
+
H[3] = H[3] + d >>> 0;
|
|
81868
|
+
H[4] = H[4] + e >>> 0;
|
|
81869
|
+
}
|
|
81870
|
+
|
|
81871
|
+
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];
|
|
81872
|
+
}
|
|
81873
|
+
|
|
81874
|
+
const v5 = v35('v5', 0x50, sha1);
|
|
81875
|
+
var uuidv5 = v5;
|
|
81876
|
+
|
|
81612
81877
|
function hasWindow() {
|
|
81613
81878
|
return typeof window !== 'undefined';
|
|
81614
81879
|
}
|
|
@@ -81636,33 +81901,8 @@ function hasSessionStorage() {
|
|
|
81636
81901
|
}
|
|
81637
81902
|
function hasCookieStorage() {
|
|
81638
81903
|
return hasNavigator() && navigator.cookieEnabled;
|
|
81639
|
-
}
|
|
81640
|
-
function hasCrypto() {
|
|
81641
|
-
return typeof crypto !== 'undefined';
|
|
81642
|
-
}
|
|
81643
|
-
function hasCryptoRandomValues() {
|
|
81644
|
-
return hasCrypto() && typeof crypto.getRandomValues !== 'undefined';
|
|
81645
81904
|
}
|
|
81646
81905
|
|
|
81647
|
-
const uuidv4 = (a) => {
|
|
81648
|
-
if (!!a) {
|
|
81649
|
-
return (Number(a) ^ (getRandomValues(new Uint8Array(1))[0] % 16 >> (Number(a) / 4))).toString(16);
|
|
81650
|
-
}
|
|
81651
|
-
return (`${1e7}` + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, uuidv4);
|
|
81652
|
-
};
|
|
81653
|
-
const getRandomValues = (rnds) => {
|
|
81654
|
-
if (hasCryptoRandomValues()) {
|
|
81655
|
-
return crypto.getRandomValues(rnds);
|
|
81656
|
-
}
|
|
81657
|
-
for (var i = 0, r = 0; i < rnds.length; i++) {
|
|
81658
|
-
if ((i & 0x03) === 0) {
|
|
81659
|
-
r = Math.random() * 0x100000000;
|
|
81660
|
-
}
|
|
81661
|
-
rnds[i] = (r >>> ((i & 0x03) << 3)) & 0xff;
|
|
81662
|
-
}
|
|
81663
|
-
return rnds;
|
|
81664
|
-
};
|
|
81665
|
-
|
|
81666
81906
|
const eventTypesForDefaultValues = [EventType.click, EventType.custom, EventType.search, EventType.view];
|
|
81667
81907
|
const addDefaultValues = (eventType, payload) => {
|
|
81668
81908
|
return eventTypesForDefaultValues.indexOf(eventType) !== -1
|
|
@@ -81918,224 +82158,7 @@ const addPageViewToHistory = (pageViewValue) => __awaiter(void 0, void 0, void 0
|
|
|
81918
82158
|
yield store.addElementAsync(historyElement);
|
|
81919
82159
|
});
|
|
81920
82160
|
|
|
81921
|
-
|
|
81922
|
-
|
|
81923
|
-
function validate(uuid) {
|
|
81924
|
-
return typeof uuid === 'string' && REGEX.test(uuid);
|
|
81925
|
-
}
|
|
81926
|
-
|
|
81927
|
-
/**
|
|
81928
|
-
* Convert array of 16 byte values to UUID string format of the form:
|
|
81929
|
-
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
81930
|
-
*/
|
|
81931
|
-
|
|
81932
|
-
const byteToHex = [];
|
|
81933
|
-
|
|
81934
|
-
for (let i = 0; i < 256; ++i) {
|
|
81935
|
-
byteToHex.push((i + 0x100).toString(16).slice(1));
|
|
81936
|
-
}
|
|
81937
|
-
|
|
81938
|
-
function unsafeStringify(arr, offset = 0) {
|
|
81939
|
-
// Note: Be careful editing this code! It's been tuned for performance
|
|
81940
|
-
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
|
81941
|
-
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();
|
|
81942
|
-
}
|
|
81943
|
-
|
|
81944
|
-
function parse(uuid) {
|
|
81945
|
-
if (!validate(uuid)) {
|
|
81946
|
-
throw TypeError('Invalid UUID');
|
|
81947
|
-
}
|
|
81948
|
-
|
|
81949
|
-
let v;
|
|
81950
|
-
const arr = new Uint8Array(16); // Parse ########-....-....-....-............
|
|
81951
|
-
|
|
81952
|
-
arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
|
|
81953
|
-
arr[1] = v >>> 16 & 0xff;
|
|
81954
|
-
arr[2] = v >>> 8 & 0xff;
|
|
81955
|
-
arr[3] = v & 0xff; // Parse ........-####-....-....-............
|
|
81956
|
-
|
|
81957
|
-
arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;
|
|
81958
|
-
arr[5] = v & 0xff; // Parse ........-....-####-....-............
|
|
81959
|
-
|
|
81960
|
-
arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;
|
|
81961
|
-
arr[7] = v & 0xff; // Parse ........-....-....-####-............
|
|
81962
|
-
|
|
81963
|
-
arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;
|
|
81964
|
-
arr[9] = v & 0xff; // Parse ........-....-....-....-############
|
|
81965
|
-
// (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes)
|
|
81966
|
-
|
|
81967
|
-
arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;
|
|
81968
|
-
arr[11] = v / 0x100000000 & 0xff;
|
|
81969
|
-
arr[12] = v >>> 24 & 0xff;
|
|
81970
|
-
arr[13] = v >>> 16 & 0xff;
|
|
81971
|
-
arr[14] = v >>> 8 & 0xff;
|
|
81972
|
-
arr[15] = v & 0xff;
|
|
81973
|
-
return arr;
|
|
81974
|
-
}
|
|
81975
|
-
|
|
81976
|
-
function stringToBytes(str) {
|
|
81977
|
-
str = unescape(encodeURIComponent(str)); // UTF8 escape
|
|
81978
|
-
|
|
81979
|
-
const bytes = [];
|
|
81980
|
-
|
|
81981
|
-
for (let i = 0; i < str.length; ++i) {
|
|
81982
|
-
bytes.push(str.charCodeAt(i));
|
|
81983
|
-
}
|
|
81984
|
-
|
|
81985
|
-
return bytes;
|
|
81986
|
-
}
|
|
81987
|
-
|
|
81988
|
-
const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
|
|
81989
|
-
const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
|
|
81990
|
-
function v35(name, version, hashfunc) {
|
|
81991
|
-
function generateUUID(value, namespace, buf, offset) {
|
|
81992
|
-
var _namespace;
|
|
81993
|
-
|
|
81994
|
-
if (typeof value === 'string') {
|
|
81995
|
-
value = stringToBytes(value);
|
|
81996
|
-
}
|
|
81997
|
-
|
|
81998
|
-
if (typeof namespace === 'string') {
|
|
81999
|
-
namespace = parse(namespace);
|
|
82000
|
-
}
|
|
82001
|
-
|
|
82002
|
-
if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) {
|
|
82003
|
-
throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');
|
|
82004
|
-
} // Compute hash of namespace and value, Per 4.3
|
|
82005
|
-
// Future: Use spread syntax when supported on all platforms, e.g. `bytes =
|
|
82006
|
-
// hashfunc([...namespace, ... value])`
|
|
82007
|
-
|
|
82008
|
-
|
|
82009
|
-
let bytes = new Uint8Array(16 + value.length);
|
|
82010
|
-
bytes.set(namespace);
|
|
82011
|
-
bytes.set(value, namespace.length);
|
|
82012
|
-
bytes = hashfunc(bytes);
|
|
82013
|
-
bytes[6] = bytes[6] & 0x0f | version;
|
|
82014
|
-
bytes[8] = bytes[8] & 0x3f | 0x80;
|
|
82015
|
-
|
|
82016
|
-
if (buf) {
|
|
82017
|
-
offset = offset || 0;
|
|
82018
|
-
|
|
82019
|
-
for (let i = 0; i < 16; ++i) {
|
|
82020
|
-
buf[offset + i] = bytes[i];
|
|
82021
|
-
}
|
|
82022
|
-
|
|
82023
|
-
return buf;
|
|
82024
|
-
}
|
|
82025
|
-
|
|
82026
|
-
return unsafeStringify(bytes);
|
|
82027
|
-
} // Function#name is not settable on some platforms (#270)
|
|
82028
|
-
|
|
82029
|
-
|
|
82030
|
-
try {
|
|
82031
|
-
generateUUID.name = name; // eslint-disable-next-line no-empty
|
|
82032
|
-
} catch (err) {} // For CommonJS default export support
|
|
82033
|
-
|
|
82034
|
-
|
|
82035
|
-
generateUUID.DNS = DNS;
|
|
82036
|
-
generateUUID.URL = URL;
|
|
82037
|
-
return generateUUID;
|
|
82038
|
-
}
|
|
82039
|
-
|
|
82040
|
-
// Adapted from Chris Veness' SHA1 code at
|
|
82041
|
-
// http://www.movable-type.co.uk/scripts/sha1.html
|
|
82042
|
-
function f(s, x, y, z) {
|
|
82043
|
-
switch (s) {
|
|
82044
|
-
case 0:
|
|
82045
|
-
return x & y ^ ~x & z;
|
|
82046
|
-
|
|
82047
|
-
case 1:
|
|
82048
|
-
return x ^ y ^ z;
|
|
82049
|
-
|
|
82050
|
-
case 2:
|
|
82051
|
-
return x & y ^ x & z ^ y & z;
|
|
82052
|
-
|
|
82053
|
-
case 3:
|
|
82054
|
-
return x ^ y ^ z;
|
|
82055
|
-
}
|
|
82056
|
-
}
|
|
82057
|
-
|
|
82058
|
-
function ROTL(x, n) {
|
|
82059
|
-
return x << n | x >>> 32 - n;
|
|
82060
|
-
}
|
|
82061
|
-
|
|
82062
|
-
function sha1(bytes) {
|
|
82063
|
-
const K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];
|
|
82064
|
-
const H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
|
|
82065
|
-
|
|
82066
|
-
if (typeof bytes === 'string') {
|
|
82067
|
-
const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
|
|
82068
|
-
|
|
82069
|
-
bytes = [];
|
|
82070
|
-
|
|
82071
|
-
for (let i = 0; i < msg.length; ++i) {
|
|
82072
|
-
bytes.push(msg.charCodeAt(i));
|
|
82073
|
-
}
|
|
82074
|
-
} else if (!Array.isArray(bytes)) {
|
|
82075
|
-
// Convert Array-like to Array
|
|
82076
|
-
bytes = Array.prototype.slice.call(bytes);
|
|
82077
|
-
}
|
|
82078
|
-
|
|
82079
|
-
bytes.push(0x80);
|
|
82080
|
-
const l = bytes.length / 4 + 2;
|
|
82081
|
-
const N = Math.ceil(l / 16);
|
|
82082
|
-
const M = new Array(N);
|
|
82083
|
-
|
|
82084
|
-
for (let i = 0; i < N; ++i) {
|
|
82085
|
-
const arr = new Uint32Array(16);
|
|
82086
|
-
|
|
82087
|
-
for (let j = 0; j < 16; ++j) {
|
|
82088
|
-
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];
|
|
82089
|
-
}
|
|
82090
|
-
|
|
82091
|
-
M[i] = arr;
|
|
82092
|
-
}
|
|
82093
|
-
|
|
82094
|
-
M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32);
|
|
82095
|
-
M[N - 1][14] = Math.floor(M[N - 1][14]);
|
|
82096
|
-
M[N - 1][15] = (bytes.length - 1) * 8 & 0xffffffff;
|
|
82097
|
-
|
|
82098
|
-
for (let i = 0; i < N; ++i) {
|
|
82099
|
-
const W = new Uint32Array(80);
|
|
82100
|
-
|
|
82101
|
-
for (let t = 0; t < 16; ++t) {
|
|
82102
|
-
W[t] = M[i][t];
|
|
82103
|
-
}
|
|
82104
|
-
|
|
82105
|
-
for (let t = 16; t < 80; ++t) {
|
|
82106
|
-
W[t] = ROTL(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1);
|
|
82107
|
-
}
|
|
82108
|
-
|
|
82109
|
-
let a = H[0];
|
|
82110
|
-
let b = H[1];
|
|
82111
|
-
let c = H[2];
|
|
82112
|
-
let d = H[3];
|
|
82113
|
-
let e = H[4];
|
|
82114
|
-
|
|
82115
|
-
for (let t = 0; t < 80; ++t) {
|
|
82116
|
-
const s = Math.floor(t / 20);
|
|
82117
|
-
const T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[t] >>> 0;
|
|
82118
|
-
e = d;
|
|
82119
|
-
d = c;
|
|
82120
|
-
c = ROTL(b, 30) >>> 0;
|
|
82121
|
-
b = a;
|
|
82122
|
-
a = T;
|
|
82123
|
-
}
|
|
82124
|
-
|
|
82125
|
-
H[0] = H[0] + a >>> 0;
|
|
82126
|
-
H[1] = H[1] + b >>> 0;
|
|
82127
|
-
H[2] = H[2] + c >>> 0;
|
|
82128
|
-
H[3] = H[3] + d >>> 0;
|
|
82129
|
-
H[4] = H[4] + e >>> 0;
|
|
82130
|
-
}
|
|
82131
|
-
|
|
82132
|
-
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];
|
|
82133
|
-
}
|
|
82134
|
-
|
|
82135
|
-
const v5 = v35('v5', 0x50, sha1);
|
|
82136
|
-
var uuidv5 = v5;
|
|
82137
|
-
|
|
82138
|
-
const libVersion = "2.24.1" ;
|
|
82161
|
+
const libVersion = "2.25.1" ;
|
|
82139
82162
|
|
|
82140
82163
|
const keysOf = Object.keys;
|
|
82141
82164
|
function isObject(o) {
|
|
@@ -82551,11 +82574,11 @@ class CoveoAnalyticsClient {
|
|
|
82551
82574
|
determineVisitorId() {
|
|
82552
82575
|
return __awaiter(this, void 0, void 0, function* () {
|
|
82553
82576
|
try {
|
|
82554
|
-
return (yield this.storage.getItem('visitorId')) ||
|
|
82577
|
+
return (yield this.storage.getItem('visitorId')) || v4();
|
|
82555
82578
|
}
|
|
82556
82579
|
catch (err) {
|
|
82557
82580
|
console.log('Could not get visitor ID from the current runtime environment storage. Using a random ID instead.', err);
|
|
82558
|
-
return
|
|
82581
|
+
return v4();
|
|
82559
82582
|
}
|
|
82560
82583
|
});
|
|
82561
82584
|
}
|
|
@@ -82601,7 +82624,7 @@ class CoveoAnalyticsClient {
|
|
|
82601
82624
|
get currentVisitorId() {
|
|
82602
82625
|
const visitorId = this.visitorId || this.storage.getItem('visitorId');
|
|
82603
82626
|
if (typeof visitorId !== 'string') {
|
|
82604
|
-
this.setCurrentVisitorId(
|
|
82627
|
+
this.setCurrentVisitorId(v4());
|
|
82605
82628
|
}
|
|
82606
82629
|
return this.visitorId;
|
|
82607
82630
|
}
|
|
@@ -82876,7 +82899,7 @@ class ReactNativeRuntime {
|
|
|
82876
82899
|
token: options.token,
|
|
82877
82900
|
baseUrl: buildBaseUrl(options.endpoint, options.version),
|
|
82878
82901
|
visitorIdProvider: {
|
|
82879
|
-
getCurrentVisitorId: () => __awaiter(this, void 0, void 0, function* () { return (yield this.storage.getItem(visitorIdKey)) ||
|
|
82902
|
+
getCurrentVisitorId: () => __awaiter(this, void 0, void 0, function* () { return (yield this.storage.getItem(visitorIdKey)) || v4(); }),
|
|
82880
82903
|
setCurrentVisitorId: (visitorId) => this.storage.setItem(visitorIdKey, visitorId),
|
|
82881
82904
|
},
|
|
82882
82905
|
});
|
|
@@ -83817,7 +83840,7 @@ const BasePluginEventTypes = {
|
|
|
83817
83840
|
event: 'event',
|
|
83818
83841
|
};
|
|
83819
83842
|
class BasePlugin {
|
|
83820
|
-
constructor({ client, uuidGenerator =
|
|
83843
|
+
constructor({ client, uuidGenerator = v4 }) {
|
|
83821
83844
|
this.actionData = {};
|
|
83822
83845
|
this.client = client;
|
|
83823
83846
|
this.uuidGenerator = uuidGenerator;
|
|
@@ -83897,7 +83920,7 @@ class BasePlugin {
|
|
|
83897
83920
|
const SVCPluginEventTypes = Object.assign({}, BasePluginEventTypes);
|
|
83898
83921
|
const allSVCEventTypes = Object.keys(SVCPluginEventTypes).map((key) => SVCPluginEventTypes[key]);
|
|
83899
83922
|
class SVCPlugin extends BasePlugin {
|
|
83900
|
-
constructor({ client, uuidGenerator =
|
|
83923
|
+
constructor({ client, uuidGenerator = v4 }) {
|
|
83901
83924
|
super({ client, uuidGenerator });
|
|
83902
83925
|
this.ticket = {};
|
|
83903
83926
|
}
|
package/package.json
CHANGED
|
@@ -9,10 +9,10 @@ import * as doNotTrack from '../donottrack';
|
|
|
9
9
|
import {Cookie} from '../cookieutils';
|
|
10
10
|
|
|
11
11
|
const aVisitorId = '123';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
jest.
|
|
15
|
-
|
|
12
|
+
jest.mock('uuid', () => ({
|
|
13
|
+
v4: () => aVisitorId,
|
|
14
|
+
validate: jest.requireActual('uuid').validate,
|
|
15
|
+
v5: jest.requireActual('uuid').v5,
|
|
16
16
|
}));
|
|
17
17
|
|
|
18
18
|
const {fetchMock, fetchMockBeforeEach} = mockFetch();
|
|
@@ -49,7 +49,6 @@ describe('Analytics', () => {
|
|
|
49
49
|
new CookieStorage().removeItem('visitorId');
|
|
50
50
|
localStorage.clear();
|
|
51
51
|
fetchMock.reset();
|
|
52
|
-
uuidv4Mock.mockImplementationOnce(() => aVisitorId);
|
|
53
52
|
|
|
54
53
|
client = new CoveoAnalyticsClient({
|
|
55
54
|
token: aToken,
|
package/src/client/analytics.ts
CHANGED
|
@@ -22,8 +22,7 @@ import {IAnalyticsClientOptions, PreprocessAnalyticsRequest, VisitorIdProvider}
|
|
|
22
22
|
import {hasWindow, hasDocument} from '../detector';
|
|
23
23
|
import {addDefaultValues} from '../hook/addDefaultValues';
|
|
24
24
|
import {enhanceViewEvent} from '../hook/enhanceViewEvent';
|
|
25
|
-
import {uuidv4} from '
|
|
26
|
-
import {v5 as uuidv5, validate as uuidValidate} from 'uuid';
|
|
25
|
+
import {v4 as uuidv4, v5 as uuidv5, validate as uuidValidate} from 'uuid';
|
|
27
26
|
import {libVersion} from '../version';
|
|
28
27
|
import {
|
|
29
28
|
convertKeysToMeasurementProtocol,
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import coveoua from './simpleanalytics';
|
|
2
2
|
import {createAnalyticsClientMock, visitorIdMock} from '../../tests/analyticsClientMock';
|
|
3
3
|
import {TestPlugin} from '../../tests/pluginMock';
|
|
4
|
-
import {uuidv4} from '
|
|
4
|
+
import {v4 as uuidv4} from 'uuid';
|
|
5
5
|
import {PluginOptions} from '../plugins/BasePlugin';
|
|
6
6
|
import {mockFetch} from '../../tests/fetchMock';
|
|
7
7
|
import {CookieStorage} from '../storage';
|
|
8
8
|
import {libVersion} from '../version';
|
|
9
9
|
|
|
10
10
|
const uuidv4Mock = jest.fn();
|
|
11
|
-
jest.mock('
|
|
12
|
-
uuidv4: () => uuidv4Mock(),
|
|
13
|
-
}));
|
|
11
|
+
jest.mock('uuid', () => ({v4: () => uuidv4Mock()}));
|
|
14
12
|
|
|
15
13
|
const {fetchMock, fetchMockBeforeEach} = mockFetch();
|
|
16
14
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {AnalyticsClient} from '../client/analytics';
|
|
2
|
-
import {uuidv4} from '
|
|
2
|
+
import {v4 as uuidv4} from 'uuid';
|
|
3
3
|
import {getFormattedLocation} from '../client/location';
|
|
4
|
-
import {UAPluginOptions} from '../coveoua/plugins';
|
|
5
4
|
import {hasDocument} from '../detector';
|
|
6
5
|
|
|
7
6
|
type PluginWithId = {
|
|
@@ -67,7 +66,7 @@ export abstract class BasePlugin {
|
|
|
67
66
|
public getDefaultContextInformation(eventType: string) {
|
|
68
67
|
const documentContext = {
|
|
69
68
|
title: hasDocument() ? document.title : '',
|
|
70
|
-
encoding: hasDocument() ? document.characterSet :'UTF-8',
|
|
69
|
+
encoding: hasDocument() ? document.characterSet : 'UTF-8',
|
|
71
70
|
};
|
|
72
71
|
const screenContext = {
|
|
73
72
|
screenResolution: `${screen.width}x${screen.height}`,
|
|
@@ -103,7 +102,7 @@ export abstract class BasePlugin {
|
|
|
103
102
|
}
|
|
104
103
|
|
|
105
104
|
/*
|
|
106
|
-
When calling getPayload or getParameters, we need to return what would be sent by the API without updating our internal reference.
|
|
105
|
+
When calling getPayload or getParameters, we need to return what would be sent by the API without updating our internal reference.
|
|
107
106
|
For instance, if you getPayload("pageview"), we want to return the same payload as if you did coveoua("send", "pageview").
|
|
108
107
|
*/
|
|
109
108
|
private getNextValues(eventType: string, payload: any) {
|
package/src/plugins/ec.spec.ts
CHANGED
|
@@ -25,7 +25,7 @@ describe('EC plugin', () => {
|
|
|
25
25
|
beforeEach(() => {
|
|
26
26
|
jest.clearAllMocks();
|
|
27
27
|
client = createAnalyticsClientMock();
|
|
28
|
-
ec = new ECPlugin({client, uuidGenerator: someUUIDGenerator});
|
|
28
|
+
ec = new ECPlugin({client, uuidGenerator: someUUIDGenerator as any});
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
it('should register a hook in the client', () => {
|
package/src/plugins/ec.ts
CHANGED