coveo.analytics 2.23.9 → 2.24.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 +306 -27
- package/dist/coveoua.debug.js.map +1 -1
- package/dist/coveoua.js +1 -1
- package/dist/coveoua.js.map +1 -1
- package/dist/definitions/client/analytics.d.ts +3 -0
- package/dist/definitions/client/noopAnalytics.d.ts +1 -0
- package/dist/definitions/cookieutils.d.ts +1 -1
- package/dist/definitions/coveoua/simpleanalytics.d.ts +1 -0
- package/dist/definitions/insight/insightClient.d.ts +6 -1
- package/dist/definitions/insight/insightEvents.d.ts +17 -1
- package/dist/definitions/src/coveoua/simpleanalytics.d.ts +1 -0
- package/dist/definitions/storage.d.ts +1 -1
- package/dist/definitions/version.d.ts +1 -0
- package/dist/library.es.js +286 -25
- package/dist/library.js +300 -24
- package/dist/react-native.es.js +81793 -28
- package/package.json +5 -2
- package/src/client/analytics.spec.ts +38 -7
- package/src/client/analytics.ts +22 -0
- package/src/client/analyticsBeaconClient.spec.ts +1 -1
- package/src/client/noopAnalytics.ts +4 -0
- package/src/cookieutils.ts +21 -42
- package/src/coveoua/browser.ts +2 -2
- package/src/coveoua/plugins.ts +1 -1
- package/src/coveoua/simpleanalytics.spec.ts +9 -1
- package/src/coveoua/simpleanalytics.ts +6 -0
- package/src/insight/insightClient.spec.ts +42 -0
- package/src/insight/insightClient.ts +31 -0
- package/src/insight/insightEvents.ts +33 -0
- package/src/searchPage/searchPageEvents.ts +5 -0
- package/src/storage.spec.ts +8 -0
- package/src/storage.ts +3 -3
- package/src/version.ts +1 -0
|
@@ -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;
|
|
@@ -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,7 +1,7 @@
|
|
|
1
1
|
import { AnalyticsClient, ClientOptions } from '../client/analytics';
|
|
2
2
|
import { SearchEventRequest } from '../events';
|
|
3
3
|
import { DocumentIdentifier, FacetStateMetadata, PartialDocumentInformation, SearchPageEvents } from '../searchPage/searchPageEvents';
|
|
4
|
-
import { ExpandToFullUIMetadata, InsightEvents, InsightFacetMetadata, InsightInterfaceChangeMetadata, InsightStaticFilterToggleValueMetadata, InsightFacetRangeMetadata, InsightCategoryFacetMetadata, CaseMetadata, InsightFacetSortMeta, InsightFacetBaseMeta, InsightQueryErrorMeta, InsightPagerMetadata, InsightResultsSortMetadata } from './insightEvents';
|
|
4
|
+
import { ExpandToFullUIMetadata, InsightEvents, InsightFacetMetadata, InsightInterfaceChangeMetadata, InsightStaticFilterToggleValueMetadata, InsightFacetRangeMetadata, InsightCategoryFacetMetadata, CaseMetadata, InsightFacetSortMeta, InsightFacetBaseMeta, InsightQueryErrorMeta, InsightPagerMetadata, InsightResultsSortMetadata, UserActionsDocumentMetadata, UserActionsPageViewMetadata } from './insightEvents';
|
|
5
5
|
export interface InsightClientProvider {
|
|
6
6
|
getSearchEventRequestPayload: () => Omit<SearchEventRequest, 'actionCause' | 'searchQueryUid'>;
|
|
7
7
|
getSearchUID: () => string;
|
|
@@ -47,6 +47,11 @@ export declare class CoveoInsightClient {
|
|
|
47
47
|
logSearchboxSubmit(metadata?: CaseMetadata): Promise<void | import("../events").SearchEventResponse>;
|
|
48
48
|
logContextChanged(metadata: CaseMetadata): Promise<void | import("../events").SearchEventResponse>;
|
|
49
49
|
logExpandToFullUI(metadata: ExpandToFullUIMetadata): Promise<void | import("../events").CustomEventResponse>;
|
|
50
|
+
logOpenUserActions(metadata: CaseMetadata): Promise<void | import("../events").CustomEventResponse>;
|
|
51
|
+
logShowPrecedingSessions(metadata: CaseMetadata): Promise<void | import("../events").CustomEventResponse>;
|
|
52
|
+
logShowFollowingSessions(metadata: CaseMetadata): Promise<void | import("../events").CustomEventResponse>;
|
|
53
|
+
logViewedDocumentClick(document: UserActionsDocumentMetadata, metadata: CaseMetadata): Promise<void | import("../events").CustomEventResponse>;
|
|
54
|
+
logPageViewClick(pageView: UserActionsPageViewMetadata, metadata: CaseMetadata): Promise<void | import("../events").CustomEventResponse>;
|
|
50
55
|
logDocumentOpen(info: PartialDocumentInformation, identifier: DocumentIdentifier, metadata?: CaseMetadata): Promise<void | import("../events").ClickEventResponse>;
|
|
51
56
|
logCopyToClipboard(info: PartialDocumentInformation, identifier: DocumentIdentifier, metadata?: CaseMetadata): Promise<void | import("../events").ClickEventResponse>;
|
|
52
57
|
logDocumentQuickview(info: PartialDocumentInformation, identifier: DocumentIdentifier, caseMetadata?: CaseMetadata): Promise<void | import("../events").ClickEventResponse>;
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { CategoryFacetMetadata, FacetBaseMeta, FacetMetadata, FacetRangeMetadata, FacetSortMeta, InterfaceChangeMetadata, PagerMetadata, QueryErrorMeta, ResultsSortMetadata, StaticFilterToggleValueMetadata } from '../searchPage/searchPageEvents';
|
|
2
2
|
export declare enum InsightEvents {
|
|
3
3
|
contextChanged = "contextChanged",
|
|
4
|
-
expandToFullUI = "expandToFullUI"
|
|
4
|
+
expandToFullUI = "expandToFullUI",
|
|
5
|
+
openUserActions = "openUserActions",
|
|
6
|
+
showPrecedingSessions = "showPrecedingSessions",
|
|
7
|
+
showFollowingSessions = "showFollowingSessions",
|
|
8
|
+
clickViewedDocument = "clickViewedDocument",
|
|
9
|
+
clickPageView = "clickPageView"
|
|
5
10
|
}
|
|
6
11
|
export interface CaseMetadata {
|
|
7
12
|
caseId?: string;
|
|
@@ -12,6 +17,17 @@ export interface ExpandToFullUIMetadata extends CaseMetadata {
|
|
|
12
17
|
fullSearchComponentName: string;
|
|
13
18
|
triggeredBy: string;
|
|
14
19
|
}
|
|
20
|
+
export interface UserActionsDocumentMetadata {
|
|
21
|
+
title: string;
|
|
22
|
+
uri: string;
|
|
23
|
+
uriHash?: string;
|
|
24
|
+
permanentId?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface UserActionsPageViewMetadata {
|
|
27
|
+
title: string;
|
|
28
|
+
contentIdKey: string;
|
|
29
|
+
contentIdValue: string;
|
|
30
|
+
}
|
|
15
31
|
export interface InsightInterfaceChangeMetadata extends InterfaceChangeMetadata, CaseMetadata {
|
|
16
32
|
}
|
|
17
33
|
export interface InsightFacetMetadata extends FacetMetadata, CaseMetadata {
|
|
@@ -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.24.1";
|
package/dist/library.es.js
CHANGED
|
@@ -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
|
|
@@ -86,29 +86,20 @@ const addDefaultValues = (eventType, payload) => {
|
|
|
86
86
|
};
|
|
87
87
|
|
|
88
88
|
class Cookie {
|
|
89
|
-
static set(name, value,
|
|
90
|
-
var domain,
|
|
91
|
-
if (
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
expires = '; expires=' + date.toGMTString();
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
expires = '';
|
|
89
|
+
static set(name, value, expire) {
|
|
90
|
+
var domain, expirationDate, domainParts, host;
|
|
91
|
+
if (expire) {
|
|
92
|
+
expirationDate = new Date();
|
|
93
|
+
expirationDate.setTime(expirationDate.getTime() + expire);
|
|
98
94
|
}
|
|
99
95
|
host = window.location.hostname;
|
|
100
96
|
if (host.indexOf('.') === -1) {
|
|
101
|
-
|
|
97
|
+
writeCookie(name, value, expirationDate);
|
|
102
98
|
}
|
|
103
99
|
else {
|
|
104
100
|
domainParts = host.split('.');
|
|
105
|
-
domainParts.
|
|
106
|
-
|
|
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
|
-
}
|
|
101
|
+
domain = domainParts[domainParts.length - 2] + '.' + domainParts[domainParts.length - 1];
|
|
102
|
+
writeCookie(name, value, expirationDate, domain);
|
|
112
103
|
}
|
|
113
104
|
}
|
|
114
105
|
static get(name) {
|
|
@@ -117,7 +108,7 @@ class Cookie {
|
|
|
117
108
|
for (var i = 0; i < cookieArray.length; i++) {
|
|
118
109
|
var cookie = cookieArray[i];
|
|
119
110
|
cookie = cookie.replace(/^\s+/, '');
|
|
120
|
-
if (cookie.
|
|
111
|
+
if (cookie.lastIndexOf(cookiePrefix, 0) === 0) {
|
|
121
112
|
return cookie.substring(cookiePrefix.length, cookie.length);
|
|
122
113
|
}
|
|
123
114
|
}
|
|
@@ -127,9 +118,12 @@ class Cookie {
|
|
|
127
118
|
Cookie.set(name, '', -1);
|
|
128
119
|
}
|
|
129
120
|
}
|
|
130
|
-
function writeCookie(
|
|
131
|
-
|
|
132
|
-
|
|
121
|
+
function writeCookie(name, value, expirationDate, domain) {
|
|
122
|
+
document.cookie =
|
|
123
|
+
`${name}=${value}` +
|
|
124
|
+
(expirationDate ? `;expires=${expirationDate.toUTCString()}` : '') +
|
|
125
|
+
(domain ? `;domain=${domain}` : '') +
|
|
126
|
+
';SameSite=Lax';
|
|
133
127
|
}
|
|
134
128
|
|
|
135
129
|
function getAvailableStorage() {
|
|
@@ -151,8 +145,8 @@ class CookieStorage {
|
|
|
151
145
|
removeItem(key) {
|
|
152
146
|
Cookie.erase(`${CookieStorage.prefix}${key}`);
|
|
153
147
|
}
|
|
154
|
-
setItem(key, data) {
|
|
155
|
-
Cookie.set(`${CookieStorage.prefix}${key}`, data);
|
|
148
|
+
setItem(key, data, expire) {
|
|
149
|
+
Cookie.set(`${CookieStorage.prefix}${key}`, data, expire);
|
|
156
150
|
}
|
|
157
151
|
}
|
|
158
152
|
CookieStorage.prefix = 'coveo_';
|
|
@@ -169,7 +163,7 @@ class CookieAndLocalStorage {
|
|
|
169
163
|
}
|
|
170
164
|
setItem(key, data) {
|
|
171
165
|
localStorage.setItem(key, data);
|
|
172
|
-
this.cookieStorage.setItem(key, data);
|
|
166
|
+
this.cookieStorage.setItem(key, data, 31556926000);
|
|
173
167
|
}
|
|
174
168
|
}
|
|
175
169
|
class NullStorage {
|
|
@@ -359,6 +353,225 @@ const getRandomValues = (rnds) => {
|
|
|
359
353
|
return rnds;
|
|
360
354
|
};
|
|
361
355
|
|
|
356
|
+
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;
|
|
357
|
+
|
|
358
|
+
function validate(uuid) {
|
|
359
|
+
return typeof uuid === 'string' && REGEX.test(uuid);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Convert array of 16 byte values to UUID string format of the form:
|
|
364
|
+
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
365
|
+
*/
|
|
366
|
+
|
|
367
|
+
const byteToHex = [];
|
|
368
|
+
|
|
369
|
+
for (let i = 0; i < 256; ++i) {
|
|
370
|
+
byteToHex.push((i + 0x100).toString(16).slice(1));
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
function unsafeStringify(arr, offset = 0) {
|
|
374
|
+
// Note: Be careful editing this code! It's been tuned for performance
|
|
375
|
+
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
|
376
|
+
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();
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
function parse(uuid) {
|
|
380
|
+
if (!validate(uuid)) {
|
|
381
|
+
throw TypeError('Invalid UUID');
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
let v;
|
|
385
|
+
const arr = new Uint8Array(16); // Parse ########-....-....-....-............
|
|
386
|
+
|
|
387
|
+
arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
|
|
388
|
+
arr[1] = v >>> 16 & 0xff;
|
|
389
|
+
arr[2] = v >>> 8 & 0xff;
|
|
390
|
+
arr[3] = v & 0xff; // Parse ........-####-....-....-............
|
|
391
|
+
|
|
392
|
+
arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;
|
|
393
|
+
arr[5] = v & 0xff; // Parse ........-....-####-....-............
|
|
394
|
+
|
|
395
|
+
arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;
|
|
396
|
+
arr[7] = v & 0xff; // Parse ........-....-....-####-............
|
|
397
|
+
|
|
398
|
+
arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;
|
|
399
|
+
arr[9] = v & 0xff; // Parse ........-....-....-....-############
|
|
400
|
+
// (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes)
|
|
401
|
+
|
|
402
|
+
arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;
|
|
403
|
+
arr[11] = v / 0x100000000 & 0xff;
|
|
404
|
+
arr[12] = v >>> 24 & 0xff;
|
|
405
|
+
arr[13] = v >>> 16 & 0xff;
|
|
406
|
+
arr[14] = v >>> 8 & 0xff;
|
|
407
|
+
arr[15] = v & 0xff;
|
|
408
|
+
return arr;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
function stringToBytes(str) {
|
|
412
|
+
str = unescape(encodeURIComponent(str)); // UTF8 escape
|
|
413
|
+
|
|
414
|
+
const bytes = [];
|
|
415
|
+
|
|
416
|
+
for (let i = 0; i < str.length; ++i) {
|
|
417
|
+
bytes.push(str.charCodeAt(i));
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
return bytes;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
|
|
424
|
+
const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
|
|
425
|
+
function v35(name, version, hashfunc) {
|
|
426
|
+
function generateUUID(value, namespace, buf, offset) {
|
|
427
|
+
var _namespace;
|
|
428
|
+
|
|
429
|
+
if (typeof value === 'string') {
|
|
430
|
+
value = stringToBytes(value);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
if (typeof namespace === 'string') {
|
|
434
|
+
namespace = parse(namespace);
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) {
|
|
438
|
+
throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');
|
|
439
|
+
} // Compute hash of namespace and value, Per 4.3
|
|
440
|
+
// Future: Use spread syntax when supported on all platforms, e.g. `bytes =
|
|
441
|
+
// hashfunc([...namespace, ... value])`
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
let bytes = new Uint8Array(16 + value.length);
|
|
445
|
+
bytes.set(namespace);
|
|
446
|
+
bytes.set(value, namespace.length);
|
|
447
|
+
bytes = hashfunc(bytes);
|
|
448
|
+
bytes[6] = bytes[6] & 0x0f | version;
|
|
449
|
+
bytes[8] = bytes[8] & 0x3f | 0x80;
|
|
450
|
+
|
|
451
|
+
if (buf) {
|
|
452
|
+
offset = offset || 0;
|
|
453
|
+
|
|
454
|
+
for (let i = 0; i < 16; ++i) {
|
|
455
|
+
buf[offset + i] = bytes[i];
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
return buf;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
return unsafeStringify(bytes);
|
|
462
|
+
} // Function#name is not settable on some platforms (#270)
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
try {
|
|
466
|
+
generateUUID.name = name; // eslint-disable-next-line no-empty
|
|
467
|
+
} catch (err) {} // For CommonJS default export support
|
|
468
|
+
|
|
469
|
+
|
|
470
|
+
generateUUID.DNS = DNS;
|
|
471
|
+
generateUUID.URL = URL;
|
|
472
|
+
return generateUUID;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
// Adapted from Chris Veness' SHA1 code at
|
|
476
|
+
// http://www.movable-type.co.uk/scripts/sha1.html
|
|
477
|
+
function f(s, x, y, z) {
|
|
478
|
+
switch (s) {
|
|
479
|
+
case 0:
|
|
480
|
+
return x & y ^ ~x & z;
|
|
481
|
+
|
|
482
|
+
case 1:
|
|
483
|
+
return x ^ y ^ z;
|
|
484
|
+
|
|
485
|
+
case 2:
|
|
486
|
+
return x & y ^ x & z ^ y & z;
|
|
487
|
+
|
|
488
|
+
case 3:
|
|
489
|
+
return x ^ y ^ z;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
function ROTL(x, n) {
|
|
494
|
+
return x << n | x >>> 32 - n;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
function sha1(bytes) {
|
|
498
|
+
const K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];
|
|
499
|
+
const H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
|
|
500
|
+
|
|
501
|
+
if (typeof bytes === 'string') {
|
|
502
|
+
const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
|
|
503
|
+
|
|
504
|
+
bytes = [];
|
|
505
|
+
|
|
506
|
+
for (let i = 0; i < msg.length; ++i) {
|
|
507
|
+
bytes.push(msg.charCodeAt(i));
|
|
508
|
+
}
|
|
509
|
+
} else if (!Array.isArray(bytes)) {
|
|
510
|
+
// Convert Array-like to Array
|
|
511
|
+
bytes = Array.prototype.slice.call(bytes);
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
bytes.push(0x80);
|
|
515
|
+
const l = bytes.length / 4 + 2;
|
|
516
|
+
const N = Math.ceil(l / 16);
|
|
517
|
+
const M = new Array(N);
|
|
518
|
+
|
|
519
|
+
for (let i = 0; i < N; ++i) {
|
|
520
|
+
const arr = new Uint32Array(16);
|
|
521
|
+
|
|
522
|
+
for (let j = 0; j < 16; ++j) {
|
|
523
|
+
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];
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
M[i] = arr;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32);
|
|
530
|
+
M[N - 1][14] = Math.floor(M[N - 1][14]);
|
|
531
|
+
M[N - 1][15] = (bytes.length - 1) * 8 & 0xffffffff;
|
|
532
|
+
|
|
533
|
+
for (let i = 0; i < N; ++i) {
|
|
534
|
+
const W = new Uint32Array(80);
|
|
535
|
+
|
|
536
|
+
for (let t = 0; t < 16; ++t) {
|
|
537
|
+
W[t] = M[i][t];
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
for (let t = 16; t < 80; ++t) {
|
|
541
|
+
W[t] = ROTL(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1);
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
let a = H[0];
|
|
545
|
+
let b = H[1];
|
|
546
|
+
let c = H[2];
|
|
547
|
+
let d = H[3];
|
|
548
|
+
let e = H[4];
|
|
549
|
+
|
|
550
|
+
for (let t = 0; t < 80; ++t) {
|
|
551
|
+
const s = Math.floor(t / 20);
|
|
552
|
+
const T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[t] >>> 0;
|
|
553
|
+
e = d;
|
|
554
|
+
d = c;
|
|
555
|
+
c = ROTL(b, 30) >>> 0;
|
|
556
|
+
b = a;
|
|
557
|
+
a = T;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
H[0] = H[0] + a >>> 0;
|
|
561
|
+
H[1] = H[1] + b >>> 0;
|
|
562
|
+
H[2] = H[2] + c >>> 0;
|
|
563
|
+
H[3] = H[3] + d >>> 0;
|
|
564
|
+
H[4] = H[4] + e >>> 0;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
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];
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
const v5 = v35('v5', 0x50, sha1);
|
|
571
|
+
var uuidv5 = v5;
|
|
572
|
+
|
|
573
|
+
const libVersion = "2.24.1" ;
|
|
574
|
+
|
|
362
575
|
const keysOf = Object.keys;
|
|
363
576
|
function isObject(o) {
|
|
364
577
|
return o !== null && typeof o === 'object' && !Array.isArray(o);
|
|
@@ -779,6 +992,7 @@ function buildBaseUrl(endpoint = Endpoints.default, apiVersion = Version) {
|
|
|
779
992
|
const endpointIsCoveoProxy = endpoint.indexOf('.cloud.coveo.com') !== -1;
|
|
780
993
|
return `${endpoint}${endpointIsCoveoProxy ? '' : '/rest'}/${apiVersion}`;
|
|
781
994
|
}
|
|
995
|
+
const COVEO_NAMESPACE = '38824e1f-37f5-42d3-8372-a4b8fa9df946';
|
|
782
996
|
class CoveoAnalyticsClient {
|
|
783
997
|
constructor(opts) {
|
|
784
998
|
if (!opts) {
|
|
@@ -811,6 +1025,9 @@ class CoveoAnalyticsClient {
|
|
|
811
1025
|
afterSendHooks: [],
|
|
812
1026
|
};
|
|
813
1027
|
}
|
|
1028
|
+
get version() {
|
|
1029
|
+
return libVersion;
|
|
1030
|
+
}
|
|
814
1031
|
initRuntime(clientsOptions) {
|
|
815
1032
|
if (hasWindow() && hasDocument()) {
|
|
816
1033
|
return new BrowserRuntime(clientsOptions, () => {
|
|
@@ -853,6 +1070,19 @@ class CoveoAnalyticsClient {
|
|
|
853
1070
|
yield this.storage.setItem('visitorId', visitorId);
|
|
854
1071
|
});
|
|
855
1072
|
}
|
|
1073
|
+
setClientId(value, namespace) {
|
|
1074
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1075
|
+
if (validate(value)) {
|
|
1076
|
+
this.setCurrentVisitorId(value);
|
|
1077
|
+
}
|
|
1078
|
+
else {
|
|
1079
|
+
if (!namespace) {
|
|
1080
|
+
throw Error('Cannot generate uuid client id without a specific namespace string.');
|
|
1081
|
+
}
|
|
1082
|
+
this.setCurrentVisitorId(uuidv5(value, uuidv5(namespace, COVEO_NAMESPACE)));
|
|
1083
|
+
}
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
856
1086
|
getParameters(eventType, ...payload) {
|
|
857
1087
|
return __awaiter(this, void 0, void 0, function* () {
|
|
858
1088
|
return yield this.resolveParameters(eventType, ...payload);
|
|
@@ -1136,6 +1366,11 @@ var InsightEvents;
|
|
|
1136
1366
|
(function (InsightEvents) {
|
|
1137
1367
|
InsightEvents["contextChanged"] = "contextChanged";
|
|
1138
1368
|
InsightEvents["expandToFullUI"] = "expandToFullUI";
|
|
1369
|
+
InsightEvents["openUserActions"] = "openUserActions";
|
|
1370
|
+
InsightEvents["showPrecedingSessions"] = "showPrecedingSessions";
|
|
1371
|
+
InsightEvents["showFollowingSessions"] = "showFollowingSessions";
|
|
1372
|
+
InsightEvents["clickViewedDocument"] = "clickViewedDocument";
|
|
1373
|
+
InsightEvents["clickPageView"] = "clickPageView";
|
|
1139
1374
|
})(InsightEvents || (InsightEvents = {}));
|
|
1140
1375
|
|
|
1141
1376
|
var SearchPageEvents;
|
|
@@ -1245,6 +1480,11 @@ const CustomEventsTypes = {
|
|
|
1245
1480
|
[SearchPageEvents.clearRecentResults]: 'recentlyClickedDocuments',
|
|
1246
1481
|
[SearchPageEvents.showLessFoldedResults]: 'folding',
|
|
1247
1482
|
[InsightEvents.expandToFullUI]: 'interface',
|
|
1483
|
+
[InsightEvents.openUserActions]: 'User Actions',
|
|
1484
|
+
[InsightEvents.showPrecedingSessions]: 'User Actions',
|
|
1485
|
+
[InsightEvents.showFollowingSessions]: 'User Actions',
|
|
1486
|
+
[InsightEvents.clickViewedDocument]: 'User Actions',
|
|
1487
|
+
[InsightEvents.clickPageView]: 'User Actions',
|
|
1248
1488
|
[SearchPageEvents.caseDetach]: 'case',
|
|
1249
1489
|
};
|
|
1250
1490
|
|
|
@@ -1298,6 +1538,9 @@ class NoopAnalytics {
|
|
|
1298
1538
|
registerBeforeSendEventHook() { }
|
|
1299
1539
|
registerAfterSendEventHook() { }
|
|
1300
1540
|
addEventTypeMapping() { }
|
|
1541
|
+
get version() {
|
|
1542
|
+
return libVersion;
|
|
1543
|
+
}
|
|
1301
1544
|
}
|
|
1302
1545
|
|
|
1303
1546
|
function filterConsecutiveRepeatedValues(rawData) {
|
|
@@ -2441,6 +2684,24 @@ class CoveoInsightClient {
|
|
|
2441
2684
|
const metadataToSend = generateMetadataToSend(metadata);
|
|
2442
2685
|
return this.logCustomEvent(InsightEvents.expandToFullUI, metadataToSend);
|
|
2443
2686
|
}
|
|
2687
|
+
logOpenUserActions(metadata) {
|
|
2688
|
+
const metadataToSend = generateMetadataToSend(metadata, false);
|
|
2689
|
+
return this.logCustomEvent(InsightEvents.openUserActions, metadataToSend);
|
|
2690
|
+
}
|
|
2691
|
+
logShowPrecedingSessions(metadata) {
|
|
2692
|
+
const metadataToSend = generateMetadataToSend(metadata, false);
|
|
2693
|
+
return this.logCustomEvent(InsightEvents.showPrecedingSessions, metadataToSend);
|
|
2694
|
+
}
|
|
2695
|
+
logShowFollowingSessions(metadata) {
|
|
2696
|
+
const metadataToSend = generateMetadataToSend(metadata, false);
|
|
2697
|
+
return this.logCustomEvent(InsightEvents.showFollowingSessions, metadataToSend);
|
|
2698
|
+
}
|
|
2699
|
+
logViewedDocumentClick(document, metadata) {
|
|
2700
|
+
return this.logCustomEvent(InsightEvents.clickViewedDocument, Object.assign(Object.assign({}, generateMetadataToSend(metadata, false)), { document }));
|
|
2701
|
+
}
|
|
2702
|
+
logPageViewClick(pageView, metadata) {
|
|
2703
|
+
return this.logCustomEvent(InsightEvents.clickPageView, Object.assign(Object.assign({}, generateMetadataToSend(metadata, false)), { pageView }));
|
|
2704
|
+
}
|
|
2444
2705
|
logDocumentOpen(info, identifier, metadata) {
|
|
2445
2706
|
return this.logClickEvent(SearchPageEvents.documentOpen, info, identifier, metadata ? generateMetadataToSend(metadata, false) : undefined);
|
|
2446
2707
|
}
|