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
|
@@ -1,84 +1,85 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
CategoryFacetMetadata,
|
|
3
|
+
FacetBaseMeta,
|
|
4
|
+
FacetMetadata,
|
|
5
|
+
FacetRangeMetadata,
|
|
6
|
+
FacetSortMeta,
|
|
7
|
+
InterfaceChangeMetadata,
|
|
8
|
+
PagerMetadata,
|
|
9
|
+
QueryErrorMeta,
|
|
10
|
+
ResultsSortMetadata,
|
|
11
|
+
StaticFilterToggleValueMetadata,
|
|
12
12
|
} from '../searchPage/searchPageEvents';
|
|
13
13
|
|
|
14
14
|
export enum InsightEvents {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Identifies the search event that gets logged when the query context is updated as a result of updating one of the case context fields.
|
|
17
|
+
*/
|
|
18
|
+
contextChanged = 'contextChanged',
|
|
19
|
+
/**
|
|
20
|
+
* Identifies the event that gets logged when the user opens the full search page from the insight panel.
|
|
21
|
+
*/
|
|
22
|
+
expandToFullUI = 'expandToFullUI',
|
|
23
|
+
/**
|
|
24
|
+
* Identifies the event that gets logged when the user opens the user actions section.
|
|
25
|
+
*/
|
|
26
|
+
openUserActions = 'openUserActions',
|
|
27
|
+
/**
|
|
28
|
+
* Identifies the event that gets logged when the user clicks to view user action sessions preceding the ticket creation.
|
|
29
|
+
*/
|
|
30
|
+
showPrecedingSessions = 'showPrecedingSessions',
|
|
31
|
+
/**
|
|
32
|
+
* Identifies the event that gets logged when the user clicks to view user action sessions following the ticket creation.
|
|
33
|
+
*/
|
|
34
|
+
showFollowingSessions = 'showFollowingSessions',
|
|
35
|
+
/**
|
|
36
|
+
* Identifies the event that gets logged when the user clicks a viewed document link on the user actions timeline.
|
|
37
|
+
*/
|
|
38
|
+
clickViewedDocument = 'clickViewedDocument',
|
|
39
|
+
/**
|
|
40
|
+
* Identifies the event that gets logged when the user clicks a viewed page link on the user actions timeline.
|
|
41
|
+
*/
|
|
42
|
+
clickPageView = 'clickPageView',
|
|
43
|
+
/**
|
|
44
|
+
* Identifies the event that gets logged when the user clicks the create article button.
|
|
45
|
+
*/
|
|
46
|
+
createArticle = 'createArticle',
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
export interface CaseMetadata {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
caseId?: string;
|
|
51
|
+
caseNumber?: string;
|
|
52
|
+
caseContext?: Record<string, string>;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
export interface ExpandToFullUIMetadata extends CaseMetadata {
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
fullSearchComponentName: string;
|
|
57
|
+
triggeredBy: string;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
export interface UserActionsDocumentMetadata {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
title: string;
|
|
62
|
+
uri: string;
|
|
63
|
+
uriHash?: string;
|
|
64
|
+
permanentId?: string;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
export interface UserActionsPageViewMetadata {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
title: string;
|
|
69
|
+
contentIdKey: string;
|
|
70
|
+
contentIdValue: string;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
export interface CreateArticleMetadata {
|
|
74
|
-
|
|
74
|
+
articleType: string;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
export interface InsightInterfaceChangeMetadata extends InterfaceChangeMetadata, CaseMetadata {}
|
|
78
78
|
|
|
79
79
|
export interface InsightFacetMetadata extends FacetMetadata, CaseMetadata {}
|
|
80
80
|
|
|
81
|
-
export interface InsightStaticFilterToggleValueMetadata
|
|
81
|
+
export interface InsightStaticFilterToggleValueMetadata
|
|
82
|
+
extends StaticFilterToggleValueMetadata, CaseMetadata {}
|
|
82
83
|
|
|
83
84
|
export interface InsightFacetRangeMetadata extends FacetRangeMetadata, CaseMetadata {}
|
|
84
85
|
|
|
@@ -4,148 +4,152 @@ import {getFormattedLocation} from '../client/location';
|
|
|
4
4
|
import {hasDocument} from '../detector';
|
|
5
5
|
|
|
6
6
|
type PluginWithId = {
|
|
7
|
-
|
|
7
|
+
readonly Id: string;
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
export type PluginClass = typeof Plugin & PluginWithId;
|
|
11
11
|
export const BasePluginEventTypes = {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
pageview: 'pageview',
|
|
13
|
+
event: 'event',
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
export type PluginOptions = {
|
|
16
|
+
export type PluginOptions = {
|
|
17
|
+
client: AnalyticsClient;
|
|
18
|
+
uuidGenerator?: typeof uuidv4;
|
|
19
|
+
};
|
|
17
20
|
|
|
18
21
|
export abstract class Plugin {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
protected client: AnalyticsClient;
|
|
23
|
+
protected uuidGenerator: typeof uuidv4;
|
|
24
|
+
constructor({client, uuidGenerator = uuidv4}: PluginOptions) {
|
|
25
|
+
this.client = client;
|
|
26
|
+
this.uuidGenerator = uuidGenerator;
|
|
27
|
+
}
|
|
28
|
+
public abstract getApi(name: string): any;
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
export abstract class BasePlugin extends Plugin {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
public setAction(action: string, options?: any) {
|
|
59
|
-
this.action = action;
|
|
60
|
-
this.actionData = options;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
public clearData() {
|
|
64
|
-
this.clearPluginData();
|
|
65
|
-
this.action = undefined;
|
|
66
|
-
this.actionData = {};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
public getLocationInformation(eventType: string, payload: any) {
|
|
70
|
-
return {
|
|
71
|
-
hitType: eventType,
|
|
72
|
-
...this.getNextValues(eventType, payload),
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
protected updateLocationInformation(eventType: string, payload: any) {
|
|
77
|
-
this.updateLocationForNextPageView(eventType, payload);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
public getDefaultContextInformation(eventType: string) {
|
|
81
|
-
const documentContext = {
|
|
82
|
-
title: hasDocument() ? document.title : '',
|
|
83
|
-
encoding: hasDocument() ? document.characterSet : 'UTF-8',
|
|
84
|
-
};
|
|
85
|
-
const screenContext = {
|
|
86
|
-
screenResolution: `${screen.width}x${screen.height}`,
|
|
87
|
-
screenColor: `${screen.colorDepth}-bit`,
|
|
88
|
-
};
|
|
89
|
-
const navigatorContext = {
|
|
90
|
-
language: navigator.language,
|
|
91
|
-
userAgent: navigator.userAgent,
|
|
92
|
-
};
|
|
93
|
-
const eventContext = {
|
|
94
|
-
time: Date.now(),
|
|
95
|
-
eventId: this.uuidGenerator(),
|
|
96
|
-
};
|
|
97
|
-
return {
|
|
98
|
-
...eventContext,
|
|
99
|
-
...screenContext,
|
|
100
|
-
...navigatorContext,
|
|
101
|
-
...documentContext,
|
|
102
|
-
};
|
|
32
|
+
protected action?: string;
|
|
33
|
+
protected actionData: {[name: string]: string} = {};
|
|
34
|
+
private pageViewId: string;
|
|
35
|
+
private nextPageViewId: string;
|
|
36
|
+
private hasSentFirstPageView?: boolean;
|
|
37
|
+
private currentLocation: string;
|
|
38
|
+
private lastReferrer: string;
|
|
39
|
+
|
|
40
|
+
constructor({client, uuidGenerator = uuidv4}: PluginOptions) {
|
|
41
|
+
super({client, uuidGenerator});
|
|
42
|
+
this.pageViewId = uuidGenerator();
|
|
43
|
+
this.nextPageViewId = this.pageViewId;
|
|
44
|
+
this.currentLocation = getFormattedLocation(window.location);
|
|
45
|
+
this.lastReferrer = hasDocument() ? document.referrer : '';
|
|
46
|
+
|
|
47
|
+
this.addHooks();
|
|
48
|
+
}
|
|
49
|
+
protected abstract addHooks(): void;
|
|
50
|
+
protected abstract clearPluginData(): void;
|
|
51
|
+
|
|
52
|
+
public getApi(name: string): Function | null {
|
|
53
|
+
switch (name) {
|
|
54
|
+
case 'setAction':
|
|
55
|
+
return this.setAction;
|
|
56
|
+
default:
|
|
57
|
+
return null;
|
|
103
58
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public setAction(action: string, options?: any) {
|
|
62
|
+
this.action = action;
|
|
63
|
+
this.actionData = options;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public clearData() {
|
|
67
|
+
this.clearPluginData();
|
|
68
|
+
this.action = undefined;
|
|
69
|
+
this.actionData = {};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
public getLocationInformation(eventType: string, payload: any) {
|
|
73
|
+
return {
|
|
74
|
+
hitType: eventType,
|
|
75
|
+
...this.getNextValues(eventType, payload),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
protected updateLocationInformation(eventType: string, payload: any) {
|
|
80
|
+
this.updateLocationForNextPageView(eventType, payload);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
public getDefaultContextInformation(eventType: string) {
|
|
84
|
+
const documentContext = {
|
|
85
|
+
title: hasDocument() ? document.title : '',
|
|
86
|
+
encoding: hasDocument() ? document.characterSet : 'UTF-8',
|
|
87
|
+
};
|
|
88
|
+
const screenContext = {
|
|
89
|
+
screenResolution: `${screen.width}x${screen.height}`,
|
|
90
|
+
screenColor: `${screen.colorDepth}-bit`,
|
|
91
|
+
};
|
|
92
|
+
const navigatorContext = {
|
|
93
|
+
language: navigator.language,
|
|
94
|
+
userAgent: navigator.userAgent,
|
|
95
|
+
};
|
|
96
|
+
const eventContext = {
|
|
97
|
+
time: Date.now(),
|
|
98
|
+
eventId: this.uuidGenerator(),
|
|
99
|
+
};
|
|
100
|
+
return {
|
|
101
|
+
...eventContext,
|
|
102
|
+
...screenContext,
|
|
103
|
+
...navigatorContext,
|
|
104
|
+
...documentContext,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
private updateLocationForNextPageView(eventType: string, payload: any) {
|
|
109
|
+
const {pageViewId, referrer, location} = this.getNextValues(eventType, payload);
|
|
110
|
+
|
|
111
|
+
this.lastReferrer = referrer;
|
|
112
|
+
this.pageViewId = pageViewId;
|
|
113
|
+
this.currentLocation = location;
|
|
114
|
+
|
|
115
|
+
if (eventType === BasePluginEventTypes.pageview) {
|
|
116
|
+
this.nextPageViewId = this.uuidGenerator();
|
|
117
|
+
this.hasSentFirstPageView = true;
|
|
116
118
|
}
|
|
119
|
+
}
|
|
117
120
|
|
|
118
|
-
|
|
121
|
+
/*
|
|
119
122
|
When calling getPayload or getParameters, we need to return what would be sent by the API without updating our internal reference.
|
|
120
123
|
For instance, if you getPayload("pageview"), we want to return the same payload as if you did coveoua("send", "pageview").
|
|
121
124
|
*/
|
|
122
|
-
|
|
123
|
-
|
|
125
|
+
private getNextValues(eventType: string, payload: any) {
|
|
126
|
+
/*
|
|
124
127
|
When sending a pageview, we need to generate a new pageview ID.
|
|
125
128
|
For instance, with the following sequence: 1. pageview, 2. event, 3. pageview, 4. event, 1 and 2 will have the pageviewid, whereas 3 and 4 will have a different pageviewid.
|
|
126
129
|
We pre-generate the "nextPageViewId" in case you send the following sequence: 1. pageview, 2. event, 3. getPayload, 4. pageview. This ensures that 3 and 4 have the same pageviewid.
|
|
127
130
|
We applied the same logic to the referrer and the location.
|
|
128
131
|
*/
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
132
|
+
return {
|
|
133
|
+
pageViewId:
|
|
134
|
+
eventType === BasePluginEventTypes.pageview ? this.nextPageViewId : this.pageViewId,
|
|
135
|
+
referrer:
|
|
136
|
+
eventType === BasePluginEventTypes.pageview && this.hasSentFirstPageView
|
|
137
|
+
? this.currentLocation
|
|
138
|
+
: this.lastReferrer,
|
|
139
|
+
location:
|
|
140
|
+
eventType === BasePluginEventTypes.pageview
|
|
141
|
+
? this.getCurrentLocationFromPayload(payload)
|
|
142
|
+
: this.currentLocation,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
private getCurrentLocationFromPayload(payload: any) {
|
|
147
|
+
if (payload.page) {
|
|
148
|
+
const removeStartingSlash = (page: string) => page.replace(/^\/?(.*)$/, '/$1');
|
|
149
|
+
const extractHostnamePart = (location: string) => location.split('/').slice(0, 3).join('/');
|
|
150
|
+
return `${extractHostnamePart(this.currentLocation)}${removeStartingSlash(payload.page)}`;
|
|
151
|
+
} else {
|
|
152
|
+
return getFormattedLocation(window.location);
|
|
150
153
|
}
|
|
154
|
+
}
|
|
151
155
|
}
|