coveo.analytics 2.30.45 → 2.30.46

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 (47) hide show
  1. package/README.md +41 -41
  2. package/dist/browser.mjs +34 -16
  3. package/dist/coveoua.browser.js +1 -1
  4. package/dist/coveoua.browser.js.map +1 -1
  5. package/dist/coveoua.debug.js +54 -36
  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 +2 -2
  10. package/dist/definitions/insight/insightClient.d.ts +2 -0
  11. package/dist/definitions/version.d.ts +1 -1
  12. package/dist/library.cjs +151 -43
  13. package/dist/library.es.js +34 -16
  14. package/dist/library.js +151 -43
  15. package/dist/library.mjs +151 -43
  16. package/dist/react-native.es.js +34 -16
  17. package/package.json +7 -7
  18. package/src/caseAssist/caseAssistClient.spec.ts +5 -5
  19. package/src/caseAssist/caseAssistClient.ts +7 -4
  20. package/src/client/analytics.spec.ts +1 -1
  21. package/src/client/analytics.ts +11 -11
  22. package/src/client/analyticsBeaconClient.spec.ts +10 -10
  23. package/src/client/analyticsBeaconClient.ts +4 -4
  24. package/src/client/analyticsFetchClient.ts +1 -1
  25. package/src/client/analyticsRequestClient.ts +1 -1
  26. package/src/client/measurementProtocolMapper.ts +2 -2
  27. package/src/client/measurementProtocolMapping/baseMeasurementProtocolMapper.ts +1 -1
  28. package/src/client/measurementProtocolMapping/commerceMeasurementProtocolMapper.ts +5 -5
  29. package/src/client/noopAnalytics.ts +1 -1
  30. package/src/client/utils.spec.ts +6 -6
  31. package/src/coveoua/browser.ts +2 -2
  32. package/src/coveoua/plugins.ts +1 -1
  33. package/src/coveoua/simpleanalytics.spec.ts +5 -5
  34. package/src/coveoua/simpleanalytics.ts +1 -1
  35. package/src/donottrack.spec.ts +1 -1
  36. package/src/history.spec.ts +1 -1
  37. package/src/insight/insightClient.spec.ts +42 -8
  38. package/src/insight/insightClient.ts +82 -63
  39. package/src/plugins/ec.spec.ts +6 -6
  40. package/src/plugins/ec.ts +5 -5
  41. package/src/plugins/link.spec.ts +5 -5
  42. package/src/plugins/link.ts +1 -1
  43. package/src/plugins/svc.ts +1 -1
  44. package/src/searchPage/searchPageClient.spec.ts +3 -3
  45. package/src/searchPage/searchPageClient.ts +27 -24
  46. package/src/searchPage/searchPageEvents.ts +2 -1
  47. package/src/version.ts +1 -1
@@ -713,7 +713,7 @@ describe('custom clientId', () => {
713
713
  const client = new CoveoAnalyticsClient({});
714
714
  expect.assertions(1);
715
715
  await expect(client.setClientId('somestring')).rejects.toEqual(
716
- Error('Cannot generate uuid client id without a specific namespace string.')
716
+ Error('Cannot generate uuid client id without a specific namespace string.'),
717
717
  );
718
718
  //uuid v5 specific uuid generation
719
719
  });
@@ -79,19 +79,19 @@ export interface AnalyticsClient {
79
79
  ): Promise<PreparedEvent<TPreparedRequest, TCompleteRequest, TResponse>>;
80
80
  sendEvent(eventType: string, ...payload: VariableArgumentsPayload): Promise<AnyEventResponse | void>;
81
81
  makeSearchEvent(
82
- request: PreparedSearchEventRequest
82
+ request: PreparedSearchEventRequest,
83
83
  ): Promise<PreparedEvent<PreparedSearchEventRequest, SearchEventRequest, SearchEventResponse>>;
84
84
  sendSearchEvent(request: SearchEventRequest): Promise<SearchEventResponse | void>;
85
85
  makeClickEvent(
86
- request: PreparedClickEventRequest
86
+ request: PreparedClickEventRequest,
87
87
  ): Promise<PreparedEvent<PreparedClickEventRequest, ClickEventRequest, ClickEventResponse>>;
88
88
  sendClickEvent(request: ClickEventRequest): Promise<ClickEventResponse | void>;
89
89
  makeCustomEvent(
90
- request: PreparedCustomEventRequest
90
+ request: PreparedCustomEventRequest,
91
91
  ): Promise<PreparedEvent<PreparedCustomEventRequest, CustomEventRequest, CustomEventResponse>>;
92
92
  sendCustomEvent(request: CustomEventRequest): Promise<CustomEventResponse | void>;
93
93
  makeViewEvent(
94
- request: PreparedViewEventRequest
94
+ request: PreparedViewEventRequest,
95
95
  ): Promise<PreparedEvent<PreparedViewEventRequest, ViewEventRequest, ViewEventResponse>>;
96
96
  sendViewEvent(request: ViewEventRequest): Promise<ViewEventResponse | void>;
97
97
  getVisit(): Promise<VisitResponse>;
@@ -220,7 +220,7 @@ export class CoveoAnalyticsClient implements AnalyticsClient, VisitorIdProvider
220
220
  } catch (err) {
221
221
  console.log(
222
222
  'Could not get visitor ID from the current runtime environment storage. Using a random ID instead.',
223
- err
223
+ err,
224
224
  );
225
225
  return uuidv4();
226
226
  }
@@ -394,7 +394,7 @@ export class CoveoAnalyticsClient implements AnalyticsClient, VisitorIdProvider
394
394
  payload: {...payloadToSend, ...remainingPayload},
395
395
  });
396
396
  await Promise.all(
397
- this.afterSendHooks.map((hook) => hook(eventType, {...parametersToSend, ...remainingPayload}))
397
+ this.afterSendHooks.map((hook) => hook(eventType, {...parametersToSend, ...remainingPayload})),
398
398
  );
399
399
  await this.deferExecution();
400
400
  return (await this.sendFromBuffer()) as TResponse | void;
@@ -431,7 +431,7 @@ export class CoveoAnalyticsClient implements AnalyticsClient, VisitorIdProvider
431
431
  async makeSearchEvent(request: PreparedSearchEventRequest) {
432
432
  return this.makeEvent<PreparedSearchEventRequest, SearchEventRequest, SearchEventResponse>(
433
433
  EventType.search,
434
- request
434
+ request,
435
435
  );
436
436
  }
437
437
 
@@ -442,7 +442,7 @@ export class CoveoAnalyticsClient implements AnalyticsClient, VisitorIdProvider
442
442
  async makeClickEvent(request: PreparedClickEventRequest) {
443
443
  return this.makeEvent<PreparedClickEventRequest, ClickEventRequest, ClickEventResponse>(
444
444
  EventType.click,
445
- request
445
+ request,
446
446
  );
447
447
  }
448
448
 
@@ -453,7 +453,7 @@ export class CoveoAnalyticsClient implements AnalyticsClient, VisitorIdProvider
453
453
  async makeCustomEvent(request: PreparedCustomEventRequest) {
454
454
  return this.makeEvent<PreparedCustomEventRequest, CustomEventRequest, CustomEventResponse>(
455
455
  EventType.custom,
456
- request
456
+ request,
457
457
  );
458
458
  }
459
459
 
@@ -535,7 +535,7 @@ export class CoveoAnalyticsClient implements AnalyticsClient, VisitorIdProvider
535
535
  ...newPayload,
536
536
  [key]: payload[key],
537
537
  }),
538
- {}
538
+ {},
539
539
  );
540
540
  }
541
541
 
@@ -553,7 +553,7 @@ export class CoveoAnalyticsClient implements AnalyticsClient, VisitorIdProvider
553
553
  ...newPayload,
554
554
  [key]: payload[key],
555
555
  }),
556
- {}
556
+ {},
557
557
  );
558
558
  return newPayload;
559
559
  }
@@ -39,7 +39,7 @@ describe('AnalyticsBeaconClient', () => {
39
39
 
40
40
  expect(sendBeaconMock).toHaveBeenCalledWith(
41
41
  `${baseUrl}/analytics/custom?access_token=👛&visitorId=${currentVisitorId}&discardVisitInfo=true`,
42
- expect.anything()
42
+ expect.anything(),
43
43
  );
44
44
  expect(await getSendBeaconFirstCallBlobArgument()).toBe(`customEvent=${encodeURIComponent('{"wow":"ok"}')}`);
45
45
  });
@@ -63,12 +63,12 @@ describe('AnalyticsBeaconClient', () => {
63
63
 
64
64
  expect(sendBeaconMock).toHaveBeenCalledWith(
65
65
  `${baseUrl}/analytics/collect?visitorId=${currentVisitorId}&discardVisitInfo=true`,
66
- expect.anything()
66
+ expect.anything(),
67
67
  );
68
68
  expect(await getSendBeaconFirstCallBlobArgument()).toBe(
69
69
  `access_token=${encodeURIComponent('👛')}&collectEvent=${encodeURIComponent(
70
- '{"pr1a":"value","to encode":"to encode"}'
71
- )}`
70
+ '{"pr1a":"value","to encode":"to encode"}',
71
+ )}`,
72
72
  );
73
73
  });
74
74
 
@@ -94,10 +94,10 @@ describe('AnalyticsBeaconClient', () => {
94
94
 
95
95
  expect(sendBeaconMock).toHaveBeenCalledWith(
96
96
  `${baseUrl}/analytics/collect?visitorId=${currentVisitorId}&discardVisitInfo=true`,
97
- expect.anything()
97
+ expect.anything(),
98
98
  );
99
99
  expect(await getSendBeaconFirstCallBlobArgument()).toBe(
100
- `access_token=${encodeURIComponent('👛')}&collectEvent=${encodeURIComponent('{"value":{"subvalue":"ok"}}')}`
100
+ `access_token=${encodeURIComponent('👛')}&collectEvent=${encodeURIComponent('{"value":{"subvalue":"ok"}}')}`,
101
101
  );
102
102
  });
103
103
 
@@ -147,7 +147,7 @@ describe('AnalyticsBeaconClient', () => {
147
147
 
148
148
  await client.sendEvent(EventType.collect, {foo: 'bar'});
149
149
  expect(await getSendBeaconFirstCallBlobArgument()).toBe(
150
- 'access_token=%F0%9F%91%9B&collectEvent=%7B%22foo%22%3A%22baz%22%7D'
150
+ 'access_token=%F0%9F%91%9B&collectEvent=%7B%22foo%22%3A%22baz%22%7D',
151
151
  );
152
152
  });
153
153
 
@@ -162,7 +162,7 @@ describe('AnalyticsBeaconClient', () => {
162
162
 
163
163
  await client.sendEvent(EventType.click, {actionCause: 'foo'});
164
164
  expect(await getSendBeaconFirstCallBlobArgument()).toContain(
165
- `clickEvent=${encodeURIComponent('{"actionCause":"bar"}')}`
165
+ `clickEvent=${encodeURIComponent('{"actionCause":"bar"}')}`,
166
166
  );
167
167
  });
168
168
 
@@ -176,7 +176,7 @@ describe('AnalyticsBeaconClient', () => {
176
176
 
177
177
  await client.sendEvent(EventType.click, {actionCause: 'foo'});
178
178
  expect(await getSendBeaconFirstCallBlobArgument()).toContain(
179
- `clickEvent=${encodeURIComponent('{"actionCause":"foo","aNewProperty":"bar"}')}`
179
+ `clickEvent=${encodeURIComponent('{"actionCause":"foo","aNewProperty":"bar"}')}`,
180
180
  );
181
181
  });
182
182
 
@@ -188,7 +188,7 @@ describe('AnalyticsBeaconClient', () => {
188
188
 
189
189
  await client.sendEvent(EventType.click, {actionCause: 'bar'});
190
190
  expect(await getSendBeaconFirstCallBlobArgument()).toContain(
191
- `clickEvent=${encodeURIComponent(`{"actionCause":"bar"}`)}`
191
+ `clickEvent=${encodeURIComponent(`{"actionCause":"bar"}`)}`,
192
192
  );
193
193
  });
194
194
  });
@@ -7,7 +7,7 @@ export class AnalyticsBeaconClient implements AnalyticsRequestClient {
7
7
  public async sendEvent(eventType: EventType, originalPayload: IRequestPayload): Promise<void> {
8
8
  if (!this.isAvailable()) {
9
9
  throw new Error(
10
- `navigator.sendBeacon is not supported in this browser. Consider adding a polyfill like "sendbeacon-polyfill".`
10
+ `navigator.sendBeacon is not supported in this browser. Consider adding a polyfill like "sendbeacon-polyfill".`,
11
11
  );
12
12
  }
13
13
 
@@ -18,7 +18,7 @@ export class AnalyticsBeaconClient implements AnalyticsRequestClient {
18
18
  const {url, payload} = await this.preProcessRequestAsPotentialJSONString(
19
19
  `${baseUrl}/analytics/${eventType}?${paramsFragments}`,
20
20
  originalPayload,
21
- preprocessRequest
21
+ preprocessRequest,
22
22
  );
23
23
 
24
24
  const parsedRequestData = this.encodeForEventType(eventType, payload);
@@ -41,7 +41,7 @@ export class AnalyticsBeaconClient implements AnalyticsRequestClient {
41
41
  private async preProcessRequestAsPotentialJSONString(
42
42
  originalURL: string,
43
43
  originalPayload: IRequestPayload,
44
- preprocessRequest?: PreprocessAnalyticsRequest
44
+ preprocessRequest?: PreprocessAnalyticsRequest,
45
45
  ): Promise<{url: string; payload: IRequestPayload}> {
46
46
  let returnedUrl = originalURL;
47
47
  let returnedPayload = originalPayload;
@@ -49,7 +49,7 @@ export class AnalyticsBeaconClient implements AnalyticsRequestClient {
49
49
  if (preprocessRequest) {
50
50
  const processedRequest = await preprocessRequest(
51
51
  {url: originalURL, body: JSON.stringify(originalPayload)},
52
- 'analyticsBeacon'
52
+ 'analyticsBeacon',
53
53
  );
54
54
  const {url: processedURL, body: processedBody} = processedRequest;
55
55
  returnedUrl = processedURL || originalURL;
@@ -47,7 +47,7 @@ export class AnalyticsFetchClient implements AnalyticsRequestClient {
47
47
  }
48
48
  console.error(`An error has occured when sending the "${eventType}" event.`, response, payload);
49
49
  throw new Error(
50
- `An error has occurred when sending the "${eventType}" event. Check the console logs for more details.`
50
+ `An error has occurred when sending the "${eventType}" event. Check the console logs for more details.`,
51
51
  );
52
52
  }
53
53
  }
@@ -21,7 +21,7 @@ export type AnalyticsClientOrigin = 'analyticsFetch' | 'analyticsBeacon';
21
21
 
22
22
  export type PreprocessAnalyticsRequest = (
23
23
  request: IAnalyticsRequestOptions,
24
- clientOrigin: AnalyticsClientOrigin
24
+ clientOrigin: AnalyticsClientOrigin,
25
25
  ) => IAnalyticsRequestOptions | Promise<IAnalyticsRequestOptions>;
26
26
 
27
27
  export interface IAnalyticsRequestOptions extends RequestInit {
@@ -24,7 +24,7 @@ export const convertKeysToMeasurementProtocol = (params: any) => {
24
24
  };
25
25
 
26
26
  const measurementProtocolKeysMappingValues = keysOf(measurementProtocolKeysMapping).map(
27
- (key) => measurementProtocolKeysMapping[key]
27
+ (key) => measurementProtocolKeysMapping[key],
28
28
  );
29
29
 
30
30
  const isKnownMeasurementProtocolKey = (key: string) => measurementProtocolKeysMappingValues.indexOf(key) !== -1;
@@ -66,6 +66,6 @@ const convertCustomObject = (prefix: string, customData: {[name: string]: string
66
66
  ...allCustom,
67
67
  [`${prefix}${currentCustomKey}`]: customData[currentCustomKey],
68
68
  }),
69
- {}
69
+ {},
70
70
  );
71
71
  };
@@ -56,6 +56,6 @@ export const baseMeasurementProtocolKeysMapping: {[name: string]: string} = {
56
56
  ...all,
57
57
  [key]: key,
58
58
  }),
59
- {}
59
+ {},
60
60
  ),
61
61
  };
@@ -112,7 +112,7 @@ export const convertProductToMeasurementProtocol = (product: Product, index: num
112
112
  export const convertImpressionListToMeasurementProtocol = (
113
113
  impressionList: ImpressionList,
114
114
  listIndex: number,
115
- prefix: string
115
+ prefix: string,
116
116
  ) => {
117
117
  const payload: {[name: string]: any} = impressionList.impressions.reduce(
118
118
  (mappedImpressions, impression, productIndex) => {
@@ -121,7 +121,7 @@ export const convertImpressionListToMeasurementProtocol = (
121
121
  ...convertImpressionToMeasurementProtocol(impression, listIndex, productIndex, prefix),
122
122
  };
123
123
  },
124
- {}
124
+ {},
125
125
  );
126
126
 
127
127
  if (impressionList.listName) {
@@ -135,7 +135,7 @@ const convertImpressionToMeasurementProtocol = (
135
135
  impression: BaseImpression,
136
136
  listIndex: number,
137
137
  productIndex: number,
138
- prefix: string
138
+ prefix: string,
139
139
  ) => {
140
140
  return keysOf(impression).reduce((mappedImpression, key) => {
141
141
  const newKey = `il${listIndex + 1}${prefix}${productIndex + 1}${impressionKeysMapping[key] || key}`;
@@ -150,7 +150,7 @@ const productKeysMappingValues = keysOf(productKeysMapping).map((key) => product
150
150
  const impressionKeysMappingValues = keysOf(impressionKeysMapping).map((key) => impressionKeysMapping[key]);
151
151
  const productActionsKeysMappingValues = keysOf(productActionsKeysMapping).map((key) => productActionsKeysMapping[key]);
152
152
  const transactionActionsKeysMappingValues = keysOf(transactionActionsKeysMapping).map(
153
- (key) => transactionActionsKeysMapping[key]
153
+ (key) => transactionActionsKeysMapping[key],
154
154
  );
155
155
  const reviewKeysMappingValues = keysOf(reviewActionsKeysMapping).map((key) => reviewActionsKeysMapping[key]);
156
156
  const quoteKeysMappingValues = keysOf(quoteActionsKeysMapping).map((key) => quoteActionsKeysMapping[key]);
@@ -166,7 +166,7 @@ const transactionActionsKeyRegex = new RegExp(`^(${transactionActionsKeysMapping
166
166
  const customProductKeyRegex = new RegExp(`^${productPrefixMatchGroup}custom$`);
167
167
  const customImpressionKeyRegex = new RegExp(`^${impressionPrefixMatchGroup}custom$`);
168
168
  const coveoCommerceExtensionKeysRegex = new RegExp(
169
- `^(${[...coveoCommerceExtensionKeys, ...reviewKeysMappingValues, ...quoteKeysMappingValues].join('|')})$`
169
+ `^(${[...coveoCommerceExtensionKeys, ...reviewKeysMappingValues, ...quoteKeysMappingValues].join('|')})$`,
170
170
  );
171
171
 
172
172
  const isProductKey = (key: string) => productKeyRegex.test(key);
@@ -28,7 +28,7 @@ export class NoopAnalytics implements AnalyticsClient {
28
28
  return Promise.resolve();
29
29
  }
30
30
  makeEvent<TPreparedRequest, TCompleteRequest, TResponse extends AnyEventResponse>(
31
- eventType: EventType | string
31
+ eventType: EventType | string,
32
32
  ): Promise<PreparedEvent<TPreparedRequest, TCompleteRequest, TResponse>> {
33
33
  return Promise.resolve({eventType: eventType as EventType, payload: null, log: () => Promise.resolve()});
34
34
  }
@@ -9,7 +9,7 @@ describe('utils', () => {
9
9
  `truncateUrl('${URL_PLAIN}', %d) truncates to exactly that length`,
10
10
  (limit) => {
11
11
  expect(truncateUrl(URL_PLAIN, limit)).toBe(URL_PLAIN.substring(0, limit));
12
- }
12
+ },
13
13
  );
14
14
 
15
15
  /** Decoded: `'http://test/ ¿OKツ😅#fine'` */
@@ -20,7 +20,7 @@ describe('utils', () => {
20
20
  `truncateUrl('${URL_WITH_ESCAPES}', %d) truncates to the exact limit outside of codepoints`,
21
21
  (limit) => {
22
22
  expect(truncateUrl(URL_WITH_ESCAPES, limit)).toBe(URL_WITH_ESCAPES.substring(0, limit));
23
- }
23
+ },
24
24
  );
25
25
 
26
26
  it.each([
@@ -32,7 +32,7 @@ describe('utils', () => {
32
32
  `truncateUrl('${URL_WITH_ESCAPES}', %d) does not break up single-byte codepoints`,
33
33
  (limit, expectedLength) => {
34
34
  expect(truncateUrl(URL_WITH_ESCAPES, limit)).toBe(URL_WITH_ESCAPES.substring(0, expectedLength));
35
- }
35
+ },
36
36
  );
37
37
 
38
38
  it.each([
@@ -62,7 +62,7 @@ describe('utils', () => {
62
62
  `truncateUrl('${URL_WITH_ESCAPES}', %d) does not break up three-byte codepoints`,
63
63
  (limit, expectedLength) => {
64
64
  expect(truncateUrl(URL_WITH_ESCAPES, limit)).toBe(URL_WITH_ESCAPES.substring(0, expectedLength));
65
- }
65
+ },
66
66
  );
67
67
 
68
68
  it.each([
@@ -105,9 +105,9 @@ describe('utils', () => {
105
105
  `truncateUrl('${URL_WITH_INVALID_ESCAPES}', %d) only checks for percent with invalid escapes`,
106
106
  (limit, expectedLength) => {
107
107
  expect(truncateUrl(URL_WITH_INVALID_ESCAPES, limit)).toBe(
108
- URL_WITH_INVALID_ESCAPES.substring(0, expectedLength)
108
+ URL_WITH_INVALID_ESCAPES.substring(0, expectedLength),
109
109
  );
110
- }
110
+ },
111
111
  );
112
112
  });
113
113
  });
@@ -6,13 +6,13 @@ declare const self: any;
6
6
  const promise = (window as any)['Promise'];
7
7
  if (!(promise instanceof Function) && !global) {
8
8
  console.error(
9
- `This script uses window.Promise which is not supported in your browser. Consider adding a polyfill like "es6-promise".`
9
+ `This script uses window.Promise which is not supported in your browser. Consider adding a polyfill like "es6-promise".`,
10
10
  );
11
11
  }
12
12
  const fetch = (window as any)['fetch'];
13
13
  if (!(fetch instanceof Function) && !global) {
14
14
  console.error(
15
- `This script uses window.fetch which is not supported in your browser. Consider adding a polyfill like "fetch".`
15
+ `This script uses window.fetch which is not supported in your browser. Consider adding a polyfill like "fetch".`,
16
16
  );
17
17
  }
18
18
 
@@ -16,7 +16,7 @@ export class Plugins {
16
16
  const pluginClass = this.registeredPluginsMap[name];
17
17
  if (!pluginClass) {
18
18
  throw new Error(
19
- `No plugin named "${name}" is currently registered. If you use a custom plugin, use 'provide' first.`
19
+ `No plugin named "${name}" is currently registered. If you use a custom plugin, use 'provide' first.`,
20
20
  );
21
21
  }
22
22
  this.requiredPlugins[name] = new (pluginClass as any)(options);
@@ -63,7 +63,7 @@ describe('simpleanalytics', () => {
63
63
 
64
64
  it('throws when initializing with a token that is not a string nor a AnalyticClient', () => {
65
65
  expect(() => coveoua('init', {})).toThrow(
66
- `You must pass either your token or a valid object when you call 'init'`
66
+ `You must pass either your token or a valid object when you call 'init'`,
67
67
  );
68
68
  });
69
69
 
@@ -165,7 +165,7 @@ describe('simpleanalytics', () => {
165
165
 
166
166
  it(`throw if the initForProxy receive an endpoint that is not a string`, () => {
167
167
  expect(() => coveoua('initForProxy', {})).toThrow(
168
- `You must pass a string as the endpoint parameter when you call 'initForProxy'`
168
+ `You must pass a string as the endpoint parameter when you call 'initForProxy'`,
169
169
  );
170
170
  });
171
171
  });
@@ -484,7 +484,7 @@ describe('simpleanalytics', () => {
484
484
  coveoua('init', 'MYTOKEN', {plugins: []});
485
485
 
486
486
  expect(() => coveoua('require', 'test')).toThrow(
487
- `No plugin named "test" is currently registered. If you use a custom plugin, use 'provide' first.`
487
+ `No plugin named "test" is currently registered. If you use a custom plugin, use 'provide' first.`,
488
488
  );
489
489
  });
490
490
  });
@@ -506,7 +506,7 @@ describe('simpleanalytics', () => {
506
506
  coveoua('reset');
507
507
 
508
508
  expect(() => coveoua('init', 'MYTOKEN', {plugins: ['test']})).toThrow(
509
- `No plugin named "test" is currently registered. If you use a custom plugin, use 'provide' first.`
509
+ `No plugin named "test" is currently registered. If you use a custom plugin, use 'provide' first.`,
510
510
  );
511
511
  });
512
512
 
@@ -529,7 +529,7 @@ describe('simpleanalytics', () => {
529
529
  coveoua('init', 'SOME TOKEN', {plugins: ['svc']});
530
530
 
531
531
  expect(() => coveoua('potato')).toThrow(
532
- `The action "potato" does not exist. Available actions: init, set, send, onLoad, callPlugin, reset, require, provide, version.`
532
+ `The action "potato" does not exist. Available actions: init, set, send, onLoad, callPlugin, reset, require, provide, version.`,
533
533
  );
534
534
  });
535
535
 
@@ -42,7 +42,7 @@ export class CoveoUA {
42
42
  const pluginOptions: PluginOptions = {client: this.client};
43
43
  this.plugins.clearRequired();
44
44
  this.getPluginKeys(optionsOrEndpoint).forEach((pluginKey) =>
45
- this.plugins.require(pluginKey, pluginOptions)
45
+ this.plugins.require(pluginKey, pluginOptions),
46
46
  );
47
47
  this.client.registerBeforeSendEventHook((eventType, payload) => ({
48
48
  ...payload,
@@ -8,7 +8,7 @@ describe('doNotTrack', () => {
8
8
  navigatorDoNotTrack?: any;
9
9
  navigatorMsDoNotTrack?: any;
10
10
  windowDoNotTrack?: any;
11
- }
11
+ },
12
12
  ) {
13
13
  jest.resetModules();
14
14
  jest.mock('./detector', () => ({
@@ -166,7 +166,7 @@ describe('history', () => {
166
166
 
167
167
  expect(storageMock.setItem).toHaveBeenCalledWith(
168
168
  history.STORE_KEY,
169
- expect.stringContaining(JSON.stringify(historyElements))
169
+ expect.stringContaining(JSON.stringify(historyElements)),
170
170
  );
171
171
  });
172
172
 
@@ -162,6 +162,16 @@ describe('InsightClient', () => {
162
162
  expectMatchPayload(SearchPageEvents.interfaceLoad);
163
163
  });
164
164
 
165
+ it('should send proper payload for #recentQueryClick', async () => {
166
+ await client.logRecentQueryClick();
167
+ expectMatchPayload(SearchPageEvents.recentQueryClick);
168
+ });
169
+
170
+ it('should send proper payload for #clearRecentQueries', async () => {
171
+ await client.logClearRecentQueries();
172
+ expectMatchCustomEventPayload(SearchPageEvents.clearRecentQueries);
173
+ });
174
+
165
175
  it('should send proper payload for #interfaceChange', async () => {
166
176
  await client.logInterfaceChange({
167
177
  interfaceChangeTo: 'bob',
@@ -443,7 +453,7 @@ describe('InsightClient', () => {
443
453
  await client.logCollapseSmartSnippetSuggestion(exampleSmartSnippetSuggestion);
444
454
  expectMatchCustomEventPayload(
445
455
  SearchPageEvents.collapseSmartSnippetSuggestion,
446
- exampleSmartSnippetSuggestion
456
+ exampleSmartSnippetSuggestion,
447
457
  );
448
458
  });
449
459
 
@@ -480,7 +490,7 @@ describe('InsightClient', () => {
480
490
  expectMatchDocumentPayload(
481
491
  SearchPageEvents.openSmartSnippetSuggestionSource,
482
492
  fakeDocInfo,
483
- expectedMetadata
493
+ expectedMetadata,
484
494
  );
485
495
  });
486
496
 
@@ -502,7 +512,7 @@ describe('InsightClient', () => {
502
512
  expectMatchDocumentPayload(
503
513
  SearchPageEvents.openSmartSnippetSuggestionInlineLink,
504
514
  fakeDocInfo,
505
- expectedMetadata
515
+ expectedMetadata,
506
516
  );
507
517
  });
508
518
  it('should send proper payload for #showMoreFoldedResults', async () => {
@@ -581,7 +591,7 @@ describe('InsightClient', () => {
581
591
  await client.logGeneratedAnswerCopyToClipboard(exampleGeneratedAnswerMetadata);
582
592
  expectMatchCustomEventPayload(
583
593
  SearchPageEvents.generatedAnswerCopyToClipboard,
584
- exampleGeneratedAnswerMetadata
594
+ exampleGeneratedAnswerMetadata,
585
595
  );
586
596
  });
587
597
 
@@ -631,7 +641,7 @@ describe('InsightClient', () => {
631
641
  await client.logGeneratedAnswerFeedbackSubmit(exampleGeneratedAnswerMetadata);
632
642
  expectMatchCustomEventPayload(
633
643
  SearchPageEvents.generatedAnswerFeedbackSubmit,
634
- exampleGeneratedAnswerMetadata
644
+ exampleGeneratedAnswerMetadata,
635
645
  );
636
646
  });
637
647
 
@@ -693,7 +703,7 @@ describe('InsightClient', () => {
693
703
  await client.logGeneratedAnswerFeedbackSubmitV2(exampleGeneratedAnswerMetadata);
694
704
  expectMatchCustomEventPayload(
695
705
  SearchPageEvents.generatedAnswerFeedbackSubmitV2,
696
- exampleGeneratedAnswerMetadata
706
+ exampleGeneratedAnswerMetadata,
697
707
  );
698
708
  });
699
709
  });
@@ -711,6 +721,30 @@ describe('InsightClient', () => {
711
721
  expectMatchPayload(SearchPageEvents.interfaceLoad, expectedMetadata);
712
722
  });
713
723
 
724
+ it('should send proper payload for #recentQueryClick', async () => {
725
+ const metadata = baseCaseMetadata;
726
+
727
+ const expectedMetadata = {
728
+ ...expectedBaseCaseMetadata,
729
+ context_Case_Subject: 'test subject',
730
+ context_Case_Description: 'test description',
731
+ };
732
+ await client.logRecentQueryClick(metadata);
733
+ expectMatchPayload(SearchPageEvents.recentQueryClick, expectedMetadata);
734
+ });
735
+
736
+ it('should send proper payload for #clearRecentQueries', async () => {
737
+ const metadata = baseCaseMetadata;
738
+
739
+ const expectedMetadata = {
740
+ ...expectedBaseCaseMetadata,
741
+ context_Case_Subject: 'test subject',
742
+ context_Case_Description: 'test description',
743
+ };
744
+ await client.logClearRecentQueries(metadata);
745
+ expectMatchCustomEventPayload(SearchPageEvents.clearRecentQueries, expectedMetadata);
746
+ });
747
+
714
748
  it('should send proper payload for #interfaceChange', async () => {
715
749
  const metadata = {
716
750
  ...baseCaseMetadata,
@@ -1263,7 +1297,7 @@ describe('InsightClient', () => {
1263
1297
  expectMatchDocumentPayload(
1264
1298
  SearchPageEvents.openSmartSnippetSuggestionSource,
1265
1299
  fakeDocInfo,
1266
- expectedMetadata
1300
+ expectedMetadata,
1267
1301
  );
1268
1302
  });
1269
1303
 
@@ -1286,7 +1320,7 @@ describe('InsightClient', () => {
1286
1320
  expectMatchDocumentPayload(
1287
1321
  SearchPageEvents.openSmartSnippetSuggestionInlineLink,
1288
1322
  fakeDocInfo,
1289
- expectedMetadata
1323
+ expectedMetadata,
1290
1324
  );
1291
1325
  });
1292
1326