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/donottrack.spec.ts
CHANGED
|
@@ -1,144 +1,222 @@
|
|
|
1
|
+
import {vi} from 'vitest';
|
|
2
|
+
|
|
3
|
+
// `vi.mock` is hoisted, so the detector's answers are held in mutable state that
|
|
4
|
+
// each test rewrites. The Jest version instead called `jest.resetModules()` and
|
|
5
|
+
// re-`require`d the module under test, which ESM does not allow.
|
|
6
|
+
const detectorState = vi.hoisted(() => ({
|
|
7
|
+
hasNavigator: false,
|
|
8
|
+
hasWindow: false,
|
|
9
|
+
}));
|
|
10
|
+
|
|
11
|
+
vi.mock('./detector', () => ({
|
|
12
|
+
hasNavigator: () => detectorState.hasNavigator,
|
|
13
|
+
hasWindow: () => detectorState.hasWindow,
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
import {doNotTrack, shouldDisableAnalyticsForPrivacy} from './donottrack';
|
|
17
|
+
|
|
1
18
|
describe('doNotTrack', () => {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
19
|
+
function initModule(
|
|
20
|
+
hasNav: boolean,
|
|
21
|
+
hasWin: boolean,
|
|
22
|
+
options?: {
|
|
23
|
+
navigatorGlobalPrivacyControl?: any;
|
|
24
|
+
navigatorDoNotTrack?: any;
|
|
25
|
+
navigatorMsDoNotTrack?: any;
|
|
26
|
+
windowDoNotTrack?: any;
|
|
27
|
+
}
|
|
28
|
+
) {
|
|
29
|
+
detectorState.hasNavigator = hasNav;
|
|
30
|
+
detectorState.hasWindow = hasWin;
|
|
31
|
+
if (hasNav) {
|
|
32
|
+
Object.defineProperty(<any>navigator, 'globalPrivacyControl', {
|
|
33
|
+
get() {
|
|
34
|
+
return options!.navigatorGlobalPrivacyControl;
|
|
35
|
+
},
|
|
36
|
+
configurable: true,
|
|
37
|
+
});
|
|
38
|
+
Object.defineProperty(<any>navigator, 'doNotTrack', {
|
|
39
|
+
get() {
|
|
40
|
+
return options!.navigatorDoNotTrack;
|
|
41
|
+
},
|
|
42
|
+
configurable: true,
|
|
43
|
+
});
|
|
44
|
+
Object.defineProperty(<any>navigator, 'msDoNotTrack', {
|
|
45
|
+
get() {
|
|
46
|
+
return options!.navigatorMsDoNotTrack;
|
|
47
|
+
},
|
|
48
|
+
configurable: true,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
if (hasWin) {
|
|
52
|
+
Object.defineProperty(<any>window, 'doNotTrack', {
|
|
53
|
+
get() {
|
|
54
|
+
return options!.windowDoNotTrack;
|
|
11
55
|
},
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
jest.mock('./detector', () => ({
|
|
15
|
-
hasNavigator: () => hasNav,
|
|
16
|
-
hasWindow: () => hasWin,
|
|
17
|
-
}));
|
|
18
|
-
if (hasNav) {
|
|
19
|
-
Object.defineProperty(<any>navigator, 'globalPrivacyControl', {
|
|
20
|
-
get() {
|
|
21
|
-
return options!.navigatorGlobalPrivacyControl;
|
|
22
|
-
},
|
|
23
|
-
configurable: true,
|
|
24
|
-
});
|
|
25
|
-
Object.defineProperty(<any>navigator, 'doNotTrack', {
|
|
26
|
-
get() {
|
|
27
|
-
return options!.navigatorDoNotTrack;
|
|
28
|
-
},
|
|
29
|
-
configurable: true,
|
|
30
|
-
});
|
|
31
|
-
Object.defineProperty(<any>navigator, 'msDoNotTrack', {
|
|
32
|
-
get() {
|
|
33
|
-
return options!.navigatorMsDoNotTrack;
|
|
34
|
-
},
|
|
35
|
-
configurable: true,
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
if (hasWin) {
|
|
39
|
-
Object.defineProperty(<any>window, 'doNotTrack', {
|
|
40
|
-
get() {
|
|
41
|
-
return options!.windowDoNotTrack;
|
|
42
|
-
},
|
|
43
|
-
configurable: true,
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
doNotTrack = require('./donottrack').doNotTrack;
|
|
56
|
+
configurable: true,
|
|
57
|
+
});
|
|
47
58
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
59
|
+
}
|
|
60
|
+
describe('without a Navigator and without window', () => {
|
|
61
|
+
it('should be false', () => {
|
|
62
|
+
initModule(false, false);
|
|
51
63
|
|
|
52
|
-
|
|
53
|
-
});
|
|
64
|
+
expect(doNotTrack()).toBeFalsy();
|
|
54
65
|
});
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
66
|
+
});
|
|
67
|
+
describe('with a Navigator', () => {
|
|
68
|
+
it('should respect GPC false', () => {
|
|
69
|
+
initModule(true, false, {
|
|
70
|
+
navigatorGlobalPrivacyControl: false,
|
|
71
|
+
});
|
|
60
72
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
73
|
+
expect(doNotTrack()).toBeFalsy();
|
|
74
|
+
});
|
|
75
|
+
it('should respect GPC true', () => {
|
|
76
|
+
initModule(true, false, {
|
|
77
|
+
navigatorGlobalPrivacyControl: true,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
expect(doNotTrack()).toBeTruthy();
|
|
81
|
+
});
|
|
82
|
+
it('should respect GPC undefined', () => {
|
|
83
|
+
initModule(true, false, {
|
|
84
|
+
navigatorGlobalPrivacyControl: undefined,
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
expect(doNotTrack()).toBeFalsy();
|
|
88
|
+
});
|
|
67
89
|
|
|
68
|
-
|
|
90
|
+
[true, 'yes', '1'].forEach((value) => {
|
|
91
|
+
it('should fallback on `navigator.doNotTrack`: ' + JSON.stringify(value), () => {
|
|
92
|
+
initModule(true, false, {
|
|
93
|
+
navigatorDoNotTrack: value,
|
|
69
94
|
});
|
|
70
|
-
it('should respect GPC undefined', () => {
|
|
71
|
-
initModule(true, false, {
|
|
72
|
-
navigatorGlobalPrivacyControl: undefined,
|
|
73
|
-
});
|
|
74
95
|
|
|
75
|
-
|
|
96
|
+
expect(doNotTrack()).toBeTruthy();
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('should fallback on `navigator.msDoNotTrack`: ' + JSON.stringify(value), () => {
|
|
100
|
+
initModule(true, false, {
|
|
101
|
+
navigatorMsDoNotTrack: value,
|
|
76
102
|
});
|
|
103
|
+
expect(doNotTrack()).toBeTruthy();
|
|
104
|
+
});
|
|
105
|
+
});
|
|
77
106
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
expect(doNotTrack()).toBeTruthy();
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it('should fallback on `navigator.msDoNotTrack`: ' + JSON.stringify(value), () => {
|
|
88
|
-
initModule(true, false, {
|
|
89
|
-
navigatorMsDoNotTrack: value,
|
|
90
|
-
});
|
|
91
|
-
expect(doNotTrack()).toBeTruthy();
|
|
92
|
-
});
|
|
107
|
+
[false, 'no', '0', 'unspecified'].forEach((value) => {
|
|
108
|
+
it('should fallback on `navigator.doNotTrack`: ' + JSON.stringify(value), () => {
|
|
109
|
+
initModule(true, false, {
|
|
110
|
+
navigatorDoNotTrack: value,
|
|
93
111
|
});
|
|
94
112
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
expect(doNotTrack()).toBeFalsy();
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it('should fallback on `navigator.msDoNotTrack`: ' + JSON.stringify(value), () => {
|
|
105
|
-
initModule(true, false, {
|
|
106
|
-
navigatorMsDoNotTrack: value,
|
|
107
|
-
});
|
|
108
|
-
expect(doNotTrack()).toBeFalsy();
|
|
109
|
-
});
|
|
113
|
+
expect(doNotTrack()).toBeFalsy();
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('should fallback on `navigator.msDoNotTrack`: ' + JSON.stringify(value), () => {
|
|
117
|
+
initModule(true, false, {
|
|
118
|
+
navigatorMsDoNotTrack: value,
|
|
110
119
|
});
|
|
120
|
+
expect(doNotTrack()).toBeFalsy();
|
|
121
|
+
});
|
|
111
122
|
});
|
|
123
|
+
});
|
|
112
124
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
});
|
|
119
|
-
expect(doNotTrack()).toBeTruthy();
|
|
120
|
-
});
|
|
125
|
+
describe('with a Window', () => {
|
|
126
|
+
[true, 'yes', '1'].forEach((value) => {
|
|
127
|
+
it('should fallback on `window.doNotTrack`: ' + JSON.stringify(value), () => {
|
|
128
|
+
initModule(false, true, {
|
|
129
|
+
windowDoNotTrack: value,
|
|
121
130
|
});
|
|
131
|
+
expect(doNotTrack()).toBeTruthy();
|
|
132
|
+
});
|
|
133
|
+
});
|
|
122
134
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
});
|
|
128
|
-
expect(doNotTrack()).toBeFalsy();
|
|
129
|
-
});
|
|
135
|
+
[false, 'no', '0', 'unspecified'].forEach((value) => {
|
|
136
|
+
it('should fallback on `window.doNotTrack`: ' + JSON.stringify(value), () => {
|
|
137
|
+
initModule(false, true, {
|
|
138
|
+
windowDoNotTrack: value,
|
|
130
139
|
});
|
|
140
|
+
expect(doNotTrack()).toBeFalsy();
|
|
141
|
+
});
|
|
131
142
|
});
|
|
143
|
+
});
|
|
132
144
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
145
|
+
describe('with a Navigator and a Window', () => {
|
|
146
|
+
it('should fallback on `window.doNotTrack` if all navigator properties are falsy', () => {
|
|
147
|
+
initModule(true, true, {
|
|
148
|
+
navigatorDoNotTrack: false,
|
|
149
|
+
navigatorGlobalPrivacyControl: undefined,
|
|
150
|
+
navigatorMsDoNotTrack: '0',
|
|
151
|
+
windowDoNotTrack: 1,
|
|
152
|
+
});
|
|
153
|
+
expect(doNotTrack()).toBeTruthy();
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
describe('shouldDisableAnalyticsForPrivacy', () => {
|
|
159
|
+
function initModule(signal: {navigatorGlobalPrivacyControl?: any; navigatorDoNotTrack?: any}) {
|
|
160
|
+
detectorState.hasNavigator = true;
|
|
161
|
+
detectorState.hasWindow = true;
|
|
162
|
+
Object.defineProperty(<any>navigator, 'globalPrivacyControl', {
|
|
163
|
+
get() {
|
|
164
|
+
return signal.navigatorGlobalPrivacyControl;
|
|
165
|
+
},
|
|
166
|
+
configurable: true,
|
|
167
|
+
});
|
|
168
|
+
Object.defineProperty(<any>navigator, 'doNotTrack', {
|
|
169
|
+
get() {
|
|
170
|
+
return signal.navigatorDoNotTrack;
|
|
171
|
+
},
|
|
172
|
+
configurable: true,
|
|
173
|
+
});
|
|
174
|
+
Object.defineProperty(<any>navigator, 'msDoNotTrack', {
|
|
175
|
+
get() {
|
|
176
|
+
return undefined;
|
|
177
|
+
},
|
|
178
|
+
configurable: true,
|
|
143
179
|
});
|
|
180
|
+
Object.defineProperty(<any>window, 'doNotTrack', {
|
|
181
|
+
get() {
|
|
182
|
+
return undefined;
|
|
183
|
+
},
|
|
184
|
+
configurable: true,
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
it('disables when DNT is active and the option is omitted', () => {
|
|
189
|
+
initModule({navigatorDoNotTrack: '1'});
|
|
190
|
+
expect(shouldDisableAnalyticsForPrivacy()).toBe(true);
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
it('disables when GPC is active and the option is omitted', () => {
|
|
194
|
+
initModule({navigatorGlobalPrivacyControl: true});
|
|
195
|
+
expect(shouldDisableAnalyticsForPrivacy()).toBe(true);
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
it('keeps analytics when DNT is active but the option is true', () => {
|
|
199
|
+
initModule({navigatorDoNotTrack: '1'});
|
|
200
|
+
expect(shouldDisableAnalyticsForPrivacy(true)).toBe(false);
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it('keeps analytics when GPC is active but the option is true (umbrella overrides GPC)', () => {
|
|
204
|
+
initModule({navigatorGlobalPrivacyControl: true});
|
|
205
|
+
expect(shouldDisableAnalyticsForPrivacy(true)).toBe(false);
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
it('keeps analytics when both DNT and GPC are active but the option is true', () => {
|
|
209
|
+
initModule({navigatorDoNotTrack: '1', navigatorGlobalPrivacyControl: true});
|
|
210
|
+
expect(shouldDisableAnalyticsForPrivacy(true)).toBe(false);
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
it('does not disable when no signal is active and the option is omitted', () => {
|
|
214
|
+
initModule({});
|
|
215
|
+
expect(shouldDisableAnalyticsForPrivacy()).toBe(false);
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
it('treats a false option the same as omitting it', () => {
|
|
219
|
+
initModule({navigatorDoNotTrack: '1'});
|
|
220
|
+
expect(shouldDisableAnalyticsForPrivacy(false)).toBe(true);
|
|
221
|
+
});
|
|
144
222
|
});
|
package/src/donottrack.ts
CHANGED
|
@@ -9,14 +9,37 @@ import {hasNavigator, hasWindow} from './detector';
|
|
|
9
9
|
const doNotTrackValues = ['1', 1, 'yes', true];
|
|
10
10
|
|
|
11
11
|
export function doNotTrack(): boolean {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
const checks: any[] = [];
|
|
13
|
+
if (hasWindow()) {
|
|
14
|
+
checks.push((<any>window).doNotTrack);
|
|
15
|
+
}
|
|
16
|
+
if (hasNavigator()) {
|
|
17
|
+
checks.push(
|
|
18
|
+
(<any>navigator).doNotTrack,
|
|
19
|
+
(<any>navigator).msDoNotTrack,
|
|
20
|
+
(<any>navigator).globalPrivacyControl
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
return checks.some((value) => doNotTrackValues.indexOf(value) !== -1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Effective analytics-suppression policy for browser privacy signals.
|
|
28
|
+
*
|
|
29
|
+
* By default, any active browser privacy signal (Do Not Track or Global Privacy
|
|
30
|
+
* Control) suppresses analytics. When `disableBrowserPrivacySignals` is explicitly
|
|
31
|
+
* `true`, the integration takes ownership of privacy decisions and no browser
|
|
32
|
+
* signal is honored.
|
|
33
|
+
*
|
|
34
|
+
* @param disableBrowserPrivacySignals When `true`, browser privacy signals (DNT and
|
|
35
|
+
* GPC) are ignored. The default (`false`/`undefined`) preserves the privacy-friendly
|
|
36
|
+
* behavior of honoring them.
|
|
37
|
+
*/
|
|
38
|
+
export function shouldDisableAnalyticsForPrivacy(disableBrowserPrivacySignals?: boolean): boolean {
|
|
39
|
+
if (disableBrowserPrivacySignals === true) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
return doNotTrack();
|
|
20
43
|
}
|
|
21
44
|
|
|
22
45
|
export default doNotTrack;
|
package/src/events.ts
CHANGED
|
@@ -1,90 +1,90 @@
|
|
|
1
1
|
export type IRequestPayload = Record<string, any>;
|
|
2
2
|
|
|
3
3
|
export enum EventType {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
search = 'search',
|
|
5
|
+
click = 'click',
|
|
6
|
+
custom = 'custom',
|
|
7
|
+
view = 'view',
|
|
8
|
+
collect = 'collect',
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export interface SearchDocument {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
documentUri: string;
|
|
13
|
+
documentUriHash: string;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export type SendEventArguments = [EventType, ...any[]];
|
|
17
17
|
|
|
18
18
|
export type VariableArgumentsPayload =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
| []
|
|
20
|
+
| [any]
|
|
21
|
+
| [string, any]
|
|
22
|
+
| [string, string, any]
|
|
23
|
+
| [string, string, string, any]
|
|
24
|
+
| [string, string, string, string, any];
|
|
25
25
|
|
|
26
26
|
export interface EventBaseRequest {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
27
|
+
language?: string;
|
|
28
|
+
userAgent?: string;
|
|
29
|
+
customData?: Record<string, any>;
|
|
30
|
+
anonymous?: boolean;
|
|
31
|
+
username?: string;
|
|
32
|
+
userDisplayName?: any;
|
|
33
|
+
splitTestRunName?: string;
|
|
34
|
+
splitTestRunVersion?: string;
|
|
35
|
+
clientId?: string;
|
|
36
|
+
originContext?: string;
|
|
37
|
+
originLevel1?: string;
|
|
38
|
+
originLevel2?: string;
|
|
39
|
+
originLevel3?: string;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
export interface FacetStateRequest {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
43
|
+
field: string;
|
|
44
|
+
id: string;
|
|
45
|
+
value: string;
|
|
46
|
+
valuePosition: number;
|
|
47
|
+
displayValue: string;
|
|
48
|
+
facetType: 'specific' | 'dateRange' | 'numericalRange' | 'hierarchical';
|
|
49
|
+
state: 'selected' | 'idle' | 'excluded';
|
|
50
|
+
facetPosition: number;
|
|
51
|
+
title: string;
|
|
52
|
+
start?: string;
|
|
53
|
+
end?: string;
|
|
54
|
+
endInclusive?: boolean;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
export interface SearchEventRequest extends EventBaseRequest {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
58
|
+
searchQueryUid: string;
|
|
59
|
+
queryText: string;
|
|
60
|
+
actionCause: string;
|
|
61
|
+
responseTime: number;
|
|
62
|
+
advancedQuery?: string;
|
|
63
|
+
numberOfResults?: number;
|
|
64
|
+
contextual?: boolean;
|
|
65
|
+
results?: SearchDocument[];
|
|
66
|
+
queryPipeline?: string;
|
|
67
|
+
userGroups?: string[];
|
|
68
|
+
facetState?: FacetStateRequest[];
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
export interface PreparedSearchEventRequest extends Omit<SearchEventRequest, 'searchQueryUid'> {}
|
|
72
72
|
|
|
73
73
|
export interface DocumentInformation {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
74
|
+
documentUri?: string;
|
|
75
|
+
documentUriHash?: string;
|
|
76
|
+
collectionName?: string;
|
|
77
|
+
sourceName: string;
|
|
78
|
+
documentPosition: number;
|
|
79
|
+
actionCause: string;
|
|
80
|
+
|
|
81
|
+
searchQueryUid: string;
|
|
82
|
+
documentTitle?: string;
|
|
83
|
+
documentUrl?: string;
|
|
84
|
+
documentAuthor?: string;
|
|
85
|
+
queryPipeline?: string;
|
|
86
|
+
rankingModifier?: string;
|
|
87
|
+
documentCategory?: string;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
export interface ClickEventRequest extends EventBaseRequest, DocumentInformation {}
|
|
@@ -92,27 +92,30 @@ export interface ClickEventRequest extends EventBaseRequest, DocumentInformation
|
|
|
92
92
|
export interface PreparedClickEventRequest extends Omit<ClickEventRequest, 'searchQueryUid'> {}
|
|
93
93
|
|
|
94
94
|
export interface CustomEventRequest extends EventBaseRequest {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
eventType: string;
|
|
96
|
+
eventValue: string;
|
|
97
|
+
lastSearchQueryUid?: string;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
export interface PreparedCustomEventRequest extends Omit<
|
|
100
|
+
export interface PreparedCustomEventRequest extends Omit<
|
|
101
|
+
CustomEventRequest,
|
|
102
|
+
'lastSearchQueryUid'
|
|
103
|
+
> {}
|
|
101
104
|
|
|
102
105
|
export interface ViewEventRequest extends EventBaseRequest {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
location?: string;
|
|
107
|
+
referrer?: string;
|
|
108
|
+
title?: string;
|
|
109
|
+
contentIdKey: string;
|
|
110
|
+
contentIdValue: string;
|
|
111
|
+
contentType?: string;
|
|
109
112
|
}
|
|
110
113
|
|
|
111
114
|
export interface PreparedViewEventRequest extends ViewEventRequest {}
|
|
112
115
|
|
|
113
116
|
export interface DefaultEventResponse {
|
|
114
|
-
|
|
115
|
-
|
|
117
|
+
visitId: string;
|
|
118
|
+
visitorId: string;
|
|
116
119
|
}
|
|
117
120
|
|
|
118
121
|
export interface SearchEventResponse extends DefaultEventResponse {}
|
|
@@ -120,12 +123,16 @@ export interface ClickEventResponse extends DefaultEventResponse {}
|
|
|
120
123
|
export interface CustomEventResponse extends DefaultEventResponse {}
|
|
121
124
|
export interface ViewEventResponse extends DefaultEventResponse {}
|
|
122
125
|
|
|
123
|
-
export type AnyEventResponse =
|
|
126
|
+
export type AnyEventResponse =
|
|
127
|
+
| SearchEventResponse
|
|
128
|
+
| ClickEventResponse
|
|
129
|
+
| CustomEventResponse
|
|
130
|
+
| ViewEventResponse;
|
|
124
131
|
|
|
125
132
|
export interface VisitResponse {
|
|
126
|
-
|
|
127
|
-
|
|
133
|
+
id: string;
|
|
134
|
+
visitorId: string;
|
|
128
135
|
}
|
|
129
136
|
export interface HealthResponse {
|
|
130
|
-
|
|
137
|
+
status: string;
|
|
131
138
|
}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import {formatArrayForCoveoCustomData} from './format-array-for-coveo-custom-data';
|
|
2
2
|
|
|
3
3
|
describe('#formatArrayForCoveoCustomData', () => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
it('returns an empty string for an empty array', () => {
|
|
5
|
+
expect(formatArrayForCoveoCustomData([])).toEqual('');
|
|
6
|
+
});
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
it('returns the correct string for a valid array', () => {
|
|
9
|
+
expect(formatArrayForCoveoCustomData(['t', 'test'])).toEqual('t;test');
|
|
10
|
+
});
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
it('correctly truncates the data when it contains more than 256 characters', () => {
|
|
13
|
+
const longString =
|
|
14
|
+
/* cspell:disable-next-line */
|
|
15
|
+
'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis,';
|
|
16
|
+
const rawData = ['1', longString];
|
|
17
|
+
expect(formatArrayForCoveoCustomData(rawData)).toEqual(longString);
|
|
18
|
+
});
|
|
18
19
|
});
|