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.
Files changed (84) hide show
  1. package/README.md +37 -43
  2. package/dist/browser.mjs +513 -357
  3. package/dist/coveoua.browser.js +1 -1
  4. package/dist/coveoua.browser.js.map +1 -1
  5. package/dist/coveoua.debug.js +542 -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 -2
  13. package/dist/definitions/version.d.ts +1 -1
  14. package/dist/library.cjs +15350 -3699
  15. package/dist/library.es.js +513 -357
  16. package/dist/library.js +15350 -3699
  17. package/dist/library.mjs +15350 -3699
  18. package/dist/react-native.es.js +634 -460
  19. package/modules/package.json +9 -9
  20. package/package.json +60 -91
  21. package/react-native/package.json +7 -7
  22. package/src/caseAssist/caseAssistActions.ts +51 -50
  23. package/src/caseAssist/caseAssistClient.spec.ts +328 -297
  24. package/src/caseAssist/caseAssistClient.ts +201 -185
  25. package/src/client/analytics.spec.ts +724 -703
  26. package/src/client/analytics.ts +677 -602
  27. package/src/client/analyticsBeaconClient.spec.ts +195 -188
  28. package/src/client/analyticsBeaconClient.ts +99 -88
  29. package/src/client/analyticsFetchClient.ts +77 -61
  30. package/src/client/analyticsRequestClient.ts +17 -17
  31. package/src/client/location.ts +3 -3
  32. package/src/client/measurementProtocolMapper.ts +54 -45
  33. package/src/client/measurementProtocolMapping/baseMeasurementProtocolMapper.ts +48 -44
  34. package/src/client/measurementProtocolMapping/commerceMeasurementProtocolMapper.ts +133 -121
  35. package/src/client/measurementProtocolMapping/serviceMeasurementProtocolMapper.ts +17 -17
  36. package/src/client/noopAnalytics.ts +80 -68
  37. package/src/client/runtimeEnvironment.ts +50 -41
  38. package/src/client/utils.spec.ts +112 -97
  39. package/src/client/utils.ts +39 -39
  40. package/src/cookieutils.spec.ts +59 -0
  41. package/src/cookieutils.ts +40 -39
  42. package/src/coveoua/browser.ts +14 -12
  43. package/src/coveoua/library.ts +4 -4
  44. package/src/coveoua/plugins.ts +36 -34
  45. package/src/coveoua/simpleanalytics.spec.ts +467 -452
  46. package/src/coveoua/simpleanalytics.ts +146 -140
  47. package/src/detector.ts +17 -17
  48. package/src/donottrack.spec.ts +199 -121
  49. package/src/donottrack.ts +31 -8
  50. package/src/events.ts +86 -79
  51. package/src/formatting/format-array-for-coveo-custom-data.spec.ts +13 -12
  52. package/src/formatting/format-array-for-coveo-custom-data.ts +18 -18
  53. package/src/formatting/format-omnibox-metadata.ts +16 -12
  54. package/src/history.spec.ts +197 -195
  55. package/src/history.ts +143 -133
  56. package/src/hook/addDefaultValues.ts +13 -8
  57. package/src/hook/enhanceViewEvent.ts +17 -17
  58. package/src/insight/insightClient.spec.ts +1848 -1717
  59. package/src/insight/insightClient.ts +866 -761
  60. package/src/insight/insightEvents.ts +57 -56
  61. package/src/plugins/BasePlugin.ts +125 -121
  62. package/src/plugins/ec.spec.ts +457 -429
  63. package/src/plugins/ec.ts +202 -199
  64. package/src/plugins/link.spec.ts +183 -159
  65. package/src/plugins/link.ts +88 -85
  66. package/src/plugins/svc.spec.ts +161 -155
  67. package/src/plugins/svc.ts +93 -91
  68. package/src/react-native/index.ts +8 -1
  69. package/src/react-native/react-native-runtime.ts +33 -33
  70. package/src/react-native/react-native-utils.ts +1 -1
  71. package/src/react-native/react-native.spec.ts +31 -21
  72. package/src/searchPage/searchPageClient.spec.ts +1944 -1794
  73. package/src/searchPage/searchPageClient.ts +1261 -1040
  74. package/src/searchPage/searchPageEvents.ts +524 -511
  75. package/src/storage.spec.ts +51 -51
  76. package/src/storage.ts +47 -47
  77. package/dist/definitions/bundle/browser-fetch.d.ts +0 -1
  78. package/dist/definitions/src/coveoua/browser.d.ts +0 -6
  79. package/dist/definitions/src/coveoua/headless.d.ts +0 -6
  80. package/dist/definitions/src/coveoua/library.d.ts +0 -17
  81. package/dist/definitions/src/coveoua/plugins.d.ts +0 -10
  82. package/dist/definitions/src/coveoua/simpleanalytics.d.ts +0 -33
  83. package/dist/definitions/src/react-native/index.d.ts +0 -3
  84. package/dist/definitions/src/react-native/react-native-runtime.d.ts +0 -19
@@ -1,14 +1,16 @@
1
+ import {vi} from 'vitest';
2
+ import type {Mock} from 'vitest';
1
3
  import {lastCallBody, mockFetch} from '../../tests/fetchMock';
2
4
  import CoveoAnalyticsClient from '../client/analytics';
3
5
  import {NoopAnalytics} from '../client/noopAnalytics';
4
6
  import {
5
- CustomEventsTypes,
6
- GeneratedAnswerFeedbackReason,
7
- GeneratedAnswerFeedbackReasonOption,
8
- GeneratedAnswerRephraseFormat,
9
- PartialDocumentInformation,
10
- SearchPageEvents,
11
- StaticFilterToggleValueMetadata,
7
+ CustomEventsTypes,
8
+ GeneratedAnswerFeedbackReason,
9
+ GeneratedAnswerFeedbackReasonOption,
10
+ GeneratedAnswerRephraseFormat,
11
+ PartialDocumentInformation,
12
+ SearchPageEvents,
13
+ StaticFilterToggleValueMetadata,
12
14
  } from '../searchPage/searchPageEvents';
13
15
  import {CoveoInsightClient, InsightClientProvider} from './insightClient';
14
16
  import doNotTrack from '../donottrack';
@@ -16,1737 +18,1866 @@ import {InsightEvents, InsightStaticFilterToggleValueMetadata} from './insightEv
16
18
  import {Cookie} from '../cookieutils';
17
19
 
18
20
  const baseCaseMetadata = {
19
- caseId: '1234',
20
- caseNumber: '5678',
21
- caseContext: {Case_Subject: 'test subject', Case_Description: 'test description'},
21
+ caseId: '1234',
22
+ caseNumber: '5678',
23
+ caseContext: {
24
+ Case_Subject: 'test subject',
25
+ Case_Description: 'test description',
26
+ },
22
27
  };
23
28
 
24
29
  const expectedBaseCaseMetadata = {
25
- CaseId: '1234',
26
- CaseNumber: '5678',
27
- CaseSubject: 'test subject',
30
+ CaseId: '1234',
31
+ CaseNumber: '5678',
32
+ CaseSubject: 'test subject',
28
33
  };
29
34
 
30
- jest.mock('../donottrack', () => {
31
- return {
32
- default: jest.fn(),
33
- doNotTrack: jest.fn(),
34
- };
35
+ vi.mock('../donottrack', () => {
36
+ const doNotTrack = vi.fn();
37
+ return {
38
+ __esModule: true,
39
+ default: doNotTrack,
40
+ doNotTrack,
41
+ shouldDisableAnalyticsForPrivacy: (disableBrowserPrivacySignals?: boolean) =>
42
+ disableBrowserPrivacySignals === true ? false : doNotTrack(),
43
+ };
35
44
  });
36
45
 
37
46
  const {fetchMock, fetchMockBeforeEach} = mockFetch();
38
47
  describe('InsightClient', () => {
39
- const fakeFacetState = [
40
- {
41
- valuePosition: 0,
42
- value: 'foo',
43
- state: 'selected' as const,
44
- facetPosition: 1,
45
- displayValue: 'foobar',
46
- facetType: 'specific' as const,
47
- field: '@foo',
48
- id: 'bar',
49
- title: 'title',
48
+ const fakeFacetState = [
49
+ {
50
+ valuePosition: 0,
51
+ value: 'foo',
52
+ state: 'selected' as const,
53
+ facetPosition: 1,
54
+ displayValue: 'foobar',
55
+ facetType: 'specific' as const,
56
+ field: '@foo',
57
+ id: 'bar',
58
+ title: 'title',
59
+ },
60
+ ];
61
+
62
+ let client: CoveoInsightClient;
63
+
64
+ const provider: InsightClientProvider = {
65
+ getBaseMetadata: () => ({foo: 'bar'}),
66
+ getSearchEventRequestPayload: () => ({
67
+ queryText: 'queryText',
68
+ responseTime: 123,
69
+ }),
70
+ getSearchUID: () => 'my-uid',
71
+ getPipeline: () => 'my-pipeline',
72
+ getOriginContext: () => 'origin-context',
73
+ getOriginLevel1: () => 'origin-level-1',
74
+ getOriginLevel2: () => 'origin-level-2',
75
+ getOriginLevel3: () => 'origin-level-3',
76
+ getLanguage: () => 'en',
77
+ getFacetState: () => fakeFacetState,
78
+ getIsAnonymous: () => false,
79
+ getGeneratedAnswerMetadata: () => ({genratedAnswerMetadata: 'foo'}),
80
+ };
81
+
82
+ const initClient = () => {
83
+ return new CoveoInsightClient({}, provider);
84
+ };
85
+
86
+ const expectOrigins = () => ({
87
+ originContext: 'origin-context',
88
+ originLevel1: 'origin-level-1',
89
+ originLevel2: 'origin-level-2',
90
+ originLevel3: 'origin-level-3',
91
+ });
92
+
93
+ const expectMatchPayload = (actionCause: SearchPageEvents | InsightEvents, meta = {}) => {
94
+ const body: string = lastCallBody(fetchMock);
95
+ const customData = {foo: 'bar', genratedAnswerMetadata: 'foo', ...meta};
96
+ expect(JSON.parse(body)).toMatchObject({
97
+ queryText: 'queryText',
98
+ responseTime: 123,
99
+ queryPipeline: 'my-pipeline',
100
+ actionCause,
101
+ customData,
102
+ facetState: fakeFacetState,
103
+ language: 'en',
104
+ clientId: 'visitor-id',
105
+ ...expectOrigins(),
106
+ });
107
+ };
108
+
109
+ const expectMatchCustomEventPayload = (
110
+ actionCause: SearchPageEvents | InsightEvents,
111
+ meta = {}
112
+ ) => {
113
+ const body: string = lastCallBody(fetchMock);
114
+ const customData = {foo: 'bar', ...meta};
115
+ expect(JSON.parse(body)).toMatchObject({
116
+ eventValue: actionCause,
117
+ eventType: CustomEventsTypes[actionCause],
118
+ lastSearchQueryUid: 'my-uid',
119
+ customData,
120
+ language: 'en',
121
+ clientId: 'visitor-id',
122
+ ...expectOrigins(),
123
+ });
124
+ };
125
+
126
+ const expectMatchDocumentPayload = (
127
+ actionCause: SearchPageEvents,
128
+ doc: PartialDocumentInformation,
129
+ meta = {}
130
+ ) => {
131
+ const body: string = lastCallBody(fetchMock);
132
+ const customData = {foo: 'bar', ...meta};
133
+ expect(JSON.parse(body.toString())).toMatchObject({
134
+ actionCause,
135
+ customData,
136
+ language: 'en',
137
+ clientId: 'visitor-id',
138
+ ...doc,
139
+ ...expectOrigins(),
140
+ });
141
+ };
142
+
143
+ const fakeDocInfo = {
144
+ collectionName: 'collection',
145
+ documentCategory: 'category',
146
+ documentAuthor: 'author',
147
+ documentPosition: 1,
148
+ documentTitle: 'title',
149
+ documentUri: 'uri',
150
+ documentUriHash: 'hash',
151
+ documentUrl: 'url',
152
+ queryPipeline: 'my-pipeline',
153
+ rankingModifier: 'modifier',
154
+ sourceName: 'source',
155
+ };
156
+
157
+ const fakeDocID = {
158
+ contentIDKey: 'permanentID',
159
+ contentIDValue: 'the-permanent-id',
160
+ };
161
+
162
+ beforeEach(() => {
163
+ fetchMockBeforeEach();
164
+
165
+ client = initClient();
166
+ client.coveoAnalyticsClient.runtime.storage.setItem('visitorId', 'visitor-id');
167
+ fetchMock.mock(/.*/, {
168
+ visitId: 'visit-id',
169
+ });
170
+ });
171
+
172
+ afterEach(() => {
173
+ fetchMock.reset();
174
+ });
175
+
176
+ describe('when the case metadata is not included', () => {
177
+ it('should send proper payload for #interfaceLoad', async () => {
178
+ await client.logInterfaceLoad();
179
+ expectMatchPayload(SearchPageEvents.interfaceLoad);
180
+ });
181
+
182
+ it('should send proper payload for #recentQueryClick', async () => {
183
+ await client.logRecentQueryClick();
184
+ expectMatchPayload(SearchPageEvents.recentQueryClick);
185
+ });
186
+
187
+ it('should send proper payload for #clearRecentQueries', async () => {
188
+ await client.logClearRecentQueries();
189
+ expectMatchCustomEventPayload(SearchPageEvents.clearRecentQueries);
190
+ });
191
+
192
+ it('should send proper payload for #interfaceChange', async () => {
193
+ await client.logInterfaceChange({
194
+ interfaceChangeTo: 'bob',
195
+ });
196
+ expectMatchPayload(SearchPageEvents.interfaceChange, {
197
+ interfaceChangeTo: 'bob',
198
+ });
199
+ });
200
+
201
+ it('should send proper payload for #fetchMoreResults', async () => {
202
+ await client.logFetchMoreResults();
203
+ expectMatchCustomEventPayload(SearchPageEvents.pagerScrolling, {
204
+ type: 'getMoreResults',
205
+ });
206
+ });
207
+
208
+ it('should send proper payload for #staticFilterDeselect', async () => {
209
+ const meta: StaticFilterToggleValueMetadata = {
210
+ staticFilterId: 'filetypes',
211
+ staticFilterValue: {
212
+ caption: 'Youtube',
213
+ expression: '@filetype="youtubevideo"',
50
214
  },
51
- ];
52
-
53
- let client: CoveoInsightClient;
54
-
55
- const provider: InsightClientProvider = {
56
- getBaseMetadata: () => ({foo: 'bar'}),
57
- getSearchEventRequestPayload: () => ({
58
- queryText: 'queryText',
59
- responseTime: 123,
60
- }),
61
- getSearchUID: () => 'my-uid',
62
- getPipeline: () => 'my-pipeline',
63
- getOriginContext: () => 'origin-context',
64
- getOriginLevel1: () => 'origin-level-1',
65
- getOriginLevel2: () => 'origin-level-2',
66
- getOriginLevel3: () => 'origin-level-3',
67
- getLanguage: () => 'en',
68
- getFacetState: () => fakeFacetState,
69
- getIsAnonymous: () => false,
70
- getGeneratedAnswerMetadata: () => ({genratedAnswerMetadata: 'foo'}),
71
- };
215
+ };
216
+ await client.logStaticFilterDeselect(meta);
72
217
 
73
- const initClient = () => {
74
- return new CoveoInsightClient({}, provider);
75
- };
218
+ expectMatchPayload(SearchPageEvents.staticFilterDeselect, meta);
219
+ });
76
220
 
77
- const expectOrigins = () => ({
78
- originContext: 'origin-context',
79
- originLevel1: 'origin-level-1',
80
- originLevel2: 'origin-level-2',
81
- originLevel3: 'origin-level-3',
82
- });
83
-
84
- const expectMatchPayload = (actionCause: SearchPageEvents | InsightEvents, meta = {}) => {
85
- const body: string = lastCallBody(fetchMock);
86
- const customData = {foo: 'bar', genratedAnswerMetadata: 'foo', ...meta};
87
- expect(JSON.parse(body)).toMatchObject({
88
- queryText: 'queryText',
89
- responseTime: 123,
90
- queryPipeline: 'my-pipeline',
91
- actionCause,
92
- customData,
93
- facetState: fakeFacetState,
94
- language: 'en',
95
- clientId: 'visitor-id',
96
- ...expectOrigins(),
97
- });
98
- };
221
+ it('should send proper payload for #breadcrumbResetAll', async () => {
222
+ await client.logBreadcrumbResetAll();
223
+ expectMatchPayload(SearchPageEvents.breadcrumbResetAll);
224
+ });
99
225
 
100
- const expectMatchCustomEventPayload = (actionCause: SearchPageEvents | InsightEvents, meta = {}) => {
101
- const body: string = lastCallBody(fetchMock);
102
- const customData = {foo: 'bar', ...meta};
103
- expect(JSON.parse(body)).toMatchObject({
104
- eventValue: actionCause,
105
- eventType: CustomEventsTypes[actionCause],
106
- lastSearchQueryUid: 'my-uid',
107
- customData,
108
- language: 'en',
109
- clientId: 'visitor-id',
110
- ...expectOrigins(),
111
- });
112
- };
226
+ it('should send proper payload for #breadcrumbFacet', async () => {
227
+ const meta = {
228
+ facetField: '@foo',
229
+ facetId: 'bar',
230
+ facetTitle: 'title',
231
+ facetValue: 'qwerty',
232
+ };
233
+ await client.logBreadcrumbFacet(meta);
234
+ expectMatchPayload(SearchPageEvents.breadcrumbFacet, meta);
235
+ });
113
236
 
114
- const expectMatchDocumentPayload = (actionCause: SearchPageEvents, doc: PartialDocumentInformation, meta = {}) => {
115
- const body: string = lastCallBody(fetchMock);
116
- const customData = {foo: 'bar', ...meta};
117
- expect(JSON.parse(body.toString())).toMatchObject({
118
- actionCause,
119
- customData,
120
- language: 'en',
121
- clientId: 'visitor-id',
122
- ...doc,
123
- ...expectOrigins(),
124
- });
125
- };
237
+ it('should send proper payload for #logFacetSelect', async () => {
238
+ const meta = {
239
+ facetField: '@foo',
240
+ facetId: 'bar',
241
+ facetTitle: 'title',
242
+ facetValue: 'qwerty',
243
+ };
244
+
245
+ await client.logFacetSelect(meta);
246
+ expectMatchPayload(SearchPageEvents.facetSelect, meta);
247
+ });
248
+
249
+ it('should send proper payload for #logFacetExclude', async () => {
250
+ const meta = {
251
+ facetField: '@foo',
252
+ facetId: 'bar',
253
+ facetTitle: 'title',
254
+ facetValue: 'qwerty',
255
+ };
256
+
257
+ await client.logFacetExclude(meta);
258
+ expectMatchPayload(SearchPageEvents.facetExclude, meta);
259
+ });
260
+
261
+ it('should send proper payload for #logFacetDeselect', async () => {
262
+ const meta = {
263
+ facetField: '@foo',
264
+ facetId: 'bar',
265
+ facetTitle: 'title',
266
+ facetValue: 'qwerty',
267
+ };
268
+
269
+ await client.logFacetDeselect(meta);
270
+ expectMatchPayload(SearchPageEvents.facetDeselect, meta);
271
+ });
272
+
273
+ it('should send proper payload for #logFacetUpdateSort', async () => {
274
+ const meta = {
275
+ facetField: '@foo',
276
+ facetId: 'bar',
277
+ facetTitle: 'title',
278
+ criteria: 'bazz',
279
+ };
280
+ await client.logFacetUpdateSort(meta);
281
+ expectMatchPayload(SearchPageEvents.facetUpdateSort, meta);
282
+ });
283
+
284
+ it('should send proper payload for #logFacetClearAll', async () => {
285
+ const meta = {
286
+ facetField: '@foo',
287
+ facetId: 'bar',
288
+ facetTitle: 'title',
289
+ };
290
+ await client.logFacetClearAll(meta);
291
+ expectMatchPayload(SearchPageEvents.facetClearAll, meta);
292
+ });
293
+
294
+ it('should send proper payload for #logFacetShowMore', async () => {
295
+ const meta = {
296
+ facetField: '@foo',
297
+ facetId: 'bar',
298
+ facetTitle: 'title',
299
+ };
300
+ await client.logFacetShowMore(meta);
301
+ expectMatchCustomEventPayload(SearchPageEvents.facetShowMore, meta);
302
+ });
303
+
304
+ it('should send proper payload for #logFacetShowLess', async () => {
305
+ const meta = {
306
+ facetField: '@foo',
307
+ facetId: 'bar',
308
+ facetTitle: 'title',
309
+ };
310
+ await client.logFacetShowLess(meta);
311
+ expectMatchCustomEventPayload(SearchPageEvents.facetShowLess, meta);
312
+ });
313
+
314
+ it('should send proper payload for #logQueryError', async () => {
315
+ const meta = {
316
+ query: 'q',
317
+ aq: 'aq',
318
+ cq: 'cq',
319
+ dq: 'dq',
320
+ errorMessage: 'boom',
321
+ errorType: 'a bad one',
322
+ };
323
+ await client.logQueryError(meta);
324
+ expectMatchCustomEventPayload(SearchPageEvents.queryError, meta);
325
+ });
326
+
327
+ it('should send proper payload for #logPagerNumber', async () => {
328
+ const meta = {pagerNumber: 123};
329
+ await client.logPagerNumber(meta);
330
+ expectMatchCustomEventPayload(SearchPageEvents.pagerNumber, meta);
331
+ });
332
+
333
+ it('should send proper payload for #logPagerNext', async () => {
334
+ const meta = {pagerNumber: 123};
335
+ await client.logPagerNext(meta);
336
+ expectMatchCustomEventPayload(SearchPageEvents.pagerNext, meta);
337
+ });
338
+
339
+ it('should send proper payload for #logPagerPrevious', async () => {
340
+ const meta = {pagerNumber: 123};
341
+ await client.logPagerPrevious(meta);
342
+ expectMatchCustomEventPayload(SearchPageEvents.pagerPrevious, meta);
343
+ });
344
+
345
+ it('should send proper payload for #didyoumeanAutomatic', async () => {
346
+ await client.logDidYouMeanAutomatic();
347
+ expectMatchPayload(SearchPageEvents.didyoumeanAutomatic);
348
+ });
349
+
350
+ it('should send proper payload for #didyoumeanClick', async () => {
351
+ await client.logDidYouMeanClick();
352
+ expectMatchPayload(SearchPageEvents.didyoumeanClick);
353
+ });
354
+
355
+ it('should send proper payload for #resultsSort', async () => {
356
+ await client.logResultsSort({resultsSortBy: 'date ascending'});
357
+ expectMatchPayload(SearchPageEvents.resultsSort, {
358
+ resultsSortBy: 'date ascending',
359
+ });
360
+ });
361
+
362
+ it('should send proper payload for #searchboxSubmit', async () => {
363
+ await client.logSearchboxSubmit();
364
+ expectMatchPayload(SearchPageEvents.searchboxSubmit);
365
+ });
366
+
367
+ it('should send proper payload for #documentOpen', async () => {
368
+ await client.logDocumentOpen(fakeDocInfo, fakeDocID);
369
+ expectMatchDocumentPayload(SearchPageEvents.documentOpen, fakeDocInfo, fakeDocID);
370
+ });
371
+
372
+ it('should send proper payload for #copyToClipboard', async () => {
373
+ await client.logCopyToClipboard(fakeDocInfo, fakeDocID);
374
+ expectMatchDocumentPayload(SearchPageEvents.copyToClipboard, fakeDocInfo, fakeDocID);
375
+ });
376
+
377
+ it('should send proper payload for #caseSendEmail', async () => {
378
+ await client.logCaseSendEmail(fakeDocInfo, fakeDocID);
379
+ expectMatchDocumentPayload(SearchPageEvents.caseSendEmail, fakeDocInfo, fakeDocID);
380
+ });
381
+
382
+ it('should send proper payload for #feedItemTextPost', async () => {
383
+ await client.logFeedItemTextPost(fakeDocInfo, fakeDocID);
384
+ expectMatchDocumentPayload(SearchPageEvents.feedItemTextPost, fakeDocInfo, fakeDocID);
385
+ });
386
+
387
+ it('should send proper payload for #documentQuickview', async () => {
388
+ const expectedMetadata = {
389
+ ...fakeDocID,
390
+ documentTitle: fakeDocInfo.documentTitle,
391
+ documentURL: fakeDocInfo.documentUrl,
392
+ };
393
+ await client.logDocumentQuickview(fakeDocInfo, fakeDocID);
394
+ expectMatchDocumentPayload(SearchPageEvents.documentQuickview, fakeDocInfo, expectedMetadata);
395
+ });
396
+
397
+ it('should send proper payload for #caseAttach', async () => {
398
+ const expectedMetadata = {
399
+ ...fakeDocID,
400
+ documentTitle: fakeDocInfo.documentTitle,
401
+ documentURL: fakeDocInfo.documentUrl,
402
+ resultUriHash: fakeDocInfo.documentUriHash,
403
+ };
404
+ await client.logCaseAttach(fakeDocInfo, fakeDocID);
405
+ expectMatchDocumentPayload(SearchPageEvents.caseAttach, fakeDocInfo, expectedMetadata);
406
+ });
407
+
408
+ it('should send proper payload for #caseDetach', async () => {
409
+ const mockResultUriHash = fakeDocInfo.documentUriHash;
410
+ const mockPermanentId = fakeDocID.contentIDValue;
411
+ const expectedMetadata = {
412
+ resultUriHash: mockResultUriHash,
413
+ permanentId: mockPermanentId,
414
+ };
415
+ await client.logCaseDetach(mockResultUriHash, undefined, mockPermanentId);
416
+ expectMatchCustomEventPayload(SearchPageEvents.caseDetach, expectedMetadata);
417
+ });
418
+
419
+ it('should send proper payload for #likeSmartSnippet', async () => {
420
+ await client.logLikeSmartSnippet();
421
+ expectMatchCustomEventPayload(SearchPageEvents.likeSmartSnippet);
422
+ });
126
423
 
127
- const fakeDocInfo = {
128
- collectionName: 'collection',
129
- documentCategory: 'category',
130
- documentAuthor: 'author',
131
- documentPosition: 1,
132
- documentTitle: 'title',
133
- documentUri: 'uri',
134
- documentUriHash: 'hash',
135
- documentUrl: 'url',
136
- queryPipeline: 'my-pipeline',
137
- rankingModifier: 'modifier',
138
- sourceName: 'source',
424
+ it('should send proper payload for #dislikeSmartSnippet', async () => {
425
+ await client.logDislikeSmartSnippet();
426
+ expectMatchCustomEventPayload(SearchPageEvents.dislikeSmartSnippet);
427
+ });
428
+
429
+ it('should send proper payload for #expandSmartSnippet', async () => {
430
+ await client.logExpandSmartSnippet();
431
+ expectMatchCustomEventPayload(SearchPageEvents.expandSmartSnippet);
432
+ });
433
+
434
+ it('should send proper payload for #collapseSmartSnippet', async () => {
435
+ await client.logCollapseSmartSnippet();
436
+ expectMatchCustomEventPayload(SearchPageEvents.collapseSmartSnippet);
437
+ });
438
+
439
+ it('should send proper payload for #openSmartSnippetFeedbackModal', async () => {
440
+ await client.logOpenSmartSnippetFeedbackModal();
441
+ expectMatchCustomEventPayload(SearchPageEvents.openSmartSnippetFeedbackModal);
442
+ });
443
+
444
+ it('should send proper payload for #closeSmartSnippetFeedbackModal', async () => {
445
+ await client.logCloseSmartSnippetFeedbackModal();
446
+ expectMatchCustomEventPayload(SearchPageEvents.closeSmartSnippetFeedbackModal);
447
+ });
448
+
449
+ it('should send proper payload for #sendSmartSnippetReason', async () => {
450
+ const reason = 'other';
451
+ const details = 'example details';
452
+ const expectedMetadata = {
453
+ reason,
454
+ details,
455
+ };
456
+
457
+ await client.logSmartSnippetFeedbackReason(reason, details);
458
+ expectMatchCustomEventPayload(SearchPageEvents.sendSmartSnippetReason, expectedMetadata);
459
+ });
460
+
461
+ it('should send proper payload for #expandSmartSnippetSuggestion', async () => {
462
+ const exampleSmartSnippetSuggestion = {
463
+ question: 'Abc',
464
+ answerSnippet: 'Def',
465
+ documentId: {contentIdKey: 'permanentid', contentIdValue: 'foo'},
466
+ };
467
+
468
+ await client.logExpandSmartSnippetSuggestion(exampleSmartSnippetSuggestion);
469
+ expectMatchCustomEventPayload(
470
+ SearchPageEvents.expandSmartSnippetSuggestion,
471
+ exampleSmartSnippetSuggestion
472
+ );
473
+ });
474
+
475
+ it('should send proper payload for #collapseSmartSnippetSuggestion', async () => {
476
+ const exampleSmartSnippetSuggestion = {
477
+ question: 'Abc',
478
+ answerSnippet: 'Def',
479
+ documentId: {contentIdKey: 'permanentid', contentIdValue: 'foo'},
480
+ };
481
+
482
+ await client.logCollapseSmartSnippetSuggestion(exampleSmartSnippetSuggestion);
483
+ expectMatchCustomEventPayload(
484
+ SearchPageEvents.collapseSmartSnippetSuggestion,
485
+ exampleSmartSnippetSuggestion
486
+ );
487
+ });
488
+
489
+ it('should send proper payload for #openSmartSnippetSource', async () => {
490
+ await client.logOpenSmartSnippetSource(fakeDocInfo, fakeDocID);
491
+ expectMatchDocumentPayload(SearchPageEvents.openSmartSnippetSource, fakeDocInfo, fakeDocID);
492
+ });
493
+
494
+ it('should send proper payload for #openSmartSnippetInlineLink', async () => {
495
+ const meta = {
496
+ ...fakeDocID,
497
+ linkText: 'Some text',
498
+ linkURL: 'https://invalid.com',
499
+ };
500
+
501
+ await client.logOpenSmartSnippetInlineLink(fakeDocInfo, meta);
502
+ expectMatchDocumentPayload(SearchPageEvents.openSmartSnippetInlineLink, fakeDocInfo, meta);
503
+ });
504
+
505
+ it('should send proper payload for #openSmartSnippetSuggestionSource', async () => {
506
+ const meta = {
507
+ question: 'Abc',
508
+ answerSnippet: 'Def',
509
+ documentId: {contentIdKey: 'permanentid', contentIdValue: 'foo'},
510
+ };
511
+
512
+ const expectedMetadata = {
513
+ ...meta,
514
+ contentIDKey: meta.documentId.contentIdKey,
515
+ contentIDValue: meta.documentId.contentIdValue,
516
+ };
517
+
518
+ await client.logOpenSmartSnippetSuggestionSource(fakeDocInfo, meta);
519
+ expectMatchDocumentPayload(
520
+ SearchPageEvents.openSmartSnippetSuggestionSource,
521
+ fakeDocInfo,
522
+ expectedMetadata
523
+ );
524
+ });
525
+
526
+ it('should send proper payload for #openSmartSnippetSuggestionInlineLink', async () => {
527
+ const meta = {
528
+ question: 'Abc',
529
+ answerSnippet: 'Def',
530
+ documentId: {contentIdKey: 'permanentid', contentIdValue: 'foo'},
531
+ linkText: 'Some text',
532
+ linkURL: 'https://invalid.com',
533
+ };
534
+ const expectedMetadata = {
535
+ ...meta,
536
+ contentIDKey: meta.documentId.contentIdKey,
537
+ contentIDValue: meta.documentId.contentIdValue,
538
+ };
539
+
540
+ await client.logOpenSmartSnippetSuggestionInlineLink(fakeDocInfo, meta);
541
+ expectMatchDocumentPayload(
542
+ SearchPageEvents.openSmartSnippetSuggestionInlineLink,
543
+ fakeDocInfo,
544
+ expectedMetadata
545
+ );
546
+ });
547
+ it('should send proper payload for #showMoreFoldedResults', async () => {
548
+ await client.logShowMoreFoldedResults(fakeDocInfo, fakeDocID);
549
+ expectMatchDocumentPayload(SearchPageEvents.showMoreFoldedResults, fakeDocInfo, fakeDocID);
550
+ });
551
+
552
+ it('should send proper payload for #showLessFoldedResults', async () => {
553
+ await client.logShowLessFoldedResults();
554
+ expectMatchCustomEventPayload(SearchPageEvents.showLessFoldedResults);
555
+ });
556
+
557
+ it('should send proper payload for #likeGeneratedAnswer', async () => {
558
+ const exampleGeneratedAnswerMetadata = {
559
+ generativeQuestionAnsweringId: '123',
560
+ };
561
+
562
+ await client.logLikeGeneratedAnswer(exampleGeneratedAnswerMetadata);
563
+ expectMatchCustomEventPayload(
564
+ SearchPageEvents.likeGeneratedAnswer,
565
+ exampleGeneratedAnswerMetadata
566
+ );
567
+ });
568
+
569
+ it('should send proper payload for #dislikeGeneratedAnswer', async () => {
570
+ const exampleGeneratedAnswerMetadata = {
571
+ generativeQuestionAnsweringId: '123',
572
+ };
573
+
574
+ await client.logDislikeGeneratedAnswer(exampleGeneratedAnswerMetadata);
575
+ expectMatchCustomEventPayload(
576
+ SearchPageEvents.dislikeGeneratedAnswer,
577
+ exampleGeneratedAnswerMetadata
578
+ );
579
+ });
580
+
581
+ it('should send proper payload for #openGeneratedAnswerSource', async () => {
582
+ const exampleGeneratedAnswerMetadata = {
583
+ generativeQuestionAnsweringId: '123',
584
+ permanentId: 'foo',
585
+ citationId: 'bar',
586
+ };
587
+
588
+ await client.logOpenGeneratedAnswerSource(exampleGeneratedAnswerMetadata);
589
+ expectMatchCustomEventPayload(
590
+ SearchPageEvents.openGeneratedAnswerSource,
591
+ exampleGeneratedAnswerMetadata
592
+ );
593
+ });
594
+
595
+ it('should send proper payload for #generatedAnswerCitationClick', async () => {
596
+ const meta = {
597
+ generativeQuestionAnsweringId: '123',
598
+ citationId: 'bar',
599
+ documentId: {contentIdKey: 'permanentid', contentIdValue: 'foo'},
600
+ };
601
+
602
+ const expectedMetadata = {
603
+ ...meta,
604
+ contentIDKey: meta.documentId.contentIdKey,
605
+ contentIDValue: meta.documentId.contentIdValue,
606
+ };
607
+
608
+ await client.logGeneratedAnswerCitationClick(fakeDocInfo, meta);
609
+ expectMatchDocumentPayload(
610
+ SearchPageEvents.generatedAnswerCitationClick,
611
+ fakeDocInfo,
612
+ expectedMetadata
613
+ );
614
+ });
615
+
616
+ it('should send proper payload for #generatedAnswerSourceHover', async () => {
617
+ const exampleGeneratedAnswerMetadata = {
618
+ generativeQuestionAnsweringId: '123',
619
+ permanentId: 'foo',
620
+ citationId: 'bar',
621
+ citationHoverTimeMs: 100,
622
+ };
623
+
624
+ await client.logGeneratedAnswerSourceHover(exampleGeneratedAnswerMetadata);
625
+ expectMatchCustomEventPayload(
626
+ SearchPageEvents.generatedAnswerSourceHover,
627
+ exampleGeneratedAnswerMetadata
628
+ );
629
+ });
630
+
631
+ it('should send proper payload for #generatedAnswerCopyToClipboard', async () => {
632
+ const exampleGeneratedAnswerMetadata = {
633
+ generativeQuestionAnsweringId: '123',
634
+ };
635
+
636
+ await client.logGeneratedAnswerCopyToClipboard(exampleGeneratedAnswerMetadata);
637
+ expectMatchCustomEventPayload(
638
+ SearchPageEvents.generatedAnswerCopyToClipboard,
639
+ exampleGeneratedAnswerMetadata
640
+ );
641
+ });
642
+
643
+ it('should send proper payload for #generatedAnswerHideAnswers', async () => {
644
+ const exampleGeneratedAnswerMetadata = {
645
+ generativeQuestionAnsweringId: '123',
646
+ };
647
+
648
+ await client.logGeneratedAnswerHideAnswers(exampleGeneratedAnswerMetadata);
649
+ expectMatchCustomEventPayload(
650
+ SearchPageEvents.generatedAnswerHideAnswers,
651
+ exampleGeneratedAnswerMetadata
652
+ );
653
+ });
654
+
655
+ it('should send proper payload for #generatedAnswerShowAnswers', async () => {
656
+ const exampleGeneratedAnswerMetadata = {
657
+ generativeQuestionAnsweringId: '123',
658
+ };
659
+
660
+ await client.logGeneratedAnswerShowAnswers(exampleGeneratedAnswerMetadata);
661
+ expectMatchCustomEventPayload(
662
+ SearchPageEvents.generatedAnswerShowAnswers,
663
+ exampleGeneratedAnswerMetadata
664
+ );
665
+ });
666
+
667
+ it('should send proper payload for #generatedAnswerExpand', async () => {
668
+ const exampleGeneratedAnswerMetadata = {
669
+ generativeQuestionAnsweringId: '123',
670
+ };
671
+
672
+ await client.logGeneratedAnswerExpand(exampleGeneratedAnswerMetadata);
673
+ expectMatchCustomEventPayload(
674
+ SearchPageEvents.generatedAnswerExpand,
675
+ exampleGeneratedAnswerMetadata
676
+ );
677
+ });
678
+
679
+ it('should send proper payload for #generatedAnswerCollapse', async () => {
680
+ const exampleGeneratedAnswerMetadata = {
681
+ generativeQuestionAnsweringId: '123',
682
+ };
683
+
684
+ await client.logGeneratedAnswerCollapse(exampleGeneratedAnswerMetadata);
685
+ expectMatchCustomEventPayload(
686
+ SearchPageEvents.generatedAnswerCollapse,
687
+ exampleGeneratedAnswerMetadata
688
+ );
689
+ });
690
+
691
+ it('should send proper payload for #generatedAnswerFeedbackSubmit', async () => {
692
+ const exampleGeneratedAnswerMetadata = {
693
+ generativeQuestionAnsweringId: '123',
694
+ reason: <GeneratedAnswerFeedbackReason>'other',
695
+ details: 'foo',
696
+ };
697
+
698
+ await client.logGeneratedAnswerFeedbackSubmit(exampleGeneratedAnswerMetadata);
699
+ expectMatchCustomEventPayload(
700
+ SearchPageEvents.generatedAnswerFeedbackSubmit,
701
+ exampleGeneratedAnswerMetadata
702
+ );
703
+ });
704
+
705
+ it('should send proper payload for #rephraseGeneratedAnswer', async () => {
706
+ const exampleGeneratedAnswerMetadata = {
707
+ generativeQuestionAnsweringId: '123',
708
+ rephraseFormat: <GeneratedAnswerRephraseFormat>'step',
709
+ };
710
+
711
+ await client.logRephraseGeneratedAnswer(exampleGeneratedAnswerMetadata);
712
+ expectMatchPayload(SearchPageEvents.rephraseGeneratedAnswer, exampleGeneratedAnswerMetadata);
713
+ });
714
+
715
+ it('should send proper payload for #retryGeneratedAnswer', async () => {
716
+ await client.logRetryGeneratedAnswer();
717
+ expectMatchPayload(SearchPageEvents.retryGeneratedAnswer);
718
+ });
719
+
720
+ it('should send proper payload for #generatedAnswerStreamEnd', async () => {
721
+ const exampleGeneratedAnswerMetadata = {
722
+ generativeQuestionAnsweringId: '123',
723
+ answerGenerated: true,
724
+ answerTextIsEmpty: false,
725
+ };
726
+
727
+ await client.logGeneratedAnswerStreamEnd(exampleGeneratedAnswerMetadata);
728
+ expectMatchCustomEventPayload(
729
+ SearchPageEvents.generatedAnswerStreamEnd,
730
+ exampleGeneratedAnswerMetadata
731
+ );
732
+ });
733
+
734
+ it('should send proper payload for #generatedAnswerCitationDocumentAttach', async () => {
735
+ const meta = {
736
+ generativeQuestionAnsweringId: '123',
737
+ citationId: 'bar',
738
+ documentId: {contentIdKey: 'permanentid', contentIdValue: 'foo'},
739
+ };
740
+
741
+ const expectedMetadata = {
742
+ ...meta,
743
+ contentIDKey: meta.documentId.contentIdKey,
744
+ contentIDValue: meta.documentId.contentIdValue,
745
+ };
746
+
747
+ await client.logGeneratedAnswerCitationDocumentAttach(fakeDocInfo, meta);
748
+ expectMatchDocumentPayload(
749
+ SearchPageEvents.generatedAnswerCitationDocumentAttach,
750
+ fakeDocInfo,
751
+ expectedMetadata
752
+ );
753
+ });
754
+
755
+ it('should send proper payload for #createArticle', async () => {
756
+ const exampleCreateArticleMetadata = {
757
+ articleType: 'Knowledge__kav',
758
+ triggeredBy: 'CreateArticleButton',
759
+ };
760
+ await client.logCreateArticle(exampleCreateArticleMetadata);
761
+ expectMatchCustomEventPayload(InsightEvents.createArticle, exampleCreateArticleMetadata);
762
+ });
763
+
764
+ it('should send proper payload for #logTriggerNotify', async () => {
765
+ const exampleTriggerNotifyMetadata = {
766
+ notifications: ['foo', 'bar'],
767
+ };
768
+ await client.logTriggerNotify(exampleTriggerNotifyMetadata);
769
+ expectMatchCustomEventPayload(SearchPageEvents.triggerNotify, exampleTriggerNotifyMetadata);
770
+ });
771
+
772
+ it('should send proper payload for #generatedAnswerFeedbackSubmitV2', async () => {
773
+ const exampleGeneratedAnswerMetadata = {
774
+ generativeQuestionAnsweringId: '123',
775
+ helpful: true,
776
+ readable: <GeneratedAnswerFeedbackReasonOption>'yes',
777
+ documented: <GeneratedAnswerFeedbackReasonOption>'no',
778
+ correctTopic: <GeneratedAnswerFeedbackReasonOption>'unknown',
779
+ hallucinationFree: <GeneratedAnswerFeedbackReasonOption>'yes',
780
+ details: 'foo',
781
+ documentUrl: 'https://document.com',
782
+ };
783
+
784
+ await client.logGeneratedAnswerFeedbackSubmitV2(exampleGeneratedAnswerMetadata);
785
+ expectMatchCustomEventPayload(
786
+ SearchPageEvents.generatedAnswerFeedbackSubmitV2,
787
+ exampleGeneratedAnswerMetadata
788
+ );
789
+ });
790
+ });
791
+
792
+ describe('when the case metadata is included', () => {
793
+ it('should send proper payload for #interfaceLoad', async () => {
794
+ const metadata = baseCaseMetadata;
795
+
796
+ const expectedMetadata = {
797
+ ...expectedBaseCaseMetadata,
798
+ context_Case_Subject: 'test subject',
799
+ context_Case_Description: 'test description',
800
+ };
801
+ await client.logInterfaceLoad(metadata);
802
+ expectMatchPayload(SearchPageEvents.interfaceLoad, expectedMetadata);
803
+ });
804
+
805
+ it('should send proper payload for #recentQueryClick', async () => {
806
+ const metadata = baseCaseMetadata;
807
+
808
+ const expectedMetadata = {
809
+ ...expectedBaseCaseMetadata,
810
+ context_Case_Subject: 'test subject',
811
+ context_Case_Description: 'test description',
812
+ };
813
+ await client.logRecentQueryClick(metadata);
814
+ expectMatchPayload(SearchPageEvents.recentQueryClick, expectedMetadata);
815
+ });
816
+
817
+ it('should send proper payload for #clearRecentQueries', async () => {
818
+ const metadata = baseCaseMetadata;
819
+
820
+ const expectedMetadata = {
821
+ ...expectedBaseCaseMetadata,
822
+ context_Case_Subject: 'test subject',
823
+ context_Case_Description: 'test description',
824
+ };
825
+ await client.logClearRecentQueries(metadata);
826
+ expectMatchCustomEventPayload(SearchPageEvents.clearRecentQueries, expectedMetadata);
827
+ });
828
+
829
+ it('should send proper payload for #interfaceChange', async () => {
830
+ const metadata = {
831
+ ...baseCaseMetadata,
832
+ interfaceChangeTo: 'bob',
833
+ };
834
+
835
+ const expectedMetadata = {
836
+ ...expectedBaseCaseMetadata,
837
+ context_Case_Subject: 'test subject',
838
+ context_Case_Description: 'test description',
839
+ interfaceChangeTo: 'bob',
840
+ };
841
+ await client.logInterfaceChange(metadata);
842
+ expectMatchPayload(SearchPageEvents.interfaceChange, expectedMetadata);
843
+ });
844
+
845
+ it('should send proper payload for #fetchMoreResults', async () => {
846
+ const metadata = {
847
+ ...baseCaseMetadata,
848
+ };
849
+
850
+ const expectedMetadata = {
851
+ ...expectedBaseCaseMetadata,
852
+ context_Case_Subject: 'test subject',
853
+ context_Case_Description: 'test description',
854
+ type: 'getMoreResults',
855
+ };
856
+ await client.logFetchMoreResults(metadata);
857
+ expectMatchCustomEventPayload(SearchPageEvents.pagerScrolling, expectedMetadata);
858
+ });
859
+
860
+ it('should send proper payload for #staticFilterDeselect', async () => {
861
+ const metadata: InsightStaticFilterToggleValueMetadata = {
862
+ ...baseCaseMetadata,
863
+ staticFilterId: 'filetypes',
864
+ staticFilterValue: {
865
+ caption: 'Youtube',
866
+ expression: '@filetype="youtubevideo"',
867
+ },
868
+ };
869
+
870
+ const expectedMetadata = {
871
+ ...expectedBaseCaseMetadata,
872
+ context_Case_Subject: 'test subject',
873
+ context_Case_Description: 'test description',
874
+ staticFilterId: 'filetypes',
875
+ staticFilterValue: {
876
+ caption: 'Youtube',
877
+ expression: '@filetype="youtubevideo"',
878
+ },
879
+ };
880
+ await client.logStaticFilterDeselect(metadata);
881
+
882
+ expectMatchPayload(SearchPageEvents.staticFilterDeselect, expectedMetadata);
883
+ });
884
+
885
+ it('should send proper payload for #breadcrumbResetAll', async () => {
886
+ const metadata = baseCaseMetadata;
887
+
888
+ const expectedMetadata = {
889
+ ...expectedBaseCaseMetadata,
890
+ context_Case_Subject: 'test subject',
891
+ context_Case_Description: 'test description',
892
+ };
893
+ await client.logBreadcrumbResetAll(metadata);
894
+ expectMatchPayload(SearchPageEvents.breadcrumbResetAll, expectedMetadata);
895
+ });
896
+
897
+ it('should send proper payload for #breadcrumbFacet', async () => {
898
+ const metadata = {
899
+ ...baseCaseMetadata,
900
+ facetField: '@foo',
901
+ facetId: 'bar',
902
+ facetTitle: 'title',
903
+ facetValue: 'qwerty',
904
+ };
905
+
906
+ const expectedMetadata = {
907
+ ...expectedBaseCaseMetadata,
908
+ context_Case_Subject: 'test subject',
909
+ context_Case_Description: 'test description',
910
+ facetField: '@foo',
911
+ facetId: 'bar',
912
+ facetTitle: 'title',
913
+ facetValue: 'qwerty',
914
+ };
915
+ await client.logBreadcrumbFacet(metadata);
916
+ expectMatchPayload(SearchPageEvents.breadcrumbFacet, expectedMetadata);
917
+ });
918
+
919
+ it('should send proper payload for #logFacetSelect', async () => {
920
+ const metadata = {
921
+ ...baseCaseMetadata,
922
+ facetField: '@foo',
923
+ facetId: 'bar',
924
+ facetTitle: 'title',
925
+ facetValue: 'qwerty',
926
+ };
927
+
928
+ const expectedMetadata = {
929
+ ...expectedBaseCaseMetadata,
930
+ context_Case_Subject: 'test subject',
931
+ context_Case_Description: 'test description',
932
+ facetField: '@foo',
933
+ facetId: 'bar',
934
+ facetTitle: 'title',
935
+ facetValue: 'qwerty',
936
+ };
937
+
938
+ await client.logFacetSelect(metadata);
939
+ expectMatchPayload(SearchPageEvents.facetSelect, expectedMetadata);
940
+ });
941
+
942
+ it('should send proper payload for #logFacetExclude', async () => {
943
+ const metadata = {
944
+ ...baseCaseMetadata,
945
+ facetField: '@foo',
946
+ facetId: 'bar',
947
+ facetTitle: 'title',
948
+ facetValue: 'qwerty',
949
+ };
950
+
951
+ const expectedMetadata = {
952
+ ...expectedBaseCaseMetadata,
953
+ context_Case_Subject: 'test subject',
954
+ context_Case_Description: 'test description',
955
+ facetField: '@foo',
956
+ facetId: 'bar',
957
+ facetTitle: 'title',
958
+ facetValue: 'qwerty',
959
+ };
960
+
961
+ await client.logFacetExclude(metadata);
962
+ expectMatchPayload(SearchPageEvents.facetExclude, expectedMetadata);
963
+ });
964
+
965
+ it('should send proper payload for #logFacetDeselect', async () => {
966
+ const metadata = {
967
+ ...baseCaseMetadata,
968
+ facetField: '@foo',
969
+ facetId: 'bar',
970
+ facetTitle: 'title',
971
+ facetValue: 'qwerty',
972
+ };
973
+
974
+ const expectedMetadata = {
975
+ ...expectedBaseCaseMetadata,
976
+ context_Case_Subject: 'test subject',
977
+ context_Case_Description: 'test description',
978
+ facetField: '@foo',
979
+ facetId: 'bar',
980
+ facetTitle: 'title',
981
+ facetValue: 'qwerty',
982
+ };
983
+
984
+ await client.logFacetDeselect(metadata);
985
+ expectMatchPayload(SearchPageEvents.facetDeselect, expectedMetadata);
986
+ });
987
+
988
+ it('should send proper payload for #logFacetUpdateSort', async () => {
989
+ const metadata = {
990
+ ...baseCaseMetadata,
991
+ facetField: '@foo',
992
+ facetId: 'bar',
993
+ facetTitle: 'title',
994
+ criteria: 'bazz',
995
+ };
996
+
997
+ const expectedMetadata = {
998
+ ...expectedBaseCaseMetadata,
999
+ context_Case_Subject: 'test subject',
1000
+ context_Case_Description: 'test description',
1001
+ facetField: '@foo',
1002
+ facetId: 'bar',
1003
+ facetTitle: 'title',
1004
+ criteria: 'bazz',
1005
+ };
1006
+ await client.logFacetUpdateSort(metadata);
1007
+ expectMatchPayload(SearchPageEvents.facetUpdateSort, expectedMetadata);
1008
+ });
1009
+
1010
+ it('should send proper payload for #logFacetClearAll', async () => {
1011
+ const metadata = {
1012
+ ...baseCaseMetadata,
1013
+ facetField: '@foo',
1014
+ facetId: 'bar',
1015
+ facetTitle: 'title',
1016
+ };
1017
+
1018
+ const expectedMetadata = {
1019
+ ...expectedBaseCaseMetadata,
1020
+ context_Case_Subject: 'test subject',
1021
+ context_Case_Description: 'test description',
1022
+ facetField: '@foo',
1023
+ facetId: 'bar',
1024
+ facetTitle: 'title',
1025
+ };
1026
+ await client.logFacetClearAll(metadata);
1027
+ expectMatchPayload(SearchPageEvents.facetClearAll, expectedMetadata);
1028
+ });
1029
+
1030
+ it('should send proper payload for #logFacetShowMore', async () => {
1031
+ const metadata = {
1032
+ ...baseCaseMetadata,
1033
+ facetField: '@foo',
1034
+ facetId: 'bar',
1035
+ facetTitle: 'title',
1036
+ };
1037
+
1038
+ const expectedMetadata = {
1039
+ ...expectedBaseCaseMetadata,
1040
+ facetField: '@foo',
1041
+ facetId: 'bar',
1042
+ facetTitle: 'title',
1043
+ };
1044
+ await client.logFacetShowMore(metadata);
1045
+ expectMatchCustomEventPayload(SearchPageEvents.facetShowMore, expectedMetadata);
1046
+ });
1047
+
1048
+ it('should send proper payload for #logFacetShowLess', async () => {
1049
+ const metadata = {
1050
+ ...baseCaseMetadata,
1051
+ facetField: '@foo',
1052
+ facetId: 'bar',
1053
+ facetTitle: 'title',
1054
+ };
1055
+
1056
+ const expectedMetadata = {
1057
+ ...expectedBaseCaseMetadata,
1058
+ facetField: '@foo',
1059
+ facetId: 'bar',
1060
+ facetTitle: 'title',
1061
+ };
1062
+ await client.logFacetShowLess(metadata);
1063
+ expectMatchCustomEventPayload(SearchPageEvents.facetShowLess, expectedMetadata);
1064
+ });
1065
+
1066
+ it('should send proper payload for #logQueryError', async () => {
1067
+ const metadata = {
1068
+ ...baseCaseMetadata,
1069
+ query: 'q',
1070
+ aq: 'aq',
1071
+ cq: 'cq',
1072
+ dq: 'dq',
1073
+ errorMessage: 'boom',
1074
+ errorType: 'a bad one',
1075
+ };
1076
+
1077
+ const expectedMetadata = {
1078
+ ...expectedBaseCaseMetadata,
1079
+ query: 'q',
1080
+ aq: 'aq',
1081
+ cq: 'cq',
1082
+ dq: 'dq',
1083
+ errorMessage: 'boom',
1084
+ errorType: 'a bad one',
1085
+ };
1086
+ await client.logQueryError(metadata);
1087
+ expectMatchCustomEventPayload(SearchPageEvents.queryError, expectedMetadata);
1088
+ });
1089
+
1090
+ it('should send proper payload for #logPagerNumber', async () => {
1091
+ const metadata = {
1092
+ ...baseCaseMetadata,
1093
+ pagerNumber: 123,
1094
+ };
1095
+
1096
+ const expectedMetadata = {
1097
+ ...expectedBaseCaseMetadata,
1098
+ pagerNumber: 123,
1099
+ };
1100
+ await client.logPagerNumber(metadata);
1101
+ expectMatchCustomEventPayload(SearchPageEvents.pagerNumber, expectedMetadata);
1102
+ });
1103
+
1104
+ it('should send proper payload for #logPagerNext', async () => {
1105
+ const metadata = {
1106
+ ...baseCaseMetadata,
1107
+ pagerNumber: 123,
1108
+ };
1109
+
1110
+ const expectedMetadata = {
1111
+ ...expectedBaseCaseMetadata,
1112
+ pagerNumber: 123,
1113
+ };
1114
+ await client.logPagerNext(metadata);
1115
+ expectMatchCustomEventPayload(SearchPageEvents.pagerNext, expectedMetadata);
1116
+ });
1117
+
1118
+ it('should send proper payload for #logPagerPrevious', async () => {
1119
+ const metadata = {
1120
+ ...baseCaseMetadata,
1121
+ pagerNumber: 123,
1122
+ };
1123
+
1124
+ const expectedMetadata = {
1125
+ ...expectedBaseCaseMetadata,
1126
+ pagerNumber: 123,
1127
+ };
1128
+ await client.logPagerPrevious(metadata);
1129
+ expectMatchCustomEventPayload(SearchPageEvents.pagerPrevious, expectedMetadata);
1130
+ });
1131
+
1132
+ it('should send proper payload for #didyoumeanAutomatic', async () => {
1133
+ const metadata = baseCaseMetadata;
1134
+
1135
+ const expectedMetadata = {
1136
+ ...expectedBaseCaseMetadata,
1137
+ context_Case_Subject: 'test subject',
1138
+ context_Case_Description: 'test description',
1139
+ };
1140
+ await client.logDidYouMeanAutomatic(metadata);
1141
+ expectMatchPayload(SearchPageEvents.didyoumeanAutomatic, expectedMetadata);
1142
+ });
1143
+
1144
+ it('should send proper payload for #didyoumeanClick', async () => {
1145
+ const metadata = baseCaseMetadata;
1146
+
1147
+ const expectedMetadata = {
1148
+ ...expectedBaseCaseMetadata,
1149
+ context_Case_Subject: 'test subject',
1150
+ context_Case_Description: 'test description',
1151
+ };
1152
+ await client.logDidYouMeanClick(metadata);
1153
+ expectMatchPayload(SearchPageEvents.didyoumeanClick, expectedMetadata);
1154
+ });
1155
+
1156
+ it('should send proper payload for #resultsSort', async () => {
1157
+ const metadata = {
1158
+ ...baseCaseMetadata,
1159
+ resultsSortBy: 'date ascending',
1160
+ };
1161
+
1162
+ const expectedMetadata = {
1163
+ ...expectedBaseCaseMetadata,
1164
+ context_Case_Subject: 'test subject',
1165
+ context_Case_Description: 'test description',
1166
+ resultsSortBy: 'date ascending',
1167
+ };
1168
+ await client.logResultsSort(metadata);
1169
+ expectMatchPayload(SearchPageEvents.resultsSort, expectedMetadata);
1170
+ });
1171
+
1172
+ it('should send proper payload for #searchboxSubmit', async () => {
1173
+ const metadata = baseCaseMetadata;
1174
+
1175
+ const expectedMetadata = {
1176
+ ...expectedBaseCaseMetadata,
1177
+ context_Case_Subject: 'test subject',
1178
+ context_Case_Description: 'test description',
1179
+ };
1180
+ await client.logSearchboxSubmit(metadata);
1181
+ expectMatchPayload(SearchPageEvents.searchboxSubmit, expectedMetadata);
1182
+ });
1183
+
1184
+ it('should send proper payload for #documentOpen', async () => {
1185
+ const metadata = baseCaseMetadata;
1186
+
1187
+ const expectedMetadata = {
1188
+ ...fakeDocID,
1189
+ ...expectedBaseCaseMetadata,
1190
+ };
1191
+ await client.logDocumentOpen(fakeDocInfo, fakeDocID, metadata);
1192
+ expectMatchDocumentPayload(SearchPageEvents.documentOpen, fakeDocInfo, expectedMetadata);
1193
+ });
1194
+
1195
+ it('should send proper payload for #copyToClipboard', async () => {
1196
+ const metadata = baseCaseMetadata;
1197
+
1198
+ const expectedMetadata = {
1199
+ ...fakeDocID,
1200
+ ...expectedBaseCaseMetadata,
1201
+ };
1202
+ await client.logCopyToClipboard(fakeDocInfo, fakeDocID, metadata);
1203
+ expectMatchDocumentPayload(SearchPageEvents.copyToClipboard, fakeDocInfo, expectedMetadata);
1204
+ });
1205
+
1206
+ it('should send proper payload for #caseSendEmail', async () => {
1207
+ const metadata = baseCaseMetadata;
1208
+
1209
+ const expectedMetadata = {
1210
+ ...fakeDocID,
1211
+ ...expectedBaseCaseMetadata,
1212
+ };
1213
+ await client.logCaseSendEmail(fakeDocInfo, fakeDocID, metadata);
1214
+ expectMatchDocumentPayload(SearchPageEvents.caseSendEmail, fakeDocInfo, expectedMetadata);
1215
+ });
1216
+
1217
+ it('should send proper payload for #feedItemTextPost', async () => {
1218
+ const metadata = baseCaseMetadata;
1219
+
1220
+ const expectedMetadata = {
1221
+ ...fakeDocID,
1222
+ ...expectedBaseCaseMetadata,
1223
+ };
1224
+ await client.logFeedItemTextPost(fakeDocInfo, fakeDocID, metadata);
1225
+ expectMatchDocumentPayload(SearchPageEvents.feedItemTextPost, fakeDocInfo, expectedMetadata);
1226
+ });
1227
+
1228
+ it('should send proper payload for #documentQuickview', async () => {
1229
+ const metadata = baseCaseMetadata;
1230
+
1231
+ const expectedMetadata = {
1232
+ ...fakeDocID,
1233
+ ...expectedBaseCaseMetadata,
1234
+ documentTitle: fakeDocInfo.documentTitle,
1235
+ documentURL: fakeDocInfo.documentUrl,
1236
+ };
1237
+ await client.logDocumentQuickview(fakeDocInfo, fakeDocID, metadata);
1238
+ expectMatchDocumentPayload(SearchPageEvents.documentQuickview, fakeDocInfo, expectedMetadata);
1239
+ });
1240
+
1241
+ it('should send proper payload for #caseAttach', async () => {
1242
+ const metadata = baseCaseMetadata;
1243
+
1244
+ const expectedMetadata = {
1245
+ ...fakeDocID,
1246
+ ...expectedBaseCaseMetadata,
1247
+ documentTitle: fakeDocInfo.documentTitle,
1248
+ documentURL: fakeDocInfo.documentUrl,
1249
+ resultUriHash: fakeDocInfo.documentUriHash,
1250
+ };
1251
+ await client.logCaseAttach(fakeDocInfo, fakeDocID, metadata);
1252
+ expectMatchDocumentPayload(SearchPageEvents.caseAttach, fakeDocInfo, expectedMetadata);
1253
+ });
1254
+
1255
+ it('should send proper payload for #caseDetach', async () => {
1256
+ const metadata = baseCaseMetadata;
1257
+ const mockResultUriHash = fakeDocInfo.documentUriHash;
1258
+ const mockPermanentId = fakeDocID.contentIDValue;
1259
+
1260
+ const expectedMetadata = {
1261
+ ...expectedBaseCaseMetadata,
1262
+ resultUriHash: mockResultUriHash,
1263
+ permanentId: mockPermanentId,
1264
+ };
1265
+ await client.logCaseDetach(mockResultUriHash, metadata, mockPermanentId);
1266
+ expectMatchCustomEventPayload(SearchPageEvents.caseDetach, expectedMetadata);
1267
+ });
1268
+
1269
+ it('should send proper payload for #likeSmartSnippet', async () => {
1270
+ await client.logLikeSmartSnippet(baseCaseMetadata);
1271
+ expectMatchCustomEventPayload(SearchPageEvents.likeSmartSnippet, expectedBaseCaseMetadata);
1272
+ });
1273
+
1274
+ it('should send proper payload for #dislikeSmartSnippet', async () => {
1275
+ await client.logDislikeSmartSnippet(baseCaseMetadata);
1276
+ expectMatchCustomEventPayload(SearchPageEvents.dislikeSmartSnippet, expectedBaseCaseMetadata);
1277
+ });
1278
+
1279
+ it('should send proper payload for #expandSmartSnippet', async () => {
1280
+ await client.logExpandSmartSnippet(baseCaseMetadata);
1281
+ expectMatchCustomEventPayload(SearchPageEvents.expandSmartSnippet, expectedBaseCaseMetadata);
1282
+ });
1283
+
1284
+ it('should send proper payload for #collapseSmartSnippet', async () => {
1285
+ await client.logCollapseSmartSnippet(baseCaseMetadata);
1286
+ expectMatchCustomEventPayload(
1287
+ SearchPageEvents.collapseSmartSnippet,
1288
+ expectedBaseCaseMetadata
1289
+ );
1290
+ });
1291
+
1292
+ it('should send proper payload for #openSmartSnippetFeedbackModal', async () => {
1293
+ await client.logOpenSmartSnippetFeedbackModal(baseCaseMetadata);
1294
+ expectMatchCustomEventPayload(
1295
+ SearchPageEvents.openSmartSnippetFeedbackModal,
1296
+ expectedBaseCaseMetadata
1297
+ );
1298
+ });
1299
+
1300
+ it('should send proper payload for #closeSmartSnippetFeedbackModal', async () => {
1301
+ await client.logCloseSmartSnippetFeedbackModal(baseCaseMetadata);
1302
+ expectMatchCustomEventPayload(
1303
+ SearchPageEvents.closeSmartSnippetFeedbackModal,
1304
+ expectedBaseCaseMetadata
1305
+ );
1306
+ });
1307
+
1308
+ it('should send proper payload for #sendSmartSnippetReason', async () => {
1309
+ const reason = 'other';
1310
+ const details = 'example details';
1311
+ const expectedMetadata = {
1312
+ reason,
1313
+ details,
1314
+ ...expectedBaseCaseMetadata,
1315
+ };
1316
+
1317
+ await client.logSmartSnippetFeedbackReason(reason, details, baseCaseMetadata);
1318
+ expectMatchCustomEventPayload(SearchPageEvents.sendSmartSnippetReason, expectedMetadata);
1319
+ });
1320
+
1321
+ it('should send proper payload for #expandSmartSnippetSuggestion', async () => {
1322
+ const exampleSmartSnippetSuggestion = {
1323
+ question: 'Abc',
1324
+ answerSnippet: 'Def',
1325
+ documentId: {contentIdKey: 'permanentid', contentIdValue: 'foo'},
1326
+ };
1327
+ const expectedMetadata = {
1328
+ ...exampleSmartSnippetSuggestion,
1329
+ ...expectedBaseCaseMetadata,
1330
+ };
1331
+
1332
+ await client.logExpandSmartSnippetSuggestion(exampleSmartSnippetSuggestion, baseCaseMetadata);
1333
+ expectMatchCustomEventPayload(
1334
+ SearchPageEvents.expandSmartSnippetSuggestion,
1335
+ expectedMetadata
1336
+ );
1337
+ });
1338
+
1339
+ it('should send proper payload for #collapseSmartSnippetSuggestion', async () => {
1340
+ const exampleSmartSnippetSuggestion = {
1341
+ question: 'Abc',
1342
+ answerSnippet: 'Def',
1343
+ documentId: {contentIdKey: 'permanentid', contentIdValue: 'foo'},
1344
+ };
1345
+ const expectedMetadata = {
1346
+ ...exampleSmartSnippetSuggestion,
1347
+ ...expectedBaseCaseMetadata,
1348
+ };
1349
+
1350
+ await client.logCollapseSmartSnippetSuggestion(
1351
+ exampleSmartSnippetSuggestion,
1352
+ baseCaseMetadata
1353
+ );
1354
+ expectMatchCustomEventPayload(
1355
+ SearchPageEvents.collapseSmartSnippetSuggestion,
1356
+ expectedMetadata
1357
+ );
1358
+ });
1359
+
1360
+ it('should send proper payload for #openSmartSnippetSource', async () => {
1361
+ const expectedMetadata = {
1362
+ ...fakeDocID,
1363
+ ...expectedBaseCaseMetadata,
1364
+ };
1365
+ await client.logOpenSmartSnippetSource(fakeDocInfo, fakeDocID, baseCaseMetadata);
1366
+ expectMatchDocumentPayload(
1367
+ SearchPageEvents.openSmartSnippetSource,
1368
+ fakeDocInfo,
1369
+ expectedMetadata
1370
+ );
1371
+ });
1372
+
1373
+ it('should send proper payload for #openSmartSnippetInlineLink', async () => {
1374
+ const meta = {
1375
+ ...fakeDocID,
1376
+ linkText: 'Some text',
1377
+ linkURL: 'https://invalid.com',
1378
+ };
1379
+ const expectedMetadata = {
1380
+ ...meta,
1381
+ ...expectedBaseCaseMetadata,
1382
+ };
1383
+
1384
+ await client.logOpenSmartSnippetInlineLink(fakeDocInfo, meta, baseCaseMetadata);
1385
+ expectMatchDocumentPayload(
1386
+ SearchPageEvents.openSmartSnippetInlineLink,
1387
+ fakeDocInfo,
1388
+ expectedMetadata
1389
+ );
1390
+ });
1391
+
1392
+ it('should send proper payload for #openSmartSnippetSuggestionSource', async () => {
1393
+ const meta = {
1394
+ question: 'Abc',
1395
+ answerSnippet: 'Def',
1396
+ documentId: {contentIdKey: 'permanentid', contentIdValue: 'foo'},
1397
+ };
1398
+
1399
+ const expectedMetadata = {
1400
+ ...meta,
1401
+ ...expectedBaseCaseMetadata,
1402
+ contentIDKey: meta.documentId.contentIdKey,
1403
+ contentIDValue: meta.documentId.contentIdValue,
1404
+ };
1405
+
1406
+ await client.logOpenSmartSnippetSuggestionSource(fakeDocInfo, meta, baseCaseMetadata);
1407
+ expectMatchDocumentPayload(
1408
+ SearchPageEvents.openSmartSnippetSuggestionSource,
1409
+ fakeDocInfo,
1410
+ expectedMetadata
1411
+ );
1412
+ });
1413
+
1414
+ it('should send proper payload for #openSmartSnippetSuggestionInlineLink', async () => {
1415
+ const meta = {
1416
+ question: 'Abc',
1417
+ answerSnippet: 'Def',
1418
+ documentId: {contentIdKey: 'permanentid', contentIdValue: 'foo'},
1419
+ linkText: 'Some text',
1420
+ linkURL: 'https://invalid.com',
1421
+ };
1422
+ const expectedMetadata = {
1423
+ ...meta,
1424
+ ...expectedBaseCaseMetadata,
1425
+ contentIDKey: meta.documentId.contentIdKey,
1426
+ contentIDValue: meta.documentId.contentIdValue,
1427
+ };
1428
+
1429
+ await client.logOpenSmartSnippetSuggestionInlineLink(fakeDocInfo, meta, baseCaseMetadata);
1430
+ expectMatchDocumentPayload(
1431
+ SearchPageEvents.openSmartSnippetSuggestionInlineLink,
1432
+ fakeDocInfo,
1433
+ expectedMetadata
1434
+ );
1435
+ });
1436
+
1437
+ it('should send proper payload for #showMoreFoldedResults', async () => {
1438
+ const expectedMetadata = {
1439
+ ...fakeDocID,
1440
+ ...expectedBaseCaseMetadata,
1441
+ };
1442
+ await client.logShowMoreFoldedResults(fakeDocInfo, fakeDocID, baseCaseMetadata);
1443
+ expectMatchDocumentPayload(
1444
+ SearchPageEvents.showMoreFoldedResults,
1445
+ fakeDocInfo,
1446
+ expectedMetadata
1447
+ );
1448
+ });
1449
+
1450
+ it('should send proper payload for #showLessFoldedResults', async () => {
1451
+ const expectedMetadata = {
1452
+ ...expectedBaseCaseMetadata,
1453
+ };
1454
+ await client.logShowLessFoldedResults(baseCaseMetadata);
1455
+ expectMatchCustomEventPayload(SearchPageEvents.showLessFoldedResults, expectedMetadata);
1456
+ });
1457
+
1458
+ it('should send proper payload for #likeGeneratedAnswer', async () => {
1459
+ const exampleGeneratedAnswerMetadata = {
1460
+ generativeQuestionAnsweringId: '123',
1461
+ };
1462
+ const expectedMetadata = {
1463
+ ...exampleGeneratedAnswerMetadata,
1464
+ ...expectedBaseCaseMetadata,
1465
+ };
1466
+
1467
+ await client.logLikeGeneratedAnswer(exampleGeneratedAnswerMetadata, baseCaseMetadata);
1468
+ expectMatchCustomEventPayload(SearchPageEvents.likeGeneratedAnswer, expectedMetadata);
1469
+ });
1470
+
1471
+ it('should send proper payload for #dislikeGeneratedAnswer', async () => {
1472
+ const exampleGeneratedAnswerMetadata = {
1473
+ generativeQuestionAnsweringId: '123',
1474
+ };
1475
+ const expectedMetadata = {
1476
+ ...exampleGeneratedAnswerMetadata,
1477
+ ...expectedBaseCaseMetadata,
1478
+ };
1479
+
1480
+ await client.logDislikeGeneratedAnswer(exampleGeneratedAnswerMetadata, baseCaseMetadata);
1481
+ expectMatchCustomEventPayload(SearchPageEvents.dislikeGeneratedAnswer, expectedMetadata);
1482
+ });
1483
+
1484
+ it('should send proper payload for #openGeneratedAnswerSource', async () => {
1485
+ const exampleGeneratedAnswerMetadata = {
1486
+ generativeQuestionAnsweringId: '123',
1487
+ permanentId: 'foo',
1488
+ citationId: 'bar',
1489
+ };
1490
+ const expectedMetadata = {
1491
+ ...exampleGeneratedAnswerMetadata,
1492
+ ...expectedBaseCaseMetadata,
1493
+ };
1494
+
1495
+ await client.logOpenGeneratedAnswerSource(exampleGeneratedAnswerMetadata, baseCaseMetadata);
1496
+ expectMatchCustomEventPayload(SearchPageEvents.openGeneratedAnswerSource, expectedMetadata);
1497
+ });
1498
+
1499
+ it('should send proper payload for #generatedAnswerCitationClick', async () => {
1500
+ const meta = {
1501
+ generativeQuestionAnsweringId: '123',
1502
+ citationId: 'bar',
1503
+ documentId: {contentIdKey: 'permanentid', contentIdValue: 'foo'},
1504
+ };
1505
+
1506
+ const expectedMetadata = {
1507
+ ...meta,
1508
+ contentIDKey: meta.documentId.contentIdKey,
1509
+ contentIDValue: meta.documentId.contentIdValue,
1510
+ };
1511
+
1512
+ await client.logGeneratedAnswerCitationClick(fakeDocInfo, meta, baseCaseMetadata);
1513
+ expectMatchDocumentPayload(
1514
+ SearchPageEvents.generatedAnswerCitationClick,
1515
+ fakeDocInfo,
1516
+ expectedMetadata
1517
+ );
1518
+ });
1519
+
1520
+ it('should send proper payload for #generatedAnswerSourceHover', async () => {
1521
+ const exampleGeneratedAnswerMetadata = {
1522
+ generativeQuestionAnsweringId: '123',
1523
+ permanentId: 'foo',
1524
+ citationId: 'bar',
1525
+ citationHoverTimeMs: 100,
1526
+ };
1527
+ const expectedMetadata = {
1528
+ ...exampleGeneratedAnswerMetadata,
1529
+ ...expectedBaseCaseMetadata,
1530
+ };
1531
+
1532
+ await client.logGeneratedAnswerSourceHover(exampleGeneratedAnswerMetadata, baseCaseMetadata);
1533
+ expectMatchCustomEventPayload(SearchPageEvents.generatedAnswerSourceHover, expectedMetadata);
1534
+ });
1535
+
1536
+ it('should send proper payload for #generatedAnswerCopyToClipboard', async () => {
1537
+ const exampleGeneratedAnswerMetadata = {
1538
+ generativeQuestionAnsweringId: '123',
1539
+ };
1540
+ const expectedMetadata = {
1541
+ ...exampleGeneratedAnswerMetadata,
1542
+ ...expectedBaseCaseMetadata,
1543
+ };
1544
+
1545
+ await client.logGeneratedAnswerCopyToClipboard(
1546
+ exampleGeneratedAnswerMetadata,
1547
+ baseCaseMetadata
1548
+ );
1549
+ expectMatchCustomEventPayload(
1550
+ SearchPageEvents.generatedAnswerCopyToClipboard,
1551
+ expectedMetadata
1552
+ );
1553
+ });
1554
+
1555
+ it('should send proper payload for #generatedAnswerHideAnswers', async () => {
1556
+ const exampleGeneratedAnswerMetadata = {
1557
+ generativeQuestionAnsweringId: '123',
1558
+ };
1559
+ const expectedMetadata = {
1560
+ ...exampleGeneratedAnswerMetadata,
1561
+ ...expectedBaseCaseMetadata,
1562
+ };
1563
+
1564
+ await client.logGeneratedAnswerHideAnswers(exampleGeneratedAnswerMetadata, baseCaseMetadata);
1565
+ expectMatchCustomEventPayload(SearchPageEvents.generatedAnswerHideAnswers, expectedMetadata);
1566
+ });
1567
+
1568
+ it('should send proper payload for #generatedAnswerShowAnswers', async () => {
1569
+ const exampleGeneratedAnswerMetadata = {
1570
+ generativeQuestionAnsweringId: '123',
1571
+ };
1572
+ const expectedMetadata = {
1573
+ ...exampleGeneratedAnswerMetadata,
1574
+ ...expectedBaseCaseMetadata,
1575
+ };
1576
+
1577
+ await client.logGeneratedAnswerShowAnswers(exampleGeneratedAnswerMetadata, baseCaseMetadata);
1578
+ expectMatchCustomEventPayload(SearchPageEvents.generatedAnswerShowAnswers, expectedMetadata);
1579
+ });
1580
+
1581
+ it('should send proper payload for #generatedAnswerExpand', async () => {
1582
+ const exampleGeneratedAnswerMetadata = {
1583
+ generativeQuestionAnsweringId: '123',
1584
+ };
1585
+ const expectedMetadata = {
1586
+ ...exampleGeneratedAnswerMetadata,
1587
+ ...expectedBaseCaseMetadata,
1588
+ };
1589
+
1590
+ await client.logGeneratedAnswerExpand(exampleGeneratedAnswerMetadata, baseCaseMetadata);
1591
+ expectMatchCustomEventPayload(SearchPageEvents.generatedAnswerExpand, expectedMetadata);
1592
+ });
1593
+
1594
+ it('should send proper payload for #generatedAnswerCollapse', async () => {
1595
+ const exampleGeneratedAnswerMetadata = {
1596
+ generativeQuestionAnsweringId: '123',
1597
+ };
1598
+ const expectedMetadata = {
1599
+ ...exampleGeneratedAnswerMetadata,
1600
+ ...expectedBaseCaseMetadata,
1601
+ };
1602
+
1603
+ await client.logGeneratedAnswerCollapse(exampleGeneratedAnswerMetadata, baseCaseMetadata);
1604
+ expectMatchCustomEventPayload(SearchPageEvents.generatedAnswerCollapse, expectedMetadata);
1605
+ });
1606
+
1607
+ it('should send proper payload for #generatedAnswerFeedbackSubmit', async () => {
1608
+ const exampleGeneratedAnswerMetadata = {
1609
+ generativeQuestionAnsweringId: '123',
1610
+ reason: <GeneratedAnswerFeedbackReason>'other',
1611
+ details: 'foo',
1612
+ };
1613
+ const expectedMetadata = {
1614
+ ...exampleGeneratedAnswerMetadata,
1615
+ ...expectedBaseCaseMetadata,
1616
+ };
1617
+
1618
+ await client.logGeneratedAnswerFeedbackSubmit(
1619
+ exampleGeneratedAnswerMetadata,
1620
+ baseCaseMetadata
1621
+ );
1622
+ expectMatchCustomEventPayload(
1623
+ SearchPageEvents.generatedAnswerFeedbackSubmit,
1624
+ expectedMetadata
1625
+ );
1626
+ });
1627
+
1628
+ it('should send proper payload for #generatedAnswerFeedbackSubmitV2', async () => {
1629
+ const exampleGeneratedAnswerMetadata = {
1630
+ generativeQuestionAnsweringId: '123',
1631
+ helpful: true,
1632
+ readable: <GeneratedAnswerFeedbackReasonOption>'yes',
1633
+ documented: <GeneratedAnswerFeedbackReasonOption>'no',
1634
+ correctTopic: <GeneratedAnswerFeedbackReasonOption>'unknown',
1635
+ hallucinationFree: <GeneratedAnswerFeedbackReasonOption>'yes',
1636
+ details: 'foo',
1637
+ documentUrl: 'https://document.com',
1638
+ };
1639
+ const expectedMetadata = {
1640
+ ...exampleGeneratedAnswerMetadata,
1641
+ ...expectedBaseCaseMetadata,
1642
+ };
1643
+
1644
+ await client.logGeneratedAnswerFeedbackSubmitV2(
1645
+ exampleGeneratedAnswerMetadata,
1646
+ baseCaseMetadata
1647
+ );
1648
+ expectMatchCustomEventPayload(
1649
+ SearchPageEvents.generatedAnswerFeedbackSubmitV2,
1650
+ expectedMetadata
1651
+ );
1652
+ });
1653
+
1654
+ it('should send proper payload for #rephraseGeneratedAnswer', async () => {
1655
+ const exampleGeneratedAnswerMetadata = {
1656
+ generativeQuestionAnsweringId: '123',
1657
+ rephraseFormat: <GeneratedAnswerRephraseFormat>'step',
1658
+ };
1659
+ const expectedMetadata = {
1660
+ ...exampleGeneratedAnswerMetadata,
1661
+ ...expectedBaseCaseMetadata,
1662
+ };
1663
+
1664
+ await client.logRephraseGeneratedAnswer(exampleGeneratedAnswerMetadata, baseCaseMetadata);
1665
+ expectMatchPayload(SearchPageEvents.rephraseGeneratedAnswer, expectedMetadata);
1666
+ });
1667
+
1668
+ it('should send proper payload for #retryGeneratedAnswer', async () => {
1669
+ const expectedMetadata = {
1670
+ ...expectedBaseCaseMetadata,
1671
+ };
1672
+
1673
+ await client.logRetryGeneratedAnswer(baseCaseMetadata);
1674
+ expectMatchPayload(SearchPageEvents.retryGeneratedAnswer, expectedMetadata);
1675
+ });
1676
+
1677
+ it('should send proper payload for #generatedAnswerStreamEnd', async () => {
1678
+ const exampleGeneratedAnswerMetadata = {
1679
+ generativeQuestionAnsweringId: '123',
1680
+ answerGenerated: true,
1681
+ answerTextIsEmpty: false,
1682
+ };
1683
+ const expectedMetadata = {
1684
+ ...exampleGeneratedAnswerMetadata,
1685
+ ...expectedBaseCaseMetadata,
1686
+ };
1687
+
1688
+ await client.logGeneratedAnswerStreamEnd(exampleGeneratedAnswerMetadata, baseCaseMetadata);
1689
+ expectMatchCustomEventPayload(SearchPageEvents.generatedAnswerStreamEnd, expectedMetadata);
1690
+ });
1691
+
1692
+ it('should send proper payload for #generatedAnswerCitationDocumentAttach', async () => {
1693
+ const meta = {
1694
+ generativeQuestionAnsweringId: '123',
1695
+ citationId: 'bar',
1696
+ documentId: {contentIdKey: 'permanentid', contentIdValue: 'foo'},
1697
+ };
1698
+
1699
+ const expectedMetadata = {
1700
+ ...meta,
1701
+ ...expectedBaseCaseMetadata,
1702
+ contentIDKey: meta.documentId.contentIdKey,
1703
+ contentIDValue: meta.documentId.contentIdValue,
1704
+ };
1705
+
1706
+ await client.logGeneratedAnswerCitationDocumentAttach(fakeDocInfo, meta, baseCaseMetadata);
1707
+ expectMatchDocumentPayload(
1708
+ SearchPageEvents.generatedAnswerCitationDocumentAttach,
1709
+ fakeDocInfo,
1710
+ expectedMetadata
1711
+ );
1712
+ });
1713
+
1714
+ it('should send proper payload for #createArticle', async () => {
1715
+ const exampleCreateArticleMetadata = {
1716
+ articleType: 'Knowledge__kav',
1717
+ };
1718
+ const expectedMetadata = {
1719
+ ...exampleCreateArticleMetadata,
1720
+ ...expectedBaseCaseMetadata,
1721
+ };
1722
+ await client.logCreateArticle(exampleCreateArticleMetadata, baseCaseMetadata);
1723
+ expectMatchCustomEventPayload(InsightEvents.createArticle, expectedMetadata);
1724
+ });
1725
+
1726
+ it('should send proper payload for #logTriggerNotify', async () => {
1727
+ const exampleTriggerNotifyMetadata = {
1728
+ notifications: ['foo', 'bar'],
1729
+ };
1730
+ const expectedMetadata = {
1731
+ ...exampleTriggerNotifyMetadata,
1732
+ ...expectedBaseCaseMetadata,
1733
+ };
1734
+ await client.logTriggerNotify(exampleTriggerNotifyMetadata, baseCaseMetadata);
1735
+ expectMatchCustomEventPayload(SearchPageEvents.triggerNotify, expectedMetadata);
1736
+ });
1737
+ });
1738
+
1739
+ it('should enable analytics tracking by default', () => {
1740
+ const c = new CoveoInsightClient({}, provider);
1741
+ expect(c.coveoAnalyticsClient instanceof CoveoAnalyticsClient).toBe(true);
1742
+ });
1743
+
1744
+ it('should allow disabling analytics on initialization', () => {
1745
+ const c = new CoveoInsightClient({enableAnalytics: false}, provider);
1746
+ expect(c.coveoAnalyticsClient instanceof NoopAnalytics).toBe(true);
1747
+ });
1748
+
1749
+ it('should allow disabling analytics after initialization', () => {
1750
+ const c = new CoveoInsightClient({enableAnalytics: true}, provider);
1751
+ expect(c.coveoAnalyticsClient instanceof CoveoAnalyticsClient).toBe(true);
1752
+ c.disable();
1753
+ expect(c.coveoAnalyticsClient instanceof NoopAnalytics).toBe(true);
1754
+ });
1755
+
1756
+ it('disabling analytics does not delete the visitorId', () => {
1757
+ const visitorId = 'uuid';
1758
+ Cookie.set('coveo_visitorId', visitorId);
1759
+ const c = new CoveoInsightClient({enableAnalytics: true}, provider);
1760
+
1761
+ expect(Cookie.get('coveo_visitorId')).toBe(visitorId);
1762
+ c.disable();
1763
+ expect(Cookie.get('coveo_visitorId')).toBe(visitorId);
1764
+ });
1765
+
1766
+ it('should disable analytics when doNotTrack is enabled', async () => {
1767
+ (doNotTrack as Mock).mockImplementationOnce(() => true);
1768
+
1769
+ const c = new CoveoInsightClient({}, provider);
1770
+ expect(c.coveoAnalyticsClient instanceof NoopAnalytics).toBe(true);
1771
+ });
1772
+
1773
+ it('keeps a real analytics client under doNotTrack when disableBrowserPrivacySignals is true', () => {
1774
+ (doNotTrack as Mock).mockImplementation(() => true);
1775
+
1776
+ const c = new CoveoInsightClient({disableBrowserPrivacySignals: true}, provider);
1777
+ expect(c.coveoAnalyticsClient instanceof CoveoAnalyticsClient).toBe(true);
1778
+
1779
+ (doNotTrack as Mock).mockReset();
1780
+ });
1781
+
1782
+ it('still disables analytics when enableAnalytics is false even if disableBrowserPrivacySignals is true', () => {
1783
+ const c = new CoveoInsightClient(
1784
+ {enableAnalytics: false, disableBrowserPrivacySignals: true},
1785
+ provider
1786
+ );
1787
+ expect(c.coveoAnalyticsClient instanceof NoopAnalytics).toBe(true);
1788
+ });
1789
+
1790
+ it('should allow enabling analytics after initialization', () => {
1791
+ const c = new CoveoInsightClient({enableAnalytics: false}, provider);
1792
+ expect(c.coveoAnalyticsClient instanceof NoopAnalytics).toBe(true);
1793
+ c.enable();
1794
+ expect(c.coveoAnalyticsClient instanceof CoveoAnalyticsClient).toBe(true);
1795
+ });
1796
+
1797
+ it('should send proper payload for #contextChanged', async () => {
1798
+ const meta = {
1799
+ caseId: '1234',
1800
+ caseNumber: '5678',
1801
+ caseContext: {
1802
+ Case_Subject: 'test subject',
1803
+ Case_Description: 'test description',
1804
+ },
139
1805
  };
140
1806
 
141
- const fakeDocID = {
142
- contentIDKey: 'permanentID',
143
- contentIDValue: 'the-permanent-id',
1807
+ const expectedMeta = {
1808
+ CaseId: '1234',
1809
+ CaseNumber: '5678',
1810
+ CaseSubject: 'test subject',
1811
+ context_Case_Subject: 'test subject',
1812
+ context_Case_Description: 'test description',
144
1813
  };
145
1814
 
146
- beforeEach(() => {
147
- fetchMockBeforeEach();
148
-
149
- client = initClient();
150
- client.coveoAnalyticsClient.runtime.storage.setItem('visitorId', 'visitor-id');
151
- fetchMock.mock(/.*/, {
152
- visitId: 'visit-id',
153
- });
154
- });
155
-
156
- afterEach(() => {
157
- fetchMock.reset();
158
- });
159
-
160
- describe('when the case metadata is not included', () => {
161
- it('should send proper payload for #interfaceLoad', async () => {
162
- await client.logInterfaceLoad();
163
- expectMatchPayload(SearchPageEvents.interfaceLoad);
164
- });
165
-
166
- it('should send proper payload for #recentQueryClick', async () => {
167
- await client.logRecentQueryClick();
168
- expectMatchPayload(SearchPageEvents.recentQueryClick);
169
- });
170
-
171
- it('should send proper payload for #clearRecentQueries', async () => {
172
- await client.logClearRecentQueries();
173
- expectMatchCustomEventPayload(SearchPageEvents.clearRecentQueries);
174
- });
175
-
176
- it('should send proper payload for #interfaceChange', async () => {
177
- await client.logInterfaceChange({
178
- interfaceChangeTo: 'bob',
179
- });
180
- expectMatchPayload(SearchPageEvents.interfaceChange, {interfaceChangeTo: 'bob'});
181
- });
182
-
183
- it('should send proper payload for #fetchMoreResults', async () => {
184
- await client.logFetchMoreResults();
185
- expectMatchCustomEventPayload(SearchPageEvents.pagerScrolling, {type: 'getMoreResults'});
186
- });
187
-
188
- it('should send proper payload for #staticFilterDeselect', async () => {
189
- const meta: StaticFilterToggleValueMetadata = {
190
- staticFilterId: 'filetypes',
191
- staticFilterValue: {
192
- caption: 'Youtube',
193
- expression: '@filetype="youtubevideo"',
194
- },
195
- };
196
- await client.logStaticFilterDeselect(meta);
197
-
198
- expectMatchPayload(SearchPageEvents.staticFilterDeselect, meta);
199
- });
200
-
201
- it('should send proper payload for #breadcrumbResetAll', async () => {
202
- await client.logBreadcrumbResetAll();
203
- expectMatchPayload(SearchPageEvents.breadcrumbResetAll);
204
- });
205
-
206
- it('should send proper payload for #breadcrumbFacet', async () => {
207
- const meta = {
208
- facetField: '@foo',
209
- facetId: 'bar',
210
- facetTitle: 'title',
211
- facetValue: 'qwerty',
212
- };
213
- await client.logBreadcrumbFacet(meta);
214
- expectMatchPayload(SearchPageEvents.breadcrumbFacet, meta);
215
- });
216
-
217
- it('should send proper payload for #logFacetSelect', async () => {
218
- const meta = {
219
- facetField: '@foo',
220
- facetId: 'bar',
221
- facetTitle: 'title',
222
- facetValue: 'qwerty',
223
- };
224
-
225
- await client.logFacetSelect(meta);
226
- expectMatchPayload(SearchPageEvents.facetSelect, meta);
227
- });
228
-
229
- it('should send proper payload for #logFacetExclude', async () => {
230
- const meta = {
231
- facetField: '@foo',
232
- facetId: 'bar',
233
- facetTitle: 'title',
234
- facetValue: 'qwerty',
235
- };
236
-
237
- await client.logFacetExclude(meta);
238
- expectMatchPayload(SearchPageEvents.facetExclude, meta);
239
- });
240
-
241
- it('should send proper payload for #logFacetDeselect', async () => {
242
- const meta = {
243
- facetField: '@foo',
244
- facetId: 'bar',
245
- facetTitle: 'title',
246
- facetValue: 'qwerty',
247
- };
248
-
249
- await client.logFacetDeselect(meta);
250
- expectMatchPayload(SearchPageEvents.facetDeselect, meta);
251
- });
252
-
253
- it('should send proper payload for #logFacetUpdateSort', async () => {
254
- const meta = {
255
- facetField: '@foo',
256
- facetId: 'bar',
257
- facetTitle: 'title',
258
- criteria: 'bazz',
259
- };
260
- await client.logFacetUpdateSort(meta);
261
- expectMatchPayload(SearchPageEvents.facetUpdateSort, meta);
262
- });
263
-
264
- it('should send proper payload for #logFacetClearAll', async () => {
265
- const meta = {
266
- facetField: '@foo',
267
- facetId: 'bar',
268
- facetTitle: 'title',
269
- };
270
- await client.logFacetClearAll(meta);
271
- expectMatchPayload(SearchPageEvents.facetClearAll, meta);
272
- });
273
-
274
- it('should send proper payload for #logFacetShowMore', async () => {
275
- const meta = {
276
- facetField: '@foo',
277
- facetId: 'bar',
278
- facetTitle: 'title',
279
- };
280
- await client.logFacetShowMore(meta);
281
- expectMatchCustomEventPayload(SearchPageEvents.facetShowMore, meta);
282
- });
283
-
284
- it('should send proper payload for #logFacetShowLess', async () => {
285
- const meta = {
286
- facetField: '@foo',
287
- facetId: 'bar',
288
- facetTitle: 'title',
289
- };
290
- await client.logFacetShowLess(meta);
291
- expectMatchCustomEventPayload(SearchPageEvents.facetShowLess, meta);
292
- });
293
-
294
- it('should send proper payload for #logQueryError', async () => {
295
- const meta = {
296
- query: 'q',
297
- aq: 'aq',
298
- cq: 'cq',
299
- dq: 'dq',
300
- errorMessage: 'boom',
301
- errorType: 'a bad one',
302
- };
303
- await client.logQueryError(meta);
304
- expectMatchCustomEventPayload(SearchPageEvents.queryError, meta);
305
- });
306
-
307
- it('should send proper payload for #logPagerNumber', async () => {
308
- const meta = {pagerNumber: 123};
309
- await client.logPagerNumber(meta);
310
- expectMatchCustomEventPayload(SearchPageEvents.pagerNumber, meta);
311
- });
312
-
313
- it('should send proper payload for #logPagerNext', async () => {
314
- const meta = {pagerNumber: 123};
315
- await client.logPagerNext(meta);
316
- expectMatchCustomEventPayload(SearchPageEvents.pagerNext, meta);
317
- });
318
-
319
- it('should send proper payload for #logPagerPrevious', async () => {
320
- const meta = {pagerNumber: 123};
321
- await client.logPagerPrevious(meta);
322
- expectMatchCustomEventPayload(SearchPageEvents.pagerPrevious, meta);
323
- });
324
-
325
- it('should send proper payload for #didyoumeanAutomatic', async () => {
326
- await client.logDidYouMeanAutomatic();
327
- expectMatchPayload(SearchPageEvents.didyoumeanAutomatic);
328
- });
329
-
330
- it('should send proper payload for #didyoumeanClick', async () => {
331
- await client.logDidYouMeanClick();
332
- expectMatchPayload(SearchPageEvents.didyoumeanClick);
333
- });
334
-
335
- it('should send proper payload for #resultsSort', async () => {
336
- await client.logResultsSort({resultsSortBy: 'date ascending'});
337
- expectMatchPayload(SearchPageEvents.resultsSort, {resultsSortBy: 'date ascending'});
338
- });
339
-
340
- it('should send proper payload for #searchboxSubmit', async () => {
341
- await client.logSearchboxSubmit();
342
- expectMatchPayload(SearchPageEvents.searchboxSubmit);
343
- });
344
-
345
- it('should send proper payload for #documentOpen', async () => {
346
- await client.logDocumentOpen(fakeDocInfo, fakeDocID);
347
- expectMatchDocumentPayload(SearchPageEvents.documentOpen, fakeDocInfo, fakeDocID);
348
- });
349
-
350
- it('should send proper payload for #copyToClipboard', async () => {
351
- await client.logCopyToClipboard(fakeDocInfo, fakeDocID);
352
- expectMatchDocumentPayload(SearchPageEvents.copyToClipboard, fakeDocInfo, fakeDocID);
353
- });
354
-
355
- it('should send proper payload for #caseSendEmail', async () => {
356
- await client.logCaseSendEmail(fakeDocInfo, fakeDocID);
357
- expectMatchDocumentPayload(SearchPageEvents.caseSendEmail, fakeDocInfo, fakeDocID);
358
- });
359
-
360
- it('should send proper payload for #feedItemTextPost', async () => {
361
- await client.logFeedItemTextPost(fakeDocInfo, fakeDocID);
362
- expectMatchDocumentPayload(SearchPageEvents.feedItemTextPost, fakeDocInfo, fakeDocID);
363
- });
364
-
365
- it('should send proper payload for #documentQuickview', async () => {
366
- const expectedMetadata = {
367
- ...fakeDocID,
368
- documentTitle: fakeDocInfo.documentTitle,
369
- documentURL: fakeDocInfo.documentUrl,
370
- };
371
- await client.logDocumentQuickview(fakeDocInfo, fakeDocID);
372
- expectMatchDocumentPayload(SearchPageEvents.documentQuickview, fakeDocInfo, expectedMetadata);
373
- });
374
-
375
- it('should send proper payload for #caseAttach', async () => {
376
- const expectedMetadata = {
377
- ...fakeDocID,
378
- documentTitle: fakeDocInfo.documentTitle,
379
- documentURL: fakeDocInfo.documentUrl,
380
- resultUriHash: fakeDocInfo.documentUriHash,
381
- };
382
- await client.logCaseAttach(fakeDocInfo, fakeDocID);
383
- expectMatchDocumentPayload(SearchPageEvents.caseAttach, fakeDocInfo, expectedMetadata);
384
- });
385
-
386
- it('should send proper payload for #caseDetach', async () => {
387
- const mockResultUriHash = fakeDocInfo.documentUriHash;
388
- const mockPermanentId = fakeDocID.contentIDValue;
389
- const expectedMetadata = {
390
- resultUriHash: mockResultUriHash,
391
- permanentId: mockPermanentId,
392
- };
393
- await client.logCaseDetach(mockResultUriHash, undefined, mockPermanentId);
394
- expectMatchCustomEventPayload(SearchPageEvents.caseDetach, expectedMetadata);
395
- });
396
-
397
- it('should send proper payload for #likeSmartSnippet', async () => {
398
- await client.logLikeSmartSnippet();
399
- expectMatchCustomEventPayload(SearchPageEvents.likeSmartSnippet);
400
- });
401
-
402
- it('should send proper payload for #dislikeSmartSnippet', async () => {
403
- await client.logDislikeSmartSnippet();
404
- expectMatchCustomEventPayload(SearchPageEvents.dislikeSmartSnippet);
405
- });
406
-
407
- it('should send proper payload for #expandSmartSnippet', async () => {
408
- await client.logExpandSmartSnippet();
409
- expectMatchCustomEventPayload(SearchPageEvents.expandSmartSnippet);
410
- });
411
-
412
- it('should send proper payload for #collapseSmartSnippet', async () => {
413
- await client.logCollapseSmartSnippet();
414
- expectMatchCustomEventPayload(SearchPageEvents.collapseSmartSnippet);
415
- });
416
-
417
- it('should send proper payload for #openSmartSnippetFeedbackModal', async () => {
418
- await client.logOpenSmartSnippetFeedbackModal();
419
- expectMatchCustomEventPayload(SearchPageEvents.openSmartSnippetFeedbackModal);
420
- });
421
-
422
- it('should send proper payload for #closeSmartSnippetFeedbackModal', async () => {
423
- await client.logCloseSmartSnippetFeedbackModal();
424
- expectMatchCustomEventPayload(SearchPageEvents.closeSmartSnippetFeedbackModal);
425
- });
426
-
427
- it('should send proper payload for #sendSmartSnippetReason', async () => {
428
- const reason = 'other';
429
- const details = 'example details';
430
- const expectedMetadata = {
431
- reason,
432
- details,
433
- };
434
-
435
- await client.logSmartSnippetFeedbackReason(reason, details);
436
- expectMatchCustomEventPayload(SearchPageEvents.sendSmartSnippetReason, expectedMetadata);
437
- });
438
-
439
- it('should send proper payload for #expandSmartSnippetSuggestion', async () => {
440
- const exampleSmartSnippetSuggestion = {
441
- question: 'Abc',
442
- answerSnippet: 'Def',
443
- documentId: {contentIdKey: 'permanentid', contentIdValue: 'foo'},
444
- };
445
-
446
- await client.logExpandSmartSnippetSuggestion(exampleSmartSnippetSuggestion);
447
- expectMatchCustomEventPayload(SearchPageEvents.expandSmartSnippetSuggestion, exampleSmartSnippetSuggestion);
448
- });
449
-
450
- it('should send proper payload for #collapseSmartSnippetSuggestion', async () => {
451
- const exampleSmartSnippetSuggestion = {
452
- question: 'Abc',
453
- answerSnippet: 'Def',
454
- documentId: {contentIdKey: 'permanentid', contentIdValue: 'foo'},
455
- };
456
-
457
- await client.logCollapseSmartSnippetSuggestion(exampleSmartSnippetSuggestion);
458
- expectMatchCustomEventPayload(
459
- SearchPageEvents.collapseSmartSnippetSuggestion,
460
- exampleSmartSnippetSuggestion,
461
- );
462
- });
463
-
464
- it('should send proper payload for #openSmartSnippetSource', async () => {
465
- await client.logOpenSmartSnippetSource(fakeDocInfo, fakeDocID);
466
- expectMatchDocumentPayload(SearchPageEvents.openSmartSnippetSource, fakeDocInfo, fakeDocID);
467
- });
468
-
469
- it('should send proper payload for #openSmartSnippetInlineLink', async () => {
470
- const meta = {
471
- ...fakeDocID,
472
- linkText: 'Some text',
473
- linkURL: 'https://invalid.com',
474
- };
475
-
476
- await client.logOpenSmartSnippetInlineLink(fakeDocInfo, meta);
477
- expectMatchDocumentPayload(SearchPageEvents.openSmartSnippetInlineLink, fakeDocInfo, meta);
478
- });
479
-
480
- it('should send proper payload for #openSmartSnippetSuggestionSource', async () => {
481
- const meta = {
482
- question: 'Abc',
483
- answerSnippet: 'Def',
484
- documentId: {contentIdKey: 'permanentid', contentIdValue: 'foo'},
485
- };
486
-
487
- const expectedMetadata = {
488
- ...meta,
489
- contentIDKey: meta.documentId.contentIdKey,
490
- contentIDValue: meta.documentId.contentIdValue,
491
- };
492
-
493
- await client.logOpenSmartSnippetSuggestionSource(fakeDocInfo, meta);
494
- expectMatchDocumentPayload(
495
- SearchPageEvents.openSmartSnippetSuggestionSource,
496
- fakeDocInfo,
497
- expectedMetadata,
498
- );
499
- });
500
-
501
- it('should send proper payload for #openSmartSnippetSuggestionInlineLink', async () => {
502
- const meta = {
503
- question: 'Abc',
504
- answerSnippet: 'Def',
505
- documentId: {contentIdKey: 'permanentid', contentIdValue: 'foo'},
506
- linkText: 'Some text',
507
- linkURL: 'https://invalid.com',
508
- };
509
- const expectedMetadata = {
510
- ...meta,
511
- contentIDKey: meta.documentId.contentIdKey,
512
- contentIDValue: meta.documentId.contentIdValue,
513
- };
514
-
515
- await client.logOpenSmartSnippetSuggestionInlineLink(fakeDocInfo, meta);
516
- expectMatchDocumentPayload(
517
- SearchPageEvents.openSmartSnippetSuggestionInlineLink,
518
- fakeDocInfo,
519
- expectedMetadata,
520
- );
521
- });
522
- it('should send proper payload for #showMoreFoldedResults', async () => {
523
- await client.logShowMoreFoldedResults(fakeDocInfo, fakeDocID);
524
- expectMatchDocumentPayload(SearchPageEvents.showMoreFoldedResults, fakeDocInfo, fakeDocID);
525
- });
526
-
527
- it('should send proper payload for #showLessFoldedResults', async () => {
528
- await client.logShowLessFoldedResults();
529
- expectMatchCustomEventPayload(SearchPageEvents.showLessFoldedResults);
530
- });
531
-
532
- it('should send proper payload for #likeGeneratedAnswer', async () => {
533
- const exampleGeneratedAnswerMetadata = {
534
- generativeQuestionAnsweringId: '123',
535
- };
536
-
537
- await client.logLikeGeneratedAnswer(exampleGeneratedAnswerMetadata);
538
- expectMatchCustomEventPayload(SearchPageEvents.likeGeneratedAnswer, exampleGeneratedAnswerMetadata);
539
- });
540
-
541
- it('should send proper payload for #dislikeGeneratedAnswer', async () => {
542
- const exampleGeneratedAnswerMetadata = {
543
- generativeQuestionAnsweringId: '123',
544
- };
545
-
546
- await client.logDislikeGeneratedAnswer(exampleGeneratedAnswerMetadata);
547
- expectMatchCustomEventPayload(SearchPageEvents.dislikeGeneratedAnswer, exampleGeneratedAnswerMetadata);
548
- });
549
-
550
- it('should send proper payload for #openGeneratedAnswerSource', async () => {
551
- const exampleGeneratedAnswerMetadata = {
552
- generativeQuestionAnsweringId: '123',
553
- permanentId: 'foo',
554
- citationId: 'bar',
555
- };
556
-
557
- await client.logOpenGeneratedAnswerSource(exampleGeneratedAnswerMetadata);
558
- expectMatchCustomEventPayload(SearchPageEvents.openGeneratedAnswerSource, exampleGeneratedAnswerMetadata);
559
- });
560
-
561
- it('should send proper payload for #generatedAnswerCitationClick', async () => {
562
- const meta = {
563
- generativeQuestionAnsweringId: '123',
564
- citationId: 'bar',
565
- documentId: {contentIdKey: 'permanentid', contentIdValue: 'foo'},
566
- };
567
-
568
- const expectedMetadata = {
569
- ...meta,
570
- contentIDKey: meta.documentId.contentIdKey,
571
- contentIDValue: meta.documentId.contentIdValue,
572
- };
573
-
574
- await client.logGeneratedAnswerCitationClick(fakeDocInfo, meta);
575
- expectMatchDocumentPayload(SearchPageEvents.generatedAnswerCitationClick, fakeDocInfo, expectedMetadata);
576
- });
577
-
578
- it('should send proper payload for #generatedAnswerSourceHover', async () => {
579
- const exampleGeneratedAnswerMetadata = {
580
- generativeQuestionAnsweringId: '123',
581
- permanentId: 'foo',
582
- citationId: 'bar',
583
- citationHoverTimeMs: 100,
584
- };
585
-
586
- await client.logGeneratedAnswerSourceHover(exampleGeneratedAnswerMetadata);
587
- expectMatchCustomEventPayload(SearchPageEvents.generatedAnswerSourceHover, exampleGeneratedAnswerMetadata);
588
- });
589
-
590
- it('should send proper payload for #generatedAnswerCopyToClipboard', async () => {
591
- const exampleGeneratedAnswerMetadata = {
592
- generativeQuestionAnsweringId: '123',
593
- };
594
-
595
- await client.logGeneratedAnswerCopyToClipboard(exampleGeneratedAnswerMetadata);
596
- expectMatchCustomEventPayload(
597
- SearchPageEvents.generatedAnswerCopyToClipboard,
598
- exampleGeneratedAnswerMetadata,
599
- );
600
- });
601
-
602
- it('should send proper payload for #generatedAnswerHideAnswers', async () => {
603
- const exampleGeneratedAnswerMetadata = {
604
- generativeQuestionAnsweringId: '123',
605
- };
606
-
607
- await client.logGeneratedAnswerHideAnswers(exampleGeneratedAnswerMetadata);
608
- expectMatchCustomEventPayload(SearchPageEvents.generatedAnswerHideAnswers, exampleGeneratedAnswerMetadata);
609
- });
610
-
611
- it('should send proper payload for #generatedAnswerShowAnswers', async () => {
612
- const exampleGeneratedAnswerMetadata = {
613
- generativeQuestionAnsweringId: '123',
614
- };
615
-
616
- await client.logGeneratedAnswerShowAnswers(exampleGeneratedAnswerMetadata);
617
- expectMatchCustomEventPayload(SearchPageEvents.generatedAnswerShowAnswers, exampleGeneratedAnswerMetadata);
618
- });
619
-
620
- it('should send proper payload for #generatedAnswerExpand', async () => {
621
- const exampleGeneratedAnswerMetadata = {
622
- generativeQuestionAnsweringId: '123',
623
- };
624
-
625
- await client.logGeneratedAnswerExpand(exampleGeneratedAnswerMetadata);
626
- expectMatchCustomEventPayload(SearchPageEvents.generatedAnswerExpand, exampleGeneratedAnswerMetadata);
627
- });
628
-
629
- it('should send proper payload for #generatedAnswerCollapse', async () => {
630
- const exampleGeneratedAnswerMetadata = {
631
- generativeQuestionAnsweringId: '123',
632
- };
633
-
634
- await client.logGeneratedAnswerCollapse(exampleGeneratedAnswerMetadata);
635
- expectMatchCustomEventPayload(SearchPageEvents.generatedAnswerCollapse, exampleGeneratedAnswerMetadata);
636
- });
637
-
638
- it('should send proper payload for #generatedAnswerFeedbackSubmit', async () => {
639
- const exampleGeneratedAnswerMetadata = {
640
- generativeQuestionAnsweringId: '123',
641
- reason: <GeneratedAnswerFeedbackReason>'other',
642
- details: 'foo',
643
- };
644
-
645
- await client.logGeneratedAnswerFeedbackSubmit(exampleGeneratedAnswerMetadata);
646
- expectMatchCustomEventPayload(
647
- SearchPageEvents.generatedAnswerFeedbackSubmit,
648
- exampleGeneratedAnswerMetadata,
649
- );
650
- });
651
-
652
- it('should send proper payload for #rephraseGeneratedAnswer', async () => {
653
- const exampleGeneratedAnswerMetadata = {
654
- generativeQuestionAnsweringId: '123',
655
- rephraseFormat: <GeneratedAnswerRephraseFormat>'step',
656
- };
657
-
658
- await client.logRephraseGeneratedAnswer(exampleGeneratedAnswerMetadata);
659
- expectMatchPayload(SearchPageEvents.rephraseGeneratedAnswer, exampleGeneratedAnswerMetadata);
660
- });
661
-
662
- it('should send proper payload for #retryGeneratedAnswer', async () => {
663
- await client.logRetryGeneratedAnswer();
664
- expectMatchPayload(SearchPageEvents.retryGeneratedAnswer);
665
- });
666
-
667
- it('should send proper payload for #generatedAnswerStreamEnd', async () => {
668
- const exampleGeneratedAnswerMetadata = {
669
- generativeQuestionAnsweringId: '123',
670
- answerGenerated: true,
671
- answerTextIsEmpty: false,
672
- };
673
-
674
- await client.logGeneratedAnswerStreamEnd(exampleGeneratedAnswerMetadata);
675
- expectMatchCustomEventPayload(SearchPageEvents.generatedAnswerStreamEnd, exampleGeneratedAnswerMetadata);
676
- });
677
-
678
- it('should send proper payload for #generatedAnswerCitationDocumentAttach', async () => {
679
- const meta = {
680
- generativeQuestionAnsweringId: '123',
681
- citationId: 'bar',
682
- documentId: {contentIdKey: 'permanentid', contentIdValue: 'foo'},
683
- };
684
-
685
- const expectedMetadata = {
686
- ...meta,
687
- contentIDKey: meta.documentId.contentIdKey,
688
- contentIDValue: meta.documentId.contentIdValue,
689
- };
690
-
691
- await client.logGeneratedAnswerCitationDocumentAttach(fakeDocInfo, meta);
692
- expectMatchDocumentPayload(
693
- SearchPageEvents.generatedAnswerCitationDocumentAttach,
694
- fakeDocInfo,
695
- expectedMetadata,
696
- );
697
- });
698
-
699
- it('should send proper payload for #createArticle', async () => {
700
- const exampleCreateArticleMetadata = {
701
- articleType: 'Knowledge__kav',
702
- triggeredBy: 'CreateArticleButton',
703
- };
704
- await client.logCreateArticle(exampleCreateArticleMetadata);
705
- expectMatchCustomEventPayload(InsightEvents.createArticle, exampleCreateArticleMetadata);
706
- });
707
-
708
- it('should send proper payload for #logTriggerNotify', async () => {
709
- const exampleTriggerNotifyMetadata = {
710
- notifications: ['foo', 'bar'],
711
- };
712
- await client.logTriggerNotify(exampleTriggerNotifyMetadata);
713
- expectMatchCustomEventPayload(SearchPageEvents.triggerNotify, exampleTriggerNotifyMetadata);
714
- });
715
-
716
- it('should send proper payload for #generatedAnswerFeedbackSubmitV2', async () => {
717
- const exampleGeneratedAnswerMetadata = {
718
- generativeQuestionAnsweringId: '123',
719
- helpful: true,
720
- readable: <GeneratedAnswerFeedbackReasonOption>'yes',
721
- documented: <GeneratedAnswerFeedbackReasonOption>'no',
722
- correctTopic: <GeneratedAnswerFeedbackReasonOption>'unknown',
723
- hallucinationFree: <GeneratedAnswerFeedbackReasonOption>'yes',
724
- details: 'foo',
725
- documentUrl: 'https://document.com',
726
- };
727
-
728
- await client.logGeneratedAnswerFeedbackSubmitV2(exampleGeneratedAnswerMetadata);
729
- expectMatchCustomEventPayload(
730
- SearchPageEvents.generatedAnswerFeedbackSubmitV2,
731
- exampleGeneratedAnswerMetadata,
732
- );
733
- });
734
- });
735
-
736
- describe('when the case metadata is included', () => {
737
- it('should send proper payload for #interfaceLoad', async () => {
738
- const metadata = baseCaseMetadata;
739
-
740
- const expectedMetadata = {
741
- ...expectedBaseCaseMetadata,
742
- context_Case_Subject: 'test subject',
743
- context_Case_Description: 'test description',
744
- };
745
- await client.logInterfaceLoad(metadata);
746
- expectMatchPayload(SearchPageEvents.interfaceLoad, expectedMetadata);
747
- });
748
-
749
- it('should send proper payload for #recentQueryClick', async () => {
750
- const metadata = baseCaseMetadata;
751
-
752
- const expectedMetadata = {
753
- ...expectedBaseCaseMetadata,
754
- context_Case_Subject: 'test subject',
755
- context_Case_Description: 'test description',
756
- };
757
- await client.logRecentQueryClick(metadata);
758
- expectMatchPayload(SearchPageEvents.recentQueryClick, expectedMetadata);
759
- });
760
-
761
- it('should send proper payload for #clearRecentQueries', async () => {
762
- const metadata = baseCaseMetadata;
763
-
764
- const expectedMetadata = {
765
- ...expectedBaseCaseMetadata,
766
- context_Case_Subject: 'test subject',
767
- context_Case_Description: 'test description',
768
- };
769
- await client.logClearRecentQueries(metadata);
770
- expectMatchCustomEventPayload(SearchPageEvents.clearRecentQueries, expectedMetadata);
771
- });
772
-
773
- it('should send proper payload for #interfaceChange', async () => {
774
- const metadata = {
775
- ...baseCaseMetadata,
776
- interfaceChangeTo: 'bob',
777
- };
778
-
779
- const expectedMetadata = {
780
- ...expectedBaseCaseMetadata,
781
- context_Case_Subject: 'test subject',
782
- context_Case_Description: 'test description',
783
- interfaceChangeTo: 'bob',
784
- };
785
- await client.logInterfaceChange(metadata);
786
- expectMatchPayload(SearchPageEvents.interfaceChange, expectedMetadata);
787
- });
788
-
789
- it('should send proper payload for #fetchMoreResults', async () => {
790
- const metadata = {
791
- ...baseCaseMetadata,
792
- };
793
-
794
- const expectedMetadata = {
795
- ...expectedBaseCaseMetadata,
796
- context_Case_Subject: 'test subject',
797
- context_Case_Description: 'test description',
798
- type: 'getMoreResults',
799
- };
800
- await client.logFetchMoreResults(metadata);
801
- expectMatchCustomEventPayload(SearchPageEvents.pagerScrolling, expectedMetadata);
802
- });
803
-
804
- it('should send proper payload for #staticFilterDeselect', async () => {
805
- const metadata: InsightStaticFilterToggleValueMetadata = {
806
- ...baseCaseMetadata,
807
- staticFilterId: 'filetypes',
808
- staticFilterValue: {
809
- caption: 'Youtube',
810
- expression: '@filetype="youtubevideo"',
811
- },
812
- };
813
-
814
- const expectedMetadata = {
815
- ...expectedBaseCaseMetadata,
816
- context_Case_Subject: 'test subject',
817
- context_Case_Description: 'test description',
818
- staticFilterId: 'filetypes',
819
- staticFilterValue: {
820
- caption: 'Youtube',
821
- expression: '@filetype="youtubevideo"',
822
- },
823
- };
824
- await client.logStaticFilterDeselect(metadata);
825
-
826
- expectMatchPayload(SearchPageEvents.staticFilterDeselect, expectedMetadata);
827
- });
828
-
829
- it('should send proper payload for #breadcrumbResetAll', async () => {
830
- const metadata = baseCaseMetadata;
831
-
832
- const expectedMetadata = {
833
- ...expectedBaseCaseMetadata,
834
- context_Case_Subject: 'test subject',
835
- context_Case_Description: 'test description',
836
- };
837
- await client.logBreadcrumbResetAll(metadata);
838
- expectMatchPayload(SearchPageEvents.breadcrumbResetAll, expectedMetadata);
839
- });
840
-
841
- it('should send proper payload for #breadcrumbFacet', async () => {
842
- const metadata = {
843
- ...baseCaseMetadata,
844
- facetField: '@foo',
845
- facetId: 'bar',
846
- facetTitle: 'title',
847
- facetValue: 'qwerty',
848
- };
849
-
850
- const expectedMetadata = {
851
- ...expectedBaseCaseMetadata,
852
- context_Case_Subject: 'test subject',
853
- context_Case_Description: 'test description',
854
- facetField: '@foo',
855
- facetId: 'bar',
856
- facetTitle: 'title',
857
- facetValue: 'qwerty',
858
- };
859
- await client.logBreadcrumbFacet(metadata);
860
- expectMatchPayload(SearchPageEvents.breadcrumbFacet, expectedMetadata);
861
- });
862
-
863
- it('should send proper payload for #logFacetSelect', async () => {
864
- const metadata = {
865
- ...baseCaseMetadata,
866
- facetField: '@foo',
867
- facetId: 'bar',
868
- facetTitle: 'title',
869
- facetValue: 'qwerty',
870
- };
871
-
872
- const expectedMetadata = {
873
- ...expectedBaseCaseMetadata,
874
- context_Case_Subject: 'test subject',
875
- context_Case_Description: 'test description',
876
- facetField: '@foo',
877
- facetId: 'bar',
878
- facetTitle: 'title',
879
- facetValue: 'qwerty',
880
- };
881
-
882
- await client.logFacetSelect(metadata);
883
- expectMatchPayload(SearchPageEvents.facetSelect, expectedMetadata);
884
- });
885
-
886
- it('should send proper payload for #logFacetExclude', async () => {
887
- const metadata = {
888
- ...baseCaseMetadata,
889
- facetField: '@foo',
890
- facetId: 'bar',
891
- facetTitle: 'title',
892
- facetValue: 'qwerty',
893
- };
894
-
895
- const expectedMetadata = {
896
- ...expectedBaseCaseMetadata,
897
- context_Case_Subject: 'test subject',
898
- context_Case_Description: 'test description',
899
- facetField: '@foo',
900
- facetId: 'bar',
901
- facetTitle: 'title',
902
- facetValue: 'qwerty',
903
- };
904
-
905
- await client.logFacetExclude(metadata);
906
- expectMatchPayload(SearchPageEvents.facetExclude, expectedMetadata);
907
- });
908
-
909
- it('should send proper payload for #logFacetDeselect', async () => {
910
- const metadata = {
911
- ...baseCaseMetadata,
912
- facetField: '@foo',
913
- facetId: 'bar',
914
- facetTitle: 'title',
915
- facetValue: 'qwerty',
916
- };
917
-
918
- const expectedMetadata = {
919
- ...expectedBaseCaseMetadata,
920
- context_Case_Subject: 'test subject',
921
- context_Case_Description: 'test description',
922
- facetField: '@foo',
923
- facetId: 'bar',
924
- facetTitle: 'title',
925
- facetValue: 'qwerty',
926
- };
927
-
928
- await client.logFacetDeselect(metadata);
929
- expectMatchPayload(SearchPageEvents.facetDeselect, expectedMetadata);
930
- });
931
-
932
- it('should send proper payload for #logFacetUpdateSort', async () => {
933
- const metadata = {
934
- ...baseCaseMetadata,
935
- facetField: '@foo',
936
- facetId: 'bar',
937
- facetTitle: 'title',
938
- criteria: 'bazz',
939
- };
940
-
941
- const expectedMetadata = {
942
- ...expectedBaseCaseMetadata,
943
- context_Case_Subject: 'test subject',
944
- context_Case_Description: 'test description',
945
- facetField: '@foo',
946
- facetId: 'bar',
947
- facetTitle: 'title',
948
- criteria: 'bazz',
949
- };
950
- await client.logFacetUpdateSort(metadata);
951
- expectMatchPayload(SearchPageEvents.facetUpdateSort, expectedMetadata);
952
- });
953
-
954
- it('should send proper payload for #logFacetClearAll', async () => {
955
- const metadata = {
956
- ...baseCaseMetadata,
957
- facetField: '@foo',
958
- facetId: 'bar',
959
- facetTitle: 'title',
960
- };
961
-
962
- const expectedMetadata = {
963
- ...expectedBaseCaseMetadata,
964
- context_Case_Subject: 'test subject',
965
- context_Case_Description: 'test description',
966
- facetField: '@foo',
967
- facetId: 'bar',
968
- facetTitle: 'title',
969
- };
970
- await client.logFacetClearAll(metadata);
971
- expectMatchPayload(SearchPageEvents.facetClearAll, expectedMetadata);
972
- });
973
-
974
- it('should send proper payload for #logFacetShowMore', async () => {
975
- const metadata = {
976
- ...baseCaseMetadata,
977
- facetField: '@foo',
978
- facetId: 'bar',
979
- facetTitle: 'title',
980
- };
981
-
982
- const expectedMetadata = {
983
- ...expectedBaseCaseMetadata,
984
- facetField: '@foo',
985
- facetId: 'bar',
986
- facetTitle: 'title',
987
- };
988
- await client.logFacetShowMore(metadata);
989
- expectMatchCustomEventPayload(SearchPageEvents.facetShowMore, expectedMetadata);
990
- });
991
-
992
- it('should send proper payload for #logFacetShowLess', async () => {
993
- const metadata = {
994
- ...baseCaseMetadata,
995
- facetField: '@foo',
996
- facetId: 'bar',
997
- facetTitle: 'title',
998
- };
999
-
1000
- const expectedMetadata = {
1001
- ...expectedBaseCaseMetadata,
1002
- facetField: '@foo',
1003
- facetId: 'bar',
1004
- facetTitle: 'title',
1005
- };
1006
- await client.logFacetShowLess(metadata);
1007
- expectMatchCustomEventPayload(SearchPageEvents.facetShowLess, expectedMetadata);
1008
- });
1009
-
1010
- it('should send proper payload for #logQueryError', async () => {
1011
- const metadata = {
1012
- ...baseCaseMetadata,
1013
- query: 'q',
1014
- aq: 'aq',
1015
- cq: 'cq',
1016
- dq: 'dq',
1017
- errorMessage: 'boom',
1018
- errorType: 'a bad one',
1019
- };
1020
-
1021
- const expectedMetadata = {
1022
- ...expectedBaseCaseMetadata,
1023
- query: 'q',
1024
- aq: 'aq',
1025
- cq: 'cq',
1026
- dq: 'dq',
1027
- errorMessage: 'boom',
1028
- errorType: 'a bad one',
1029
- };
1030
- await client.logQueryError(metadata);
1031
- expectMatchCustomEventPayload(SearchPageEvents.queryError, expectedMetadata);
1032
- });
1033
-
1034
- it('should send proper payload for #logPagerNumber', async () => {
1035
- const metadata = {
1036
- ...baseCaseMetadata,
1037
- pagerNumber: 123,
1038
- };
1039
-
1040
- const expectedMetadata = {
1041
- ...expectedBaseCaseMetadata,
1042
- pagerNumber: 123,
1043
- };
1044
- await client.logPagerNumber(metadata);
1045
- expectMatchCustomEventPayload(SearchPageEvents.pagerNumber, expectedMetadata);
1046
- });
1047
-
1048
- it('should send proper payload for #logPagerNext', async () => {
1049
- const metadata = {
1050
- ...baseCaseMetadata,
1051
- pagerNumber: 123,
1052
- };
1053
-
1054
- const expectedMetadata = {
1055
- ...expectedBaseCaseMetadata,
1056
- pagerNumber: 123,
1057
- };
1058
- await client.logPagerNext(metadata);
1059
- expectMatchCustomEventPayload(SearchPageEvents.pagerNext, expectedMetadata);
1060
- });
1061
-
1062
- it('should send proper payload for #logPagerPrevious', async () => {
1063
- const metadata = {
1064
- ...baseCaseMetadata,
1065
- pagerNumber: 123,
1066
- };
1067
-
1068
- const expectedMetadata = {
1069
- ...expectedBaseCaseMetadata,
1070
- pagerNumber: 123,
1071
- };
1072
- await client.logPagerPrevious(metadata);
1073
- expectMatchCustomEventPayload(SearchPageEvents.pagerPrevious, expectedMetadata);
1074
- });
1075
-
1076
- it('should send proper payload for #didyoumeanAutomatic', async () => {
1077
- const metadata = baseCaseMetadata;
1078
-
1079
- const expectedMetadata = {
1080
- ...expectedBaseCaseMetadata,
1081
- context_Case_Subject: 'test subject',
1082
- context_Case_Description: 'test description',
1083
- };
1084
- await client.logDidYouMeanAutomatic(metadata);
1085
- expectMatchPayload(SearchPageEvents.didyoumeanAutomatic, expectedMetadata);
1086
- });
1087
-
1088
- it('should send proper payload for #didyoumeanClick', async () => {
1089
- const metadata = baseCaseMetadata;
1090
-
1091
- const expectedMetadata = {
1092
- ...expectedBaseCaseMetadata,
1093
- context_Case_Subject: 'test subject',
1094
- context_Case_Description: 'test description',
1095
- };
1096
- await client.logDidYouMeanClick(metadata);
1097
- expectMatchPayload(SearchPageEvents.didyoumeanClick, expectedMetadata);
1098
- });
1099
-
1100
- it('should send proper payload for #resultsSort', async () => {
1101
- const metadata = {
1102
- ...baseCaseMetadata,
1103
- resultsSortBy: 'date ascending',
1104
- };
1105
-
1106
- const expectedMetadata = {
1107
- ...expectedBaseCaseMetadata,
1108
- context_Case_Subject: 'test subject',
1109
- context_Case_Description: 'test description',
1110
- resultsSortBy: 'date ascending',
1111
- };
1112
- await client.logResultsSort(metadata);
1113
- expectMatchPayload(SearchPageEvents.resultsSort, expectedMetadata);
1114
- });
1115
-
1116
- it('should send proper payload for #searchboxSubmit', async () => {
1117
- const metadata = baseCaseMetadata;
1118
-
1119
- const expectedMetadata = {
1120
- ...expectedBaseCaseMetadata,
1121
- context_Case_Subject: 'test subject',
1122
- context_Case_Description: 'test description',
1123
- };
1124
- await client.logSearchboxSubmit(metadata);
1125
- expectMatchPayload(SearchPageEvents.searchboxSubmit, expectedMetadata);
1126
- });
1127
-
1128
- it('should send proper payload for #documentOpen', async () => {
1129
- const metadata = baseCaseMetadata;
1130
-
1131
- const expectedMetadata = {
1132
- ...fakeDocID,
1133
- ...expectedBaseCaseMetadata,
1134
- };
1135
- await client.logDocumentOpen(fakeDocInfo, fakeDocID, metadata);
1136
- expectMatchDocumentPayload(SearchPageEvents.documentOpen, fakeDocInfo, expectedMetadata);
1137
- });
1138
-
1139
- it('should send proper payload for #copyToClipboard', async () => {
1140
- const metadata = baseCaseMetadata;
1141
-
1142
- const expectedMetadata = {
1143
- ...fakeDocID,
1144
- ...expectedBaseCaseMetadata,
1145
- };
1146
- await client.logCopyToClipboard(fakeDocInfo, fakeDocID, metadata);
1147
- expectMatchDocumentPayload(SearchPageEvents.copyToClipboard, fakeDocInfo, expectedMetadata);
1148
- });
1149
-
1150
- it('should send proper payload for #caseSendEmail', async () => {
1151
- const metadata = baseCaseMetadata;
1152
-
1153
- const expectedMetadata = {
1154
- ...fakeDocID,
1155
- ...expectedBaseCaseMetadata,
1156
- };
1157
- await client.logCaseSendEmail(fakeDocInfo, fakeDocID, metadata);
1158
- expectMatchDocumentPayload(SearchPageEvents.caseSendEmail, fakeDocInfo, expectedMetadata);
1159
- });
1160
-
1161
- it('should send proper payload for #feedItemTextPost', async () => {
1162
- const metadata = baseCaseMetadata;
1163
-
1164
- const expectedMetadata = {
1165
- ...fakeDocID,
1166
- ...expectedBaseCaseMetadata,
1167
- };
1168
- await client.logFeedItemTextPost(fakeDocInfo, fakeDocID, metadata);
1169
- expectMatchDocumentPayload(SearchPageEvents.feedItemTextPost, fakeDocInfo, expectedMetadata);
1170
- });
1171
-
1172
- it('should send proper payload for #documentQuickview', async () => {
1173
- const metadata = baseCaseMetadata;
1174
-
1175
- const expectedMetadata = {
1176
- ...fakeDocID,
1177
- ...expectedBaseCaseMetadata,
1178
- documentTitle: fakeDocInfo.documentTitle,
1179
- documentURL: fakeDocInfo.documentUrl,
1180
- };
1181
- await client.logDocumentQuickview(fakeDocInfo, fakeDocID, metadata);
1182
- expectMatchDocumentPayload(SearchPageEvents.documentQuickview, fakeDocInfo, expectedMetadata);
1183
- });
1184
-
1185
- it('should send proper payload for #caseAttach', async () => {
1186
- const metadata = baseCaseMetadata;
1187
-
1188
- const expectedMetadata = {
1189
- ...fakeDocID,
1190
- ...expectedBaseCaseMetadata,
1191
- documentTitle: fakeDocInfo.documentTitle,
1192
- documentURL: fakeDocInfo.documentUrl,
1193
- resultUriHash: fakeDocInfo.documentUriHash,
1194
- };
1195
- await client.logCaseAttach(fakeDocInfo, fakeDocID, metadata);
1196
- expectMatchDocumentPayload(SearchPageEvents.caseAttach, fakeDocInfo, expectedMetadata);
1197
- });
1198
-
1199
- it('should send proper payload for #caseDetach', async () => {
1200
- const metadata = baseCaseMetadata;
1201
- const mockResultUriHash = fakeDocInfo.documentUriHash;
1202
- const mockPermanentId = fakeDocID.contentIDValue;
1203
-
1204
- const expectedMetadata = {
1205
- ...expectedBaseCaseMetadata,
1206
- resultUriHash: mockResultUriHash,
1207
- permanentId: mockPermanentId,
1208
- };
1209
- await client.logCaseDetach(mockResultUriHash, metadata, mockPermanentId);
1210
- expectMatchCustomEventPayload(SearchPageEvents.caseDetach, expectedMetadata);
1211
- });
1212
-
1213
- it('should send proper payload for #likeSmartSnippet', async () => {
1214
- await client.logLikeSmartSnippet(baseCaseMetadata);
1215
- expectMatchCustomEventPayload(SearchPageEvents.likeSmartSnippet, expectedBaseCaseMetadata);
1216
- });
1217
-
1218
- it('should send proper payload for #dislikeSmartSnippet', async () => {
1219
- await client.logDislikeSmartSnippet(baseCaseMetadata);
1220
- expectMatchCustomEventPayload(SearchPageEvents.dislikeSmartSnippet, expectedBaseCaseMetadata);
1221
- });
1222
-
1223
- it('should send proper payload for #expandSmartSnippet', async () => {
1224
- await client.logExpandSmartSnippet(baseCaseMetadata);
1225
- expectMatchCustomEventPayload(SearchPageEvents.expandSmartSnippet, expectedBaseCaseMetadata);
1226
- });
1227
-
1228
- it('should send proper payload for #collapseSmartSnippet', async () => {
1229
- await client.logCollapseSmartSnippet(baseCaseMetadata);
1230
- expectMatchCustomEventPayload(SearchPageEvents.collapseSmartSnippet, expectedBaseCaseMetadata);
1231
- });
1232
-
1233
- it('should send proper payload for #openSmartSnippetFeedbackModal', async () => {
1234
- await client.logOpenSmartSnippetFeedbackModal(baseCaseMetadata);
1235
- expectMatchCustomEventPayload(SearchPageEvents.openSmartSnippetFeedbackModal, expectedBaseCaseMetadata);
1236
- });
1237
-
1238
- it('should send proper payload for #closeSmartSnippetFeedbackModal', async () => {
1239
- await client.logCloseSmartSnippetFeedbackModal(baseCaseMetadata);
1240
- expectMatchCustomEventPayload(SearchPageEvents.closeSmartSnippetFeedbackModal, expectedBaseCaseMetadata);
1241
- });
1242
-
1243
- it('should send proper payload for #sendSmartSnippetReason', async () => {
1244
- const reason = 'other';
1245
- const details = 'example details';
1246
- const expectedMetadata = {
1247
- reason,
1248
- details,
1249
- ...expectedBaseCaseMetadata,
1250
- };
1251
-
1252
- await client.logSmartSnippetFeedbackReason(reason, details, baseCaseMetadata);
1253
- expectMatchCustomEventPayload(SearchPageEvents.sendSmartSnippetReason, expectedMetadata);
1254
- });
1255
-
1256
- it('should send proper payload for #expandSmartSnippetSuggestion', async () => {
1257
- const exampleSmartSnippetSuggestion = {
1258
- question: 'Abc',
1259
- answerSnippet: 'Def',
1260
- documentId: {contentIdKey: 'permanentid', contentIdValue: 'foo'},
1261
- };
1262
- const expectedMetadata = {
1263
- ...exampleSmartSnippetSuggestion,
1264
- ...expectedBaseCaseMetadata,
1265
- };
1266
-
1267
- await client.logExpandSmartSnippetSuggestion(exampleSmartSnippetSuggestion, baseCaseMetadata);
1268
- expectMatchCustomEventPayload(SearchPageEvents.expandSmartSnippetSuggestion, expectedMetadata);
1269
- });
1270
-
1271
- it('should send proper payload for #collapseSmartSnippetSuggestion', async () => {
1272
- const exampleSmartSnippetSuggestion = {
1273
- question: 'Abc',
1274
- answerSnippet: 'Def',
1275
- documentId: {contentIdKey: 'permanentid', contentIdValue: 'foo'},
1276
- };
1277
- const expectedMetadata = {
1278
- ...exampleSmartSnippetSuggestion,
1279
- ...expectedBaseCaseMetadata,
1280
- };
1281
-
1282
- await client.logCollapseSmartSnippetSuggestion(exampleSmartSnippetSuggestion, baseCaseMetadata);
1283
- expectMatchCustomEventPayload(SearchPageEvents.collapseSmartSnippetSuggestion, expectedMetadata);
1284
- });
1285
-
1286
- it('should send proper payload for #openSmartSnippetSource', async () => {
1287
- const expectedMetadata = {
1288
- ...fakeDocID,
1289
- ...expectedBaseCaseMetadata,
1290
- };
1291
- await client.logOpenSmartSnippetSource(fakeDocInfo, fakeDocID, baseCaseMetadata);
1292
- expectMatchDocumentPayload(SearchPageEvents.openSmartSnippetSource, fakeDocInfo, expectedMetadata);
1293
- });
1294
-
1295
- it('should send proper payload for #openSmartSnippetInlineLink', async () => {
1296
- const meta = {
1297
- ...fakeDocID,
1298
- linkText: 'Some text',
1299
- linkURL: 'https://invalid.com',
1300
- };
1301
- const expectedMetadata = {
1302
- ...meta,
1303
- ...expectedBaseCaseMetadata,
1304
- };
1305
-
1306
- await client.logOpenSmartSnippetInlineLink(fakeDocInfo, meta, baseCaseMetadata);
1307
- expectMatchDocumentPayload(SearchPageEvents.openSmartSnippetInlineLink, fakeDocInfo, expectedMetadata);
1308
- });
1309
-
1310
- it('should send proper payload for #openSmartSnippetSuggestionSource', async () => {
1311
- const meta = {
1312
- question: 'Abc',
1313
- answerSnippet: 'Def',
1314
- documentId: {contentIdKey: 'permanentid', contentIdValue: 'foo'},
1315
- };
1316
-
1317
- const expectedMetadata = {
1318
- ...meta,
1319
- ...expectedBaseCaseMetadata,
1320
- contentIDKey: meta.documentId.contentIdKey,
1321
- contentIDValue: meta.documentId.contentIdValue,
1322
- };
1323
-
1324
- await client.logOpenSmartSnippetSuggestionSource(fakeDocInfo, meta, baseCaseMetadata);
1325
- expectMatchDocumentPayload(
1326
- SearchPageEvents.openSmartSnippetSuggestionSource,
1327
- fakeDocInfo,
1328
- expectedMetadata,
1329
- );
1330
- });
1331
-
1332
- it('should send proper payload for #openSmartSnippetSuggestionInlineLink', async () => {
1333
- const meta = {
1334
- question: 'Abc',
1335
- answerSnippet: 'Def',
1336
- documentId: {contentIdKey: 'permanentid', contentIdValue: 'foo'},
1337
- linkText: 'Some text',
1338
- linkURL: 'https://invalid.com',
1339
- };
1340
- const expectedMetadata = {
1341
- ...meta,
1342
- ...expectedBaseCaseMetadata,
1343
- contentIDKey: meta.documentId.contentIdKey,
1344
- contentIDValue: meta.documentId.contentIdValue,
1345
- };
1346
-
1347
- await client.logOpenSmartSnippetSuggestionInlineLink(fakeDocInfo, meta, baseCaseMetadata);
1348
- expectMatchDocumentPayload(
1349
- SearchPageEvents.openSmartSnippetSuggestionInlineLink,
1350
- fakeDocInfo,
1351
- expectedMetadata,
1352
- );
1353
- });
1354
-
1355
- it('should send proper payload for #showMoreFoldedResults', async () => {
1356
- const expectedMetadata = {
1357
- ...fakeDocID,
1358
- ...expectedBaseCaseMetadata,
1359
- };
1360
- await client.logShowMoreFoldedResults(fakeDocInfo, fakeDocID, baseCaseMetadata);
1361
- expectMatchDocumentPayload(SearchPageEvents.showMoreFoldedResults, fakeDocInfo, expectedMetadata);
1362
- });
1363
-
1364
- it('should send proper payload for #showLessFoldedResults', async () => {
1365
- const expectedMetadata = {
1366
- ...expectedBaseCaseMetadata,
1367
- };
1368
- await client.logShowLessFoldedResults(baseCaseMetadata);
1369
- expectMatchCustomEventPayload(SearchPageEvents.showLessFoldedResults, expectedMetadata);
1370
- });
1371
-
1372
- it('should send proper payload for #likeGeneratedAnswer', async () => {
1373
- const exampleGeneratedAnswerMetadata = {
1374
- generativeQuestionAnsweringId: '123',
1375
- };
1376
- const expectedMetadata = {
1377
- ...exampleGeneratedAnswerMetadata,
1378
- ...expectedBaseCaseMetadata,
1379
- };
1380
-
1381
- await client.logLikeGeneratedAnswer(exampleGeneratedAnswerMetadata, baseCaseMetadata);
1382
- expectMatchCustomEventPayload(SearchPageEvents.likeGeneratedAnswer, expectedMetadata);
1383
- });
1384
-
1385
- it('should send proper payload for #dislikeGeneratedAnswer', async () => {
1386
- const exampleGeneratedAnswerMetadata = {
1387
- generativeQuestionAnsweringId: '123',
1388
- };
1389
- const expectedMetadata = {
1390
- ...exampleGeneratedAnswerMetadata,
1391
- ...expectedBaseCaseMetadata,
1392
- };
1393
-
1394
- await client.logDislikeGeneratedAnswer(exampleGeneratedAnswerMetadata, baseCaseMetadata);
1395
- expectMatchCustomEventPayload(SearchPageEvents.dislikeGeneratedAnswer, expectedMetadata);
1396
- });
1397
-
1398
- it('should send proper payload for #openGeneratedAnswerSource', async () => {
1399
- const exampleGeneratedAnswerMetadata = {
1400
- generativeQuestionAnsweringId: '123',
1401
- permanentId: 'foo',
1402
- citationId: 'bar',
1403
- };
1404
- const expectedMetadata = {
1405
- ...exampleGeneratedAnswerMetadata,
1406
- ...expectedBaseCaseMetadata,
1407
- };
1408
-
1409
- await client.logOpenGeneratedAnswerSource(exampleGeneratedAnswerMetadata, baseCaseMetadata);
1410
- expectMatchCustomEventPayload(SearchPageEvents.openGeneratedAnswerSource, expectedMetadata);
1411
- });
1412
-
1413
- it('should send proper payload for #generatedAnswerCitationClick', async () => {
1414
- const meta = {
1415
- generativeQuestionAnsweringId: '123',
1416
- citationId: 'bar',
1417
- documentId: {contentIdKey: 'permanentid', contentIdValue: 'foo'},
1418
- };
1419
-
1420
- const expectedMetadata = {
1421
- ...meta,
1422
- contentIDKey: meta.documentId.contentIdKey,
1423
- contentIDValue: meta.documentId.contentIdValue,
1424
- };
1425
-
1426
- await client.logGeneratedAnswerCitationClick(fakeDocInfo, meta, baseCaseMetadata);
1427
- expectMatchDocumentPayload(SearchPageEvents.generatedAnswerCitationClick, fakeDocInfo, expectedMetadata);
1428
- });
1429
-
1430
- it('should send proper payload for #generatedAnswerSourceHover', async () => {
1431
- const exampleGeneratedAnswerMetadata = {
1432
- generativeQuestionAnsweringId: '123',
1433
- permanentId: 'foo',
1434
- citationId: 'bar',
1435
- citationHoverTimeMs: 100,
1436
- };
1437
- const expectedMetadata = {
1438
- ...exampleGeneratedAnswerMetadata,
1439
- ...expectedBaseCaseMetadata,
1440
- };
1441
-
1442
- await client.logGeneratedAnswerSourceHover(exampleGeneratedAnswerMetadata, baseCaseMetadata);
1443
- expectMatchCustomEventPayload(SearchPageEvents.generatedAnswerSourceHover, expectedMetadata);
1444
- });
1445
-
1446
- it('should send proper payload for #generatedAnswerCopyToClipboard', async () => {
1447
- const exampleGeneratedAnswerMetadata = {
1448
- generativeQuestionAnsweringId: '123',
1449
- };
1450
- const expectedMetadata = {
1451
- ...exampleGeneratedAnswerMetadata,
1452
- ...expectedBaseCaseMetadata,
1453
- };
1454
-
1455
- await client.logGeneratedAnswerCopyToClipboard(exampleGeneratedAnswerMetadata, baseCaseMetadata);
1456
- expectMatchCustomEventPayload(SearchPageEvents.generatedAnswerCopyToClipboard, expectedMetadata);
1457
- });
1458
-
1459
- it('should send proper payload for #generatedAnswerHideAnswers', async () => {
1460
- const exampleGeneratedAnswerMetadata = {
1461
- generativeQuestionAnsweringId: '123',
1462
- };
1463
- const expectedMetadata = {
1464
- ...exampleGeneratedAnswerMetadata,
1465
- ...expectedBaseCaseMetadata,
1466
- };
1467
-
1468
- await client.logGeneratedAnswerHideAnswers(exampleGeneratedAnswerMetadata, baseCaseMetadata);
1469
- expectMatchCustomEventPayload(SearchPageEvents.generatedAnswerHideAnswers, expectedMetadata);
1470
- });
1471
-
1472
- it('should send proper payload for #generatedAnswerShowAnswers', async () => {
1473
- const exampleGeneratedAnswerMetadata = {
1474
- generativeQuestionAnsweringId: '123',
1475
- };
1476
- const expectedMetadata = {
1477
- ...exampleGeneratedAnswerMetadata,
1478
- ...expectedBaseCaseMetadata,
1479
- };
1480
-
1481
- await client.logGeneratedAnswerShowAnswers(exampleGeneratedAnswerMetadata, baseCaseMetadata);
1482
- expectMatchCustomEventPayload(SearchPageEvents.generatedAnswerShowAnswers, expectedMetadata);
1483
- });
1484
-
1485
- it('should send proper payload for #generatedAnswerExpand', async () => {
1486
- const exampleGeneratedAnswerMetadata = {
1487
- generativeQuestionAnsweringId: '123',
1488
- };
1489
- const expectedMetadata = {
1490
- ...exampleGeneratedAnswerMetadata,
1491
- ...expectedBaseCaseMetadata,
1492
- };
1493
-
1494
- await client.logGeneratedAnswerExpand(exampleGeneratedAnswerMetadata, baseCaseMetadata);
1495
- expectMatchCustomEventPayload(SearchPageEvents.generatedAnswerExpand, expectedMetadata);
1496
- });
1497
-
1498
- it('should send proper payload for #generatedAnswerCollapse', async () => {
1499
- const exampleGeneratedAnswerMetadata = {
1500
- generativeQuestionAnsweringId: '123',
1501
- };
1502
- const expectedMetadata = {
1503
- ...exampleGeneratedAnswerMetadata,
1504
- ...expectedBaseCaseMetadata,
1505
- };
1506
-
1507
- await client.logGeneratedAnswerCollapse(exampleGeneratedAnswerMetadata, baseCaseMetadata);
1508
- expectMatchCustomEventPayload(SearchPageEvents.generatedAnswerCollapse, expectedMetadata);
1509
- });
1510
-
1511
- it('should send proper payload for #generatedAnswerFeedbackSubmit', async () => {
1512
- const exampleGeneratedAnswerMetadata = {
1513
- generativeQuestionAnsweringId: '123',
1514
- reason: <GeneratedAnswerFeedbackReason>'other',
1515
- details: 'foo',
1516
- };
1517
- const expectedMetadata = {
1518
- ...exampleGeneratedAnswerMetadata,
1519
- ...expectedBaseCaseMetadata,
1520
- };
1521
-
1522
- await client.logGeneratedAnswerFeedbackSubmit(exampleGeneratedAnswerMetadata, baseCaseMetadata);
1523
- expectMatchCustomEventPayload(SearchPageEvents.generatedAnswerFeedbackSubmit, expectedMetadata);
1524
- });
1525
-
1526
- it('should send proper payload for #generatedAnswerFeedbackSubmitV2', async () => {
1527
- const exampleGeneratedAnswerMetadata = {
1528
- generativeQuestionAnsweringId: '123',
1529
- helpful: true,
1530
- readable: <GeneratedAnswerFeedbackReasonOption>'yes',
1531
- documented: <GeneratedAnswerFeedbackReasonOption>'no',
1532
- correctTopic: <GeneratedAnswerFeedbackReasonOption>'unknown',
1533
- hallucinationFree: <GeneratedAnswerFeedbackReasonOption>'yes',
1534
- details: 'foo',
1535
- documentUrl: 'https://document.com',
1536
- };
1537
- const expectedMetadata = {
1538
- ...exampleGeneratedAnswerMetadata,
1539
- ...expectedBaseCaseMetadata,
1540
- };
1541
-
1542
- await client.logGeneratedAnswerFeedbackSubmitV2(exampleGeneratedAnswerMetadata, baseCaseMetadata);
1543
- expectMatchCustomEventPayload(SearchPageEvents.generatedAnswerFeedbackSubmitV2, expectedMetadata);
1544
- });
1545
-
1546
- it('should send proper payload for #rephraseGeneratedAnswer', async () => {
1547
- const exampleGeneratedAnswerMetadata = {
1548
- generativeQuestionAnsweringId: '123',
1549
- rephraseFormat: <GeneratedAnswerRephraseFormat>'step',
1550
- };
1551
- const expectedMetadata = {
1552
- ...exampleGeneratedAnswerMetadata,
1553
- ...expectedBaseCaseMetadata,
1554
- };
1555
-
1556
- await client.logRephraseGeneratedAnswer(exampleGeneratedAnswerMetadata, baseCaseMetadata);
1557
- expectMatchPayload(SearchPageEvents.rephraseGeneratedAnswer, expectedMetadata);
1558
- });
1559
-
1560
- it('should send proper payload for #retryGeneratedAnswer', async () => {
1561
- const expectedMetadata = {
1562
- ...expectedBaseCaseMetadata,
1563
- };
1564
-
1565
- await client.logRetryGeneratedAnswer(baseCaseMetadata);
1566
- expectMatchPayload(SearchPageEvents.retryGeneratedAnswer, expectedMetadata);
1567
- });
1568
-
1569
- it('should send proper payload for #generatedAnswerStreamEnd', async () => {
1570
- const exampleGeneratedAnswerMetadata = {
1571
- generativeQuestionAnsweringId: '123',
1572
- answerGenerated: true,
1573
- answerTextIsEmpty: false,
1574
- };
1575
- const expectedMetadata = {
1576
- ...exampleGeneratedAnswerMetadata,
1577
- ...expectedBaseCaseMetadata,
1578
- };
1579
-
1580
- await client.logGeneratedAnswerStreamEnd(exampleGeneratedAnswerMetadata, baseCaseMetadata);
1581
- expectMatchCustomEventPayload(SearchPageEvents.generatedAnswerStreamEnd, expectedMetadata);
1582
- });
1583
-
1584
- it('should send proper payload for #generatedAnswerCitationDocumentAttach', async () => {
1585
- const meta = {
1586
- generativeQuestionAnsweringId: '123',
1587
- citationId: 'bar',
1588
- documentId: {contentIdKey: 'permanentid', contentIdValue: 'foo'},
1589
- };
1590
-
1591
- const expectedMetadata = {
1592
- ...meta,
1593
- ...expectedBaseCaseMetadata,
1594
- contentIDKey: meta.documentId.contentIdKey,
1595
- contentIDValue: meta.documentId.contentIdValue,
1596
- };
1597
-
1598
- await client.logGeneratedAnswerCitationDocumentAttach(fakeDocInfo, meta, baseCaseMetadata);
1599
- expectMatchDocumentPayload(
1600
- SearchPageEvents.generatedAnswerCitationDocumentAttach,
1601
- fakeDocInfo,
1602
- expectedMetadata,
1603
- );
1604
- });
1605
-
1606
- it('should send proper payload for #createArticle', async () => {
1607
- const exampleCreateArticleMetadata = {
1608
- articleType: 'Knowledge__kav',
1609
- };
1610
- const expectedMetadata = {
1611
- ...exampleCreateArticleMetadata,
1612
- ...expectedBaseCaseMetadata,
1613
- };
1614
- await client.logCreateArticle(exampleCreateArticleMetadata, baseCaseMetadata);
1615
- expectMatchCustomEventPayload(InsightEvents.createArticle, expectedMetadata);
1616
- });
1617
-
1618
- it('should send proper payload for #logTriggerNotify', async () => {
1619
- const exampleTriggerNotifyMetadata = {
1620
- notifications: ['foo', 'bar'],
1621
- };
1622
- const expectedMetadata = {
1623
- ...exampleTriggerNotifyMetadata,
1624
- ...expectedBaseCaseMetadata,
1625
- };
1626
- await client.logTriggerNotify(exampleTriggerNotifyMetadata, baseCaseMetadata);
1627
- expectMatchCustomEventPayload(SearchPageEvents.triggerNotify, expectedMetadata);
1628
- });
1629
- });
1630
-
1631
- it('should enable analytics tracking by default', () => {
1632
- const c = new CoveoInsightClient({}, provider);
1633
- expect(c.coveoAnalyticsClient instanceof CoveoAnalyticsClient).toBe(true);
1634
- });
1635
-
1636
- it('should allow disabling analytics on initialization', () => {
1637
- const c = new CoveoInsightClient({enableAnalytics: false}, provider);
1638
- expect(c.coveoAnalyticsClient instanceof NoopAnalytics).toBe(true);
1639
- });
1640
-
1641
- it('should allow disabling analytics after initialization', () => {
1642
- const c = new CoveoInsightClient({enableAnalytics: true}, provider);
1643
- expect(c.coveoAnalyticsClient instanceof CoveoAnalyticsClient).toBe(true);
1644
- c.disable();
1645
- expect(c.coveoAnalyticsClient instanceof NoopAnalytics).toBe(true);
1646
- });
1647
-
1648
- it('disabling analytics does not delete the visitorId', () => {
1649
- const visitorId = 'uuid';
1650
- Cookie.set('coveo_visitorId', visitorId);
1651
- const c = new CoveoInsightClient({enableAnalytics: true}, provider);
1652
-
1653
- expect(Cookie.get('coveo_visitorId')).toBe(visitorId);
1654
- c.disable();
1655
- expect(Cookie.get('coveo_visitorId')).toBe(visitorId);
1656
- });
1657
-
1658
- it('should disable analytics when doNotTrack is enabled', async () => {
1659
- (doNotTrack as jest.Mock).mockImplementationOnce(() => true);
1660
-
1661
- const c = new CoveoInsightClient({}, provider);
1662
- expect(c.coveoAnalyticsClient instanceof NoopAnalytics).toBe(true);
1663
- });
1664
-
1665
- it('should allow enabling analytics after initialization', () => {
1666
- const c = new CoveoInsightClient({enableAnalytics: false}, provider);
1667
- expect(c.coveoAnalyticsClient instanceof NoopAnalytics).toBe(true);
1668
- c.enable();
1669
- expect(c.coveoAnalyticsClient instanceof CoveoAnalyticsClient).toBe(true);
1670
- });
1671
-
1672
- it('should send proper payload for #contextChanged', async () => {
1673
- const meta = {
1674
- caseId: '1234',
1675
- caseNumber: '5678',
1676
- caseContext: {Case_Subject: 'test subject', Case_Description: 'test description'},
1677
- };
1678
-
1679
- const expectedMeta = {
1680
- CaseId: '1234',
1681
- CaseNumber: '5678',
1682
- CaseSubject: 'test subject',
1683
- context_Case_Subject: 'test subject',
1684
- context_Case_Description: 'test description',
1685
- };
1686
-
1687
- await client.logContextChanged(meta);
1688
- expectMatchPayload(InsightEvents.contextChanged, expectedMeta);
1689
- });
1690
-
1691
- it('should send proper payload for #expandToFullUI', async () => {
1692
- const meta = {
1693
- caseId: '1234',
1694
- caseNumber: '5678',
1695
- caseContext: {Case_Subject: 'test subject', Case_Description: 'test description'},
1696
- fullSearchComponentName: 'c__FullSearch',
1697
- triggeredBy: 'openFullSearchButton',
1698
- };
1699
-
1700
- const expectedMeta = {
1701
- CaseId: '1234',
1702
- CaseNumber: '5678',
1703
- CaseSubject: 'test subject',
1704
- fullSearchComponentName: 'c__FullSearch',
1705
- triggeredBy: 'openFullSearchButton',
1706
- };
1707
- await client.logExpandToFullUI(meta);
1708
- expectMatchCustomEventPayload(InsightEvents.expandToFullUI, expectedMeta);
1709
- });
1710
-
1711
- it('should send proper payload for #logOpenUserActions', async () => {
1712
- await client.logOpenUserActions(baseCaseMetadata);
1713
- expectMatchCustomEventPayload(InsightEvents.openUserActions, expectedBaseCaseMetadata);
1714
- });
1715
-
1716
- it('should send proper payload for #logShowPrecedingSession', async () => {
1717
- await client.logShowPrecedingSessions(baseCaseMetadata);
1718
- expectMatchCustomEventPayload(InsightEvents.showPrecedingSessions, expectedBaseCaseMetadata);
1719
- });
1720
-
1721
- it('should send proper payload for #logShowFollowingSession', async () => {
1722
- await client.logShowFollowingSessions(baseCaseMetadata);
1723
- expectMatchCustomEventPayload(InsightEvents.showFollowingSessions, expectedBaseCaseMetadata);
1724
- });
1815
+ await client.logContextChanged(meta);
1816
+ expectMatchPayload(InsightEvents.contextChanged, expectedMeta);
1817
+ });
1818
+
1819
+ it('should send proper payload for #expandToFullUI', async () => {
1820
+ const meta = {
1821
+ caseId: '1234',
1822
+ caseNumber: '5678',
1823
+ caseContext: {
1824
+ Case_Subject: 'test subject',
1825
+ Case_Description: 'test description',
1826
+ },
1827
+ fullSearchComponentName: 'c__FullSearch',
1828
+ triggeredBy: 'openFullSearchButton',
1829
+ };
1725
1830
 
1726
- it('should send proper payload for #logViewedDocumentClick', async () => {
1727
- const document = {
1728
- title: 'Some Title',
1729
- uri: 'https://www.some-uri.com',
1730
- uriHash: 'Acp8NfEWi0DeðeZU',
1731
- permanentId: '8c88cd894t2767a96fa4f109041bb62bb54ca21ff31c1d760814b60cbcf2',
1732
- };
1733
- await client.logViewedDocumentClick(document, baseCaseMetadata);
1734
- expectMatchCustomEventPayload(InsightEvents.clickViewedDocument, {
1735
- ...expectedBaseCaseMetadata,
1736
- document,
1737
- });
1831
+ const expectedMeta = {
1832
+ CaseId: '1234',
1833
+ CaseNumber: '5678',
1834
+ CaseSubject: 'test subject',
1835
+ fullSearchComponentName: 'c__FullSearch',
1836
+ triggeredBy: 'openFullSearchButton',
1837
+ };
1838
+ await client.logExpandToFullUI(meta);
1839
+ expectMatchCustomEventPayload(InsightEvents.expandToFullUI, expectedMeta);
1840
+ });
1841
+
1842
+ it('should send proper payload for #logOpenUserActions', async () => {
1843
+ await client.logOpenUserActions(baseCaseMetadata);
1844
+ expectMatchCustomEventPayload(InsightEvents.openUserActions, expectedBaseCaseMetadata);
1845
+ });
1846
+
1847
+ it('should send proper payload for #logShowPrecedingSession', async () => {
1848
+ await client.logShowPrecedingSessions(baseCaseMetadata);
1849
+ expectMatchCustomEventPayload(InsightEvents.showPrecedingSessions, expectedBaseCaseMetadata);
1850
+ });
1851
+
1852
+ it('should send proper payload for #logShowFollowingSession', async () => {
1853
+ await client.logShowFollowingSessions(baseCaseMetadata);
1854
+ expectMatchCustomEventPayload(InsightEvents.showFollowingSessions, expectedBaseCaseMetadata);
1855
+ });
1856
+
1857
+ it('should send proper payload for #logViewedDocumentClick', async () => {
1858
+ const document = {
1859
+ title: 'Some Title',
1860
+ uri: 'https://www.some-uri.com',
1861
+ uriHash: 'testUriHash',
1862
+ permanentId: '8c88cd894t2767a96fa4f109041bb62bb54ca21ff31c1d760814b60cbcf2',
1863
+ };
1864
+ await client.logViewedDocumentClick(document, baseCaseMetadata);
1865
+ expectMatchCustomEventPayload(InsightEvents.clickViewedDocument, {
1866
+ ...expectedBaseCaseMetadata,
1867
+ document,
1738
1868
  });
1869
+ });
1739
1870
 
1740
- it('should send proper payload for #logPageViewClick', async () => {
1741
- const pageView = {
1742
- title: 'Some Title',
1743
- contentIdKey: 'someKey',
1744
- contentIdValue: 'some-content-id-value',
1745
- };
1746
- await client.logPageViewClick(pageView, baseCaseMetadata);
1747
- expectMatchCustomEventPayload(InsightEvents.clickPageView, {
1748
- ...expectedBaseCaseMetadata,
1749
- pageView,
1750
- });
1871
+ it('should send proper payload for #logPageViewClick', async () => {
1872
+ const pageView = {
1873
+ title: 'Some Title',
1874
+ contentIdKey: 'someKey',
1875
+ contentIdValue: 'some-content-id-value',
1876
+ };
1877
+ await client.logPageViewClick(pageView, baseCaseMetadata);
1878
+ expectMatchCustomEventPayload(InsightEvents.clickPageView, {
1879
+ ...expectedBaseCaseMetadata,
1880
+ pageView,
1751
1881
  });
1882
+ });
1752
1883
  });