coveo.analytics 2.30.55 → 2.31.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.
Files changed (86) hide show
  1. package/README.md +37 -43
  2. package/dist/browser.mjs +525 -357
  3. package/dist/coveoua.browser.js +1 -1
  4. package/dist/coveoua.browser.js.map +1 -1
  5. package/dist/coveoua.debug.js +559 -359
  6. package/dist/coveoua.debug.js.map +1 -1
  7. package/dist/coveoua.js +1 -1
  8. package/dist/coveoua.js.map +1 -1
  9. package/dist/definitions/client/analytics.d.ts +3 -2
  10. package/dist/definitions/client/runtimeEnvironment.d.ts +1 -1
  11. package/dist/definitions/donottrack.d.ts +1 -0
  12. package/dist/definitions/react-native/index.d.ts +1 -1
  13. package/dist/definitions/searchPage/searchPageClient.d.ts +3 -1
  14. package/dist/definitions/searchPage/searchPageEvents.d.ts +6 -0
  15. package/dist/definitions/version.d.ts +1 -1
  16. package/dist/library.cjs +15367 -3699
  17. package/dist/library.es.js +525 -357
  18. package/dist/library.js +15367 -3699
  19. package/dist/library.mjs +15367 -3699
  20. package/dist/react-native.es.js +646 -460
  21. package/modules/package.json +9 -9
  22. package/package.json +60 -91
  23. package/react-native/package.json +7 -7
  24. package/src/caseAssist/caseAssistActions.ts +51 -50
  25. package/src/caseAssist/caseAssistClient.spec.ts +328 -297
  26. package/src/caseAssist/caseAssistClient.ts +201 -185
  27. package/src/client/analytics.spec.ts +724 -703
  28. package/src/client/analytics.ts +677 -602
  29. package/src/client/analyticsBeaconClient.spec.ts +195 -188
  30. package/src/client/analyticsBeaconClient.ts +99 -88
  31. package/src/client/analyticsFetchClient.ts +77 -61
  32. package/src/client/analyticsRequestClient.ts +17 -17
  33. package/src/client/location.ts +3 -3
  34. package/src/client/measurementProtocolMapper.ts +54 -45
  35. package/src/client/measurementProtocolMapping/baseMeasurementProtocolMapper.ts +48 -44
  36. package/src/client/measurementProtocolMapping/commerceMeasurementProtocolMapper.ts +133 -121
  37. package/src/client/measurementProtocolMapping/serviceMeasurementProtocolMapper.ts +17 -17
  38. package/src/client/noopAnalytics.ts +80 -68
  39. package/src/client/runtimeEnvironment.ts +50 -41
  40. package/src/client/utils.spec.ts +112 -97
  41. package/src/client/utils.ts +39 -39
  42. package/src/cookieutils.spec.ts +59 -0
  43. package/src/cookieutils.ts +40 -39
  44. package/src/coveoua/browser.ts +14 -12
  45. package/src/coveoua/library.ts +4 -4
  46. package/src/coveoua/plugins.ts +36 -34
  47. package/src/coveoua/simpleanalytics.spec.ts +467 -452
  48. package/src/coveoua/simpleanalytics.ts +146 -140
  49. package/src/detector.ts +17 -17
  50. package/src/donottrack.spec.ts +199 -121
  51. package/src/donottrack.ts +31 -8
  52. package/src/events.ts +86 -79
  53. package/src/formatting/format-array-for-coveo-custom-data.spec.ts +13 -12
  54. package/src/formatting/format-array-for-coveo-custom-data.ts +18 -18
  55. package/src/formatting/format-omnibox-metadata.ts +16 -12
  56. package/src/history.spec.ts +197 -195
  57. package/src/history.ts +143 -133
  58. package/src/hook/addDefaultValues.ts +13 -8
  59. package/src/hook/enhanceViewEvent.ts +17 -17
  60. package/src/insight/insightClient.spec.ts +1848 -1717
  61. package/src/insight/insightClient.ts +866 -761
  62. package/src/insight/insightEvents.ts +57 -56
  63. package/src/plugins/BasePlugin.ts +125 -121
  64. package/src/plugins/ec.spec.ts +457 -429
  65. package/src/plugins/ec.ts +202 -199
  66. package/src/plugins/link.spec.ts +183 -159
  67. package/src/plugins/link.ts +88 -85
  68. package/src/plugins/svc.spec.ts +161 -155
  69. package/src/plugins/svc.ts +93 -91
  70. package/src/react-native/index.ts +5 -1
  71. package/src/react-native/react-native-runtime.ts +33 -33
  72. package/src/react-native/react-native-utils.ts +1 -1
  73. package/src/react-native/react-native.spec.ts +22 -21
  74. package/src/searchPage/searchPageClient.spec.ts +1944 -1766
  75. package/src/searchPage/searchPageClient.ts +1261 -1029
  76. package/src/searchPage/searchPageEvents.ts +529 -500
  77. package/src/storage.spec.ts +51 -51
  78. package/src/storage.ts +47 -47
  79. package/dist/definitions/bundle/browser-fetch.d.ts +0 -1
  80. package/dist/definitions/src/coveoua/browser.d.ts +0 -6
  81. package/dist/definitions/src/coveoua/headless.d.ts +0 -6
  82. package/dist/definitions/src/coveoua/library.d.ts +0 -17
  83. package/dist/definitions/src/coveoua/plugins.d.ts +0 -10
  84. package/dist/definitions/src/coveoua/simpleanalytics.d.ts +0 -33
  85. package/dist/definitions/src/react-native/index.d.ts +0 -3
  86. package/dist/definitions/src/react-native/react-native-runtime.d.ts +0 -19
@@ -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
- let doNotTrack: () => boolean;
3
- function initModule(
4
- hasNav: boolean,
5
- hasWin: boolean,
6
- options?: {
7
- navigatorGlobalPrivacyControl?: any;
8
- navigatorDoNotTrack?: any;
9
- navigatorMsDoNotTrack?: any;
10
- windowDoNotTrack?: any;
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
- jest.resetModules();
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
- describe('without a Navigator and without window', () => {
49
- it('should be false', () => {
50
- initModule(false, false);
59
+ }
60
+ describe('without a Navigator and without window', () => {
61
+ it('should be false', () => {
62
+ initModule(false, false);
51
63
 
52
- expect(doNotTrack()).toBeFalsy();
53
- });
64
+ expect(doNotTrack()).toBeFalsy();
54
65
  });
55
- describe('with a Navigator', () => {
56
- it('should respect GPC false', () => {
57
- initModule(true, false, {
58
- navigatorGlobalPrivacyControl: false,
59
- });
66
+ });
67
+ describe('with a Navigator', () => {
68
+ it('should respect GPC false', () => {
69
+ initModule(true, false, {
70
+ navigatorGlobalPrivacyControl: false,
71
+ });
60
72
 
61
- expect(doNotTrack()).toBeFalsy();
62
- });
63
- it('should respect GPC true', () => {
64
- initModule(true, false, {
65
- navigatorGlobalPrivacyControl: true,
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
- expect(doNotTrack()).toBeTruthy();
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
- expect(doNotTrack()).toBeFalsy();
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
- [true, 'yes', '1'].forEach((value) => {
79
- it('should fallback on `navigator.doNotTrack`: ' + JSON.stringify(value), () => {
80
- initModule(true, false, {
81
- navigatorDoNotTrack: value,
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
- [false, 'no', '0', 'unspecified'].forEach((value) => {
96
- it('should fallback on `navigator.doNotTrack`: ' + JSON.stringify(value), () => {
97
- initModule(true, false, {
98
- navigatorDoNotTrack: value,
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
- describe('with a Window', () => {
114
- [true, 'yes', '1'].forEach((value) => {
115
- it('should fallback on `window.doNotTrack`: ' + JSON.stringify(value), () => {
116
- initModule(false, true, {
117
- windowDoNotTrack: value,
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
- [false, 'no', '0', 'unspecified'].forEach((value) => {
124
- it('should fallback on `window.doNotTrack`: ' + JSON.stringify(value), () => {
125
- initModule(false, true, {
126
- windowDoNotTrack: value,
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
- describe('with a Navigator and a Window', () => {
134
- it('should fallback on `window.doNotTrack` if all navigator properties are falsy', () => {
135
- initModule(true, true, {
136
- navigatorDoNotTrack: false,
137
- navigatorGlobalPrivacyControl: undefined,
138
- navigatorMsDoNotTrack: '0',
139
- windowDoNotTrack: 1,
140
- });
141
- expect(doNotTrack()).toBeTruthy();
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
- const checks: any[] = [];
13
- if (hasWindow()) {
14
- checks.push((<any>window).doNotTrack);
15
- }
16
- if (hasNavigator()) {
17
- checks.push((<any>navigator).doNotTrack, (<any>navigator).msDoNotTrack, (<any>navigator).globalPrivacyControl);
18
- }
19
- return checks.some((value) => doNotTrackValues.indexOf(value) !== -1);
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
- search = 'search',
5
- click = 'click',
6
- custom = 'custom',
7
- view = 'view',
8
- collect = 'collect',
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
- documentUri: string;
13
- documentUriHash: string;
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
- | [any]
21
- | [string, any]
22
- | [string, string, any]
23
- | [string, string, string, any]
24
- | [string, string, string, string, any];
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
- 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;
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
- 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;
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
- 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[];
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
- 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;
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
- eventType: string;
96
- eventValue: string;
97
- lastSearchQueryUid?: string;
95
+ eventType: string;
96
+ eventValue: string;
97
+ lastSearchQueryUid?: string;
98
98
  }
99
99
 
100
- export interface PreparedCustomEventRequest extends Omit<CustomEventRequest, 'lastSearchQueryUid'> {}
100
+ export interface PreparedCustomEventRequest extends Omit<
101
+ CustomEventRequest,
102
+ 'lastSearchQueryUid'
103
+ > {}
101
104
 
102
105
  export interface ViewEventRequest extends EventBaseRequest {
103
- location?: string;
104
- referrer?: string;
105
- title?: string;
106
- contentIdKey: string;
107
- contentIdValue: string;
108
- contentType?: string;
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
- visitId: string;
115
- visitorId: string;
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 = SearchEventResponse | ClickEventResponse | CustomEventResponse | ViewEventResponse;
126
+ export type AnyEventResponse =
127
+ | SearchEventResponse
128
+ | ClickEventResponse
129
+ | CustomEventResponse
130
+ | ViewEventResponse;
124
131
 
125
132
  export interface VisitResponse {
126
- id: string;
127
- visitorId: string;
133
+ id: string;
134
+ visitorId: string;
128
135
  }
129
136
  export interface HealthResponse {
130
- status: string;
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
- it('returns an empty string for an empty array', () => {
5
- expect(formatArrayForCoveoCustomData([])).toEqual('');
6
- });
4
+ it('returns an empty string for an empty array', () => {
5
+ expect(formatArrayForCoveoCustomData([])).toEqual('');
6
+ });
7
7
 
8
- it('returns the correct string for a valid array', () => {
9
- expect(formatArrayForCoveoCustomData(['t', 'test'])).toEqual('t;test');
10
- });
8
+ it('returns the correct string for a valid array', () => {
9
+ expect(formatArrayForCoveoCustomData(['t', 'test'])).toEqual('t;test');
10
+ });
11
11
 
12
- it('correctly truncates the data when it contains more than 256 characters', () => {
13
- const longString =
14
- '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,';
15
- const rawData = ['1', longString];
16
- expect(formatArrayForCoveoCustomData(rawData)).toEqual(longString);
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
  });