coveo.analytics 2.30.56 → 2.32.0
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/README.md +37 -43
- package/dist/browser.mjs +513 -357
- package/dist/coveoua.browser.js +1 -1
- package/dist/coveoua.browser.js.map +1 -1
- package/dist/coveoua.debug.js +542 -359
- 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 -2
- package/dist/definitions/client/runtimeEnvironment.d.ts +1 -1
- package/dist/definitions/donottrack.d.ts +1 -0
- package/dist/definitions/react-native/index.d.ts +1 -2
- package/dist/definitions/version.d.ts +1 -1
- package/dist/library.cjs +15350 -3699
- package/dist/library.es.js +513 -357
- package/dist/library.js +15350 -3699
- package/dist/library.mjs +15350 -3699
- package/dist/react-native.es.js +634 -460
- package/modules/package.json +9 -9
- package/package.json +60 -91
- package/react-native/package.json +7 -7
- package/src/caseAssist/caseAssistActions.ts +51 -50
- package/src/caseAssist/caseAssistClient.spec.ts +328 -297
- package/src/caseAssist/caseAssistClient.ts +201 -185
- package/src/client/analytics.spec.ts +724 -703
- package/src/client/analytics.ts +677 -602
- package/src/client/analyticsBeaconClient.spec.ts +195 -188
- package/src/client/analyticsBeaconClient.ts +99 -88
- package/src/client/analyticsFetchClient.ts +77 -61
- package/src/client/analyticsRequestClient.ts +17 -17
- package/src/client/location.ts +3 -3
- package/src/client/measurementProtocolMapper.ts +54 -45
- package/src/client/measurementProtocolMapping/baseMeasurementProtocolMapper.ts +48 -44
- package/src/client/measurementProtocolMapping/commerceMeasurementProtocolMapper.ts +133 -121
- package/src/client/measurementProtocolMapping/serviceMeasurementProtocolMapper.ts +17 -17
- package/src/client/noopAnalytics.ts +80 -68
- package/src/client/runtimeEnvironment.ts +50 -41
- package/src/client/utils.spec.ts +112 -97
- package/src/client/utils.ts +39 -39
- package/src/cookieutils.spec.ts +59 -0
- package/src/cookieutils.ts +40 -39
- package/src/coveoua/browser.ts +14 -12
- package/src/coveoua/library.ts +4 -4
- package/src/coveoua/plugins.ts +36 -34
- package/src/coveoua/simpleanalytics.spec.ts +467 -452
- package/src/coveoua/simpleanalytics.ts +146 -140
- package/src/detector.ts +17 -17
- package/src/donottrack.spec.ts +199 -121
- package/src/donottrack.ts +31 -8
- package/src/events.ts +86 -79
- package/src/formatting/format-array-for-coveo-custom-data.spec.ts +13 -12
- package/src/formatting/format-array-for-coveo-custom-data.ts +18 -18
- package/src/formatting/format-omnibox-metadata.ts +16 -12
- package/src/history.spec.ts +197 -195
- package/src/history.ts +143 -133
- package/src/hook/addDefaultValues.ts +13 -8
- package/src/hook/enhanceViewEvent.ts +17 -17
- package/src/insight/insightClient.spec.ts +1848 -1717
- package/src/insight/insightClient.ts +866 -761
- package/src/insight/insightEvents.ts +57 -56
- package/src/plugins/BasePlugin.ts +125 -121
- package/src/plugins/ec.spec.ts +457 -429
- package/src/plugins/ec.ts +202 -199
- package/src/plugins/link.spec.ts +183 -159
- package/src/plugins/link.ts +88 -85
- package/src/plugins/svc.spec.ts +161 -155
- package/src/plugins/svc.ts +93 -91
- package/src/react-native/index.ts +8 -1
- package/src/react-native/react-native-runtime.ts +33 -33
- package/src/react-native/react-native-utils.ts +1 -1
- package/src/react-native/react-native.spec.ts +31 -21
- package/src/searchPage/searchPageClient.spec.ts +1944 -1794
- package/src/searchPage/searchPageClient.ts +1261 -1040
- package/src/searchPage/searchPageEvents.ts +524 -511
- package/src/storage.spec.ts +51 -51
- package/src/storage.ts +47 -47
- package/dist/definitions/bundle/browser-fetch.d.ts +0 -1
- package/dist/definitions/src/coveoua/browser.d.ts +0 -6
- package/dist/definitions/src/coveoua/headless.d.ts +0 -6
- package/dist/definitions/src/coveoua/library.d.ts +0 -17
- package/dist/definitions/src/coveoua/plugins.d.ts +0 -10
- package/dist/definitions/src/coveoua/simpleanalytics.d.ts +0 -33
- package/dist/definitions/src/react-native/index.d.ts +0 -3
- package/dist/definitions/src/react-native/react-native-runtime.d.ts +0 -19
package/src/storage.spec.ts
CHANGED
|
@@ -2,69 +2,69 @@ import {CookieStorage, CookieAndLocalStorage} from './storage';
|
|
|
2
2
|
import {Cookie} from './cookieutils';
|
|
3
3
|
|
|
4
4
|
describe('CookieStorage', () => {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const key = 'wow';
|
|
6
|
+
const someData = 'something';
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
it('setItem writes data to a cookie', () => {
|
|
9
|
+
const storage = new CookieStorage();
|
|
10
|
+
storage.setItem(key, someData);
|
|
11
|
+
expect(storage.getItem(key)).toBe(someData);
|
|
12
|
+
});
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
it('removeItem removes the cookie', () => {
|
|
15
|
+
const storage = new CookieStorage();
|
|
16
|
+
storage.setItem(key, someData);
|
|
17
|
+
storage.removeItem(key);
|
|
18
|
+
expect(storage.getItem(key)).toBe(null);
|
|
19
|
+
});
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
it('honors expiration date', async () => {
|
|
22
|
+
const storage = new CookieStorage();
|
|
23
|
+
storage.setItem(key, someData, 1000);
|
|
24
|
+
await new Promise((res) => setTimeout(res, 1000)); // wait for 1 sec
|
|
25
|
+
expect(storage.getItem(key)).toBe(null);
|
|
26
|
+
});
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
describe('CookieAndLocalStorage', () => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
const key = 'hello';
|
|
31
|
+
const someData = 'world';
|
|
32
|
+
let storage: CookieAndLocalStorage;
|
|
33
|
+
let cookie: CookieStorage;
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
beforeEach(() => {
|
|
36
|
+
storage = new CookieAndLocalStorage();
|
|
37
|
+
cookie = new CookieStorage();
|
|
38
|
+
});
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
it('setItem writes data to a cookie and local storage', () => {
|
|
41
|
+
storage.setItem(key, someData);
|
|
42
|
+
expect(cookie.getItem(key)).toBe(someData);
|
|
43
|
+
expect(localStorage.getItem(key)).toBe(someData);
|
|
44
|
+
});
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
it('removeItem removes the cookie and local storage', () => {
|
|
47
|
+
storage.setItem(key, someData);
|
|
48
|
+
storage.removeItem(key);
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
expect(storage.getItem(key)).toBe(null);
|
|
51
|
+
expect(cookie.getItem(key)).toBe(null);
|
|
52
|
+
expect(localStorage.getItem(key)).toBe(null);
|
|
53
|
+
});
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
it('get item uses local storage first', () => {
|
|
56
|
+
cookie.setItem(key, 'fail');
|
|
57
|
+
localStorage.setItem(key, someData);
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
storage.getItem(key);
|
|
60
|
+
expect(storage.getItem(key)).toBe(someData);
|
|
61
|
+
});
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
it('get item fallback on cookie storage if absent from local storage', () => {
|
|
64
|
+
localStorage.setItem(key, '');
|
|
65
|
+
cookie.setItem(key, someData);
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
storage.getItem(key);
|
|
68
|
+
expect(storage.getItem(key)).toBe(someData);
|
|
69
|
+
});
|
|
70
70
|
});
|
package/src/storage.ts
CHANGED
|
@@ -4,66 +4,66 @@ import {Cookie} from './cookieutils';
|
|
|
4
4
|
export let preferredStorage: WebStorage | null = null;
|
|
5
5
|
|
|
6
6
|
export interface WebStorage {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
getItem(key: string): string | null | Promise<string | null>;
|
|
8
|
+
removeItem(key: string): void;
|
|
9
|
+
setItem(key: string, data: string): void | Promise<void>;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export function getAvailableStorage(): WebStorage {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
13
|
+
if (preferredStorage) {
|
|
14
|
+
return preferredStorage;
|
|
15
|
+
}
|
|
16
|
+
if (detector.hasLocalStorage()) {
|
|
17
|
+
return localStorage;
|
|
18
|
+
}
|
|
19
|
+
if (detector.hasCookieStorage()) {
|
|
20
|
+
return new CookieStorage();
|
|
21
|
+
}
|
|
22
|
+
if (detector.hasSessionStorage()) {
|
|
23
|
+
return sessionStorage;
|
|
24
|
+
}
|
|
25
|
+
return new NullStorage();
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export class CookieStorage implements WebStorage {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
static prefix = 'coveo_';
|
|
30
|
+
getItem(key: string): string | null {
|
|
31
|
+
return Cookie.get(`${CookieStorage.prefix}${key}`);
|
|
32
|
+
}
|
|
33
|
+
removeItem(key: string) {
|
|
34
|
+
Cookie.erase(`${CookieStorage.prefix}${key}`);
|
|
35
|
+
}
|
|
36
|
+
setItem(key: string, data: string, expire?: number): void {
|
|
37
|
+
Cookie.set(`${CookieStorage.prefix}${key}`, data, expire);
|
|
38
|
+
}
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
export class CookieAndLocalStorage implements WebStorage {
|
|
42
|
-
|
|
42
|
+
private cookieStorage = new CookieStorage();
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
getItem(key: string): string | null {
|
|
45
|
+
return localStorage.getItem(key) || this.cookieStorage.getItem(key);
|
|
46
|
+
}
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
removeItem(key: string): void {
|
|
49
|
+
this.cookieStorage.removeItem(key);
|
|
50
|
+
localStorage.removeItem(key);
|
|
51
|
+
}
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
setItem(key: string, data: string): void {
|
|
54
|
+
localStorage.setItem(key, data);
|
|
55
|
+
this.cookieStorage.setItem(key, data, 31556926000); // 1 year first party cookie
|
|
56
|
+
}
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
export class NullStorage implements WebStorage {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
60
|
+
getItem(key: string): string | null {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
removeItem(key: string) {
|
|
64
|
+
/**/
|
|
65
|
+
}
|
|
66
|
+
setItem(key: string, data: string): void {
|
|
67
|
+
/**/
|
|
68
|
+
}
|
|
69
69
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const fetch: typeof globalThis.fetch;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { CoveoSearchPageClient, SearchPageClientProvider } from '../searchPage/searchPageClient';
|
|
2
|
-
export { CaseAssistClient, CaseAssistClientProvider } from '../caseAssist/caseAssistClient';
|
|
3
|
-
export { CoveoInsightClient, InsightClientProvider } from '../insight/insightClient';
|
|
4
|
-
export { CoveoAnalyticsClient, AnalyticsClientSendEventHook } from '../client/analytics';
|
|
5
|
-
export { PreprocessAnalyticsRequest } from '../client/analyticsRequestClient';
|
|
6
|
-
export * as history from '../history';
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import * as analytics from '../client/analytics';
|
|
2
|
-
import * as donottrack from '../donottrack';
|
|
3
|
-
import * as history from '../history';
|
|
4
|
-
import * as SimpleAnalytics from './simpleanalytics';
|
|
5
|
-
import * as storage from '../storage';
|
|
6
|
-
export { CoveoAnalyticsClient, AnalyticsClientSendEventHook } from '../client/analytics';
|
|
7
|
-
export { PreprocessAnalyticsRequest } from '../client/analyticsRequestClient';
|
|
8
|
-
export { IRuntimeEnvironment } from '../client/runtimeEnvironment';
|
|
9
|
-
export { CoveoUA, getCurrentClient, handleOneAnalyticsEvent } from './simpleanalytics';
|
|
10
|
-
export { CoveoSearchPageClient, SearchPageClientProvider, EventDescription, EventBuilder, } from '../searchPage/searchPageClient';
|
|
11
|
-
export { CaseAssistClient, CaseAssistClientProvider } from '../caseAssist/caseAssistClient';
|
|
12
|
-
export { CoveoInsightClient, InsightClientProvider } from '../insight/insightClient';
|
|
13
|
-
export * from '../searchPage/searchPageEvents';
|
|
14
|
-
export * from '../caseAssist/caseAssistActions';
|
|
15
|
-
export * from '../insight/insightEvents';
|
|
16
|
-
export * from '../events';
|
|
17
|
-
export { analytics, donottrack, history, SimpleAnalytics, storage };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { PluginClass, PluginOptions } from '../plugins/BasePlugin';
|
|
2
|
-
export declare class Plugins {
|
|
3
|
-
static readonly DefaultPlugins: string[];
|
|
4
|
-
private registeredPluginsMap;
|
|
5
|
-
private requiredPlugins;
|
|
6
|
-
require(name: string, options: PluginOptions): void;
|
|
7
|
-
provide(name: string, plugin: PluginClass): void;
|
|
8
|
-
clearRequired(): void;
|
|
9
|
-
execute(name: string, fn: string, ...args: any[]): any;
|
|
10
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { AnyEventResponse, SendEventArguments } from '../events';
|
|
2
|
-
import { AnalyticsClient } from '../client/analytics';
|
|
3
|
-
import { PluginOptions } from '../plugins/BasePlugin';
|
|
4
|
-
import { PluginClass } from '../plugins/BasePlugin';
|
|
5
|
-
export type AvailableActions = keyof CoveoUA;
|
|
6
|
-
export interface CoveoUAOptions {
|
|
7
|
-
endpoint?: string;
|
|
8
|
-
isCustomEndpoint?: boolean;
|
|
9
|
-
plugins?: string[];
|
|
10
|
-
}
|
|
11
|
-
export declare class CoveoUA {
|
|
12
|
-
client?: AnalyticsClient;
|
|
13
|
-
private plugins;
|
|
14
|
-
private params;
|
|
15
|
-
init(token: string | AnalyticsClient, optionsOrEndpoint: string | CoveoUAOptions): void;
|
|
16
|
-
private isAnalyticsClient;
|
|
17
|
-
private getPluginKeys;
|
|
18
|
-
private getEndpoint;
|
|
19
|
-
private getIsCustomEndpoint;
|
|
20
|
-
initForProxy(endpoint: string, isCustomEndpoint?: boolean): void;
|
|
21
|
-
set(keyOrObject: string | any, value: string): void;
|
|
22
|
-
send(...[event, ...payload]: SendEventArguments): Promise<AnyEventResponse | void>;
|
|
23
|
-
onLoad(callback: Function): void;
|
|
24
|
-
provide(name: string, plugin: PluginClass): void;
|
|
25
|
-
require(name: string, options: Omit<PluginOptions, 'client'>): void;
|
|
26
|
-
callPlugin(pluginName: string, fn: string, ...args: any): any;
|
|
27
|
-
reset(): void;
|
|
28
|
-
version(): string;
|
|
29
|
-
}
|
|
30
|
-
export declare const coveoua: CoveoUA;
|
|
31
|
-
export declare const getCurrentClient: () => AnalyticsClient | undefined;
|
|
32
|
-
export declare const handleOneAnalyticsEvent: (command: string, ...params: any[]) => any;
|
|
33
|
-
export default handleOneAnalyticsEvent;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { WebStorage } from '../storage';
|
|
2
|
-
import { AnalyticsFetchClient } from '../client/analyticsFetchClient';
|
|
3
|
-
import { IRuntimeEnvironment } from '../client/runtimeEnvironment';
|
|
4
|
-
import { PreprocessAnalyticsRequest } from '../client/analyticsRequestClient';
|
|
5
|
-
export type ReactNativeStorage = WebStorage;
|
|
6
|
-
export interface ReactNativeRuntimeOptions {
|
|
7
|
-
storage: ReactNativeStorage;
|
|
8
|
-
visitorIdKey?: string;
|
|
9
|
-
token?: string;
|
|
10
|
-
version?: string;
|
|
11
|
-
endpoint?: string;
|
|
12
|
-
preprocessRequest?: PreprocessAnalyticsRequest;
|
|
13
|
-
}
|
|
14
|
-
export declare class ReactNativeRuntime implements IRuntimeEnvironment {
|
|
15
|
-
client: AnalyticsFetchClient;
|
|
16
|
-
storage: ReactNativeStorage;
|
|
17
|
-
constructor(options: ReactNativeRuntimeOptions);
|
|
18
|
-
getClientDependingOnEventType(): AnalyticsFetchClient;
|
|
19
|
-
}
|