coveo.analytics 2.20.21 → 2.20.23

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.
@@ -1,6 +1,6 @@
1
1
  import { ClientOptions, AnalyticsClient } from '../client/analytics';
2
2
  import { SearchEventRequest } from '../events';
3
- import { SearchPageEvents, OmniboxSuggestionsMetadata, FacetMetadata, FacetRangeMetadata, CategoryFacetMetadata, DocumentIdentifier, InterfaceChangeMetadata, ResultsSortMetadata, PartialDocumentInformation, TriggerNotifyMetadata, TriggerExecuteMetadata, TriggerRedirectMetadata, PagerResizeMetadata, PagerMetadata, FacetBaseMeta, FacetSortMeta, QueryErrorMeta, FacetStateMetadata, SmartSnippetFeedbackReason, SmartSnippetSuggestionMeta, SmartSnippetDocumentIdentifier, StaticFilterMetadata, StaticFilterToggleValueMetadata, UndoTriggerRedirectMetadata } from './searchPageEvents';
3
+ import { SearchPageEvents, OmniboxSuggestionsMetadata, FacetMetadata, FacetRangeMetadata, CategoryFacetMetadata, DocumentIdentifier, InterfaceChangeMetadata, ResultsSortMetadata, PartialDocumentInformation, TriggerNotifyMetadata, TriggerExecuteMetadata, TriggerRedirectMetadata, PagerResizeMetadata, PagerMetadata, FacetBaseMeta, FacetSortMeta, QueryErrorMeta, FacetStateMetadata, SmartSnippetFeedbackReason, SmartSnippetSuggestionMeta, SmartSnippetDocumentIdentifier, StaticFilterMetadata, StaticFilterToggleValueMetadata, UndoTriggerRedirectMetadata, SmartSnippetLinkMeta } from './searchPageEvents';
4
4
  export interface SearchPageClientProvider {
5
5
  getBaseMetadata: () => Record<string, any>;
6
6
  getSearchEventRequestPayload: () => Omit<SearchEventRequest, 'actionCause' | 'searchQueryUid'>;
@@ -85,6 +85,8 @@ export declare class CoveoSearchPageClient {
85
85
  logShowLessSmartSnippetSuggestion(snippet: SmartSnippetSuggestionMeta): Promise<void | import("../events").CustomEventResponse>;
86
86
  logOpenSmartSnippetSource(info: PartialDocumentInformation, identifier: DocumentIdentifier): Promise<void | import("../events").ClickEventResponse>;
87
87
  logOpenSmartSnippetSuggestionSource(info: PartialDocumentInformation, snippet: SmartSnippetSuggestionMeta): Promise<void | import("../events").ClickEventResponse>;
88
+ logOpenSmartSnippetInlineLink(info: PartialDocumentInformation, identifierAndLink: DocumentIdentifier & SmartSnippetLinkMeta): Promise<void | import("../events").ClickEventResponse>;
89
+ logOpenSmartSnippetSuggestionInlineLink(info: PartialDocumentInformation, snippetAndLink: SmartSnippetSuggestionMeta & SmartSnippetLinkMeta): Promise<void | import("../events").ClickEventResponse>;
88
90
  logRecentQueryClick(): Promise<void | import("../events").SearchEventResponse>;
89
91
  logClearRecentQueries(): Promise<void | import("../events").CustomEventResponse>;
90
92
  logRecentResultClick(info: PartialDocumentInformation, identifier: DocumentIdentifier): Promise<void | import("../events").CustomEventResponse>;
@@ -92,7 +94,7 @@ export declare class CoveoSearchPageClient {
92
94
  logNoResultsBack(): Promise<void | import("../events").SearchEventResponse>;
93
95
  logShowMoreFoldedResults(info: PartialDocumentInformation, identifier: DocumentIdentifier): Promise<void | import("../events").ClickEventResponse>;
94
96
  logShowLessFoldedResults(): Promise<void | import("../events").CustomEventResponse>;
95
- logCustomEvent(event: SearchPageEvents, metadata?: Record<string, any>): Promise<void | import("../events").CustomEventResponse>;
97
+ logCustomEvent(event: SearchPageEvents, metadata?: Record<string, any>, eventType?: string): Promise<void | import("../events").CustomEventResponse>;
96
98
  logCustomEventWithType(eventValue: string, eventType: string, metadata?: Record<string, any>): Promise<void | import("../events").CustomEventResponse>;
97
99
  logSearchEvent(event: SearchPageEvents, metadata?: Record<string, any>): Promise<void | import("../events").SearchEventResponse>;
98
100
  logClickEvent(event: SearchPageEvents, info: PartialDocumentInformation, identifier: DocumentIdentifier, metadata?: Record<string, any>): Promise<void | import("../events").ClickEventResponse>;
@@ -59,6 +59,8 @@ export declare enum SearchPageEvents {
59
59
  showLessSmartSnippetSuggestion = "showLessSmartSnippetSuggestion",
60
60
  openSmartSnippetSource = "openSmartSnippetSource",
61
61
  openSmartSnippetSuggestionSource = "openSmartSnippetSuggestionSource",
62
+ openSmartSnippetInlineLink = "openSmartSnippetInlineLink",
63
+ openSmartSnippetSuggestionInlineLink = "openSmartSnippetSuggestionInlineLink",
62
64
  recentQueryClick = "recentQueriesClick",
63
65
  clearRecentQueries = "clearRecentQueries",
64
66
  recentResultClick = "recentResultClick",
@@ -160,6 +162,10 @@ export interface SmartSnippetSuggestionMeta {
160
162
  answerSnippet: string;
161
163
  documentId: SmartSnippetDocumentIdentifier;
162
164
  }
165
+ export interface SmartSnippetLinkMeta {
166
+ linkText: string;
167
+ linkURL: string;
168
+ }
163
169
  export interface SmartSnippetDocumentIdentifier {
164
170
  contentIdKey: string;
165
171
  contentIdValue: string;
@@ -1149,6 +1149,8 @@ var SearchPageEvents;
1149
1149
  SearchPageEvents["showLessSmartSnippetSuggestion"] = "showLessSmartSnippetSuggestion";
1150
1150
  SearchPageEvents["openSmartSnippetSource"] = "openSmartSnippetSource";
1151
1151
  SearchPageEvents["openSmartSnippetSuggestionSource"] = "openSmartSnippetSuggestionSource";
1152
+ SearchPageEvents["openSmartSnippetInlineLink"] = "openSmartSnippetInlineLink";
1153
+ SearchPageEvents["openSmartSnippetSuggestionInlineLink"] = "openSmartSnippetSuggestionInlineLink";
1152
1154
  SearchPageEvents["recentQueryClick"] = "recentQueriesClick";
1153
1155
  SearchPageEvents["clearRecentQueries"] = "clearRecentQueries";
1154
1156
  SearchPageEvents["recentResultClick"] = "recentResultClick";
@@ -1356,7 +1358,7 @@ class CoveoSearchPageClient {
1356
1358
  }
1357
1359
  logTriggerQuery() {
1358
1360
  const meta = { query: this.provider.getSearchEventRequestPayload().queryText };
1359
- return this.logCustomEvent(SearchPageEvents.triggerQuery, meta);
1361
+ return this.logCustomEvent(SearchPageEvents.triggerQuery, meta, 'queryPipelineTriggers');
1360
1362
  }
1361
1363
  logUndoTriggerQuery(meta) {
1362
1364
  return this.logSearchEvent(SearchPageEvents.undoTriggerQuery, meta);
@@ -1470,6 +1472,15 @@ class CoveoSearchPageClient {
1470
1472
  logOpenSmartSnippetSuggestionSource(info, snippet) {
1471
1473
  return this.logClickEvent(SearchPageEvents.openSmartSnippetSuggestionSource, info, { contentIDKey: snippet.documentId.contentIdKey, contentIDValue: snippet.documentId.contentIdValue }, snippet);
1472
1474
  }
1475
+ logOpenSmartSnippetInlineLink(info, identifierAndLink) {
1476
+ return this.logClickEvent(SearchPageEvents.openSmartSnippetInlineLink, info, { contentIDKey: identifierAndLink.contentIDKey, contentIDValue: identifierAndLink.contentIDValue }, identifierAndLink);
1477
+ }
1478
+ logOpenSmartSnippetSuggestionInlineLink(info, snippetAndLink) {
1479
+ return this.logClickEvent(SearchPageEvents.openSmartSnippetSuggestionInlineLink, info, {
1480
+ contentIDKey: snippetAndLink.documentId.contentIdKey,
1481
+ contentIDValue: snippetAndLink.documentId.contentIdValue,
1482
+ }, snippetAndLink);
1483
+ }
1473
1484
  logRecentQueryClick() {
1474
1485
  return this.logSearchEvent(SearchPageEvents.recentQueryClick);
1475
1486
  }
@@ -1491,10 +1502,10 @@ class CoveoSearchPageClient {
1491
1502
  logShowLessFoldedResults() {
1492
1503
  return this.logCustomEvent(SearchPageEvents.showLessFoldedResults);
1493
1504
  }
1494
- logCustomEvent(event, metadata) {
1505
+ logCustomEvent(event, metadata, eventType = CustomEventsTypes[event]) {
1495
1506
  return __awaiter(this, void 0, void 0, function* () {
1496
1507
  const customData = Object.assign(Object.assign({}, this.provider.getBaseMetadata()), metadata);
1497
- const payload = Object.assign(Object.assign({}, (yield this.getBaseCustomEventRequest(customData))), { eventType: CustomEventsTypes[event], eventValue: event });
1508
+ const payload = Object.assign(Object.assign({}, (yield this.getBaseCustomEventRequest(customData))), { eventType, eventValue: event });
1498
1509
  return this.coveoAnalyticsClient.sendCustomEvent(payload);
1499
1510
  });
1500
1511
  }
package/dist/library.js CHANGED
@@ -83609,6 +83609,8 @@ var SearchPageEvents;
83609
83609
  SearchPageEvents["showLessSmartSnippetSuggestion"] = "showLessSmartSnippetSuggestion";
83610
83610
  SearchPageEvents["openSmartSnippetSource"] = "openSmartSnippetSource";
83611
83611
  SearchPageEvents["openSmartSnippetSuggestionSource"] = "openSmartSnippetSuggestionSource";
83612
+ SearchPageEvents["openSmartSnippetInlineLink"] = "openSmartSnippetInlineLink";
83613
+ SearchPageEvents["openSmartSnippetSuggestionInlineLink"] = "openSmartSnippetSuggestionInlineLink";
83612
83614
  SearchPageEvents["recentQueryClick"] = "recentQueriesClick";
83613
83615
  SearchPageEvents["clearRecentQueries"] = "clearRecentQueries";
83614
83616
  SearchPageEvents["recentResultClick"] = "recentResultClick";
@@ -83817,7 +83819,7 @@ var CoveoSearchPageClient = (function () {
83817
83819
  };
83818
83820
  CoveoSearchPageClient.prototype.logTriggerQuery = function () {
83819
83821
  var meta = { query: this.provider.getSearchEventRequestPayload().queryText };
83820
- return this.logCustomEvent(SearchPageEvents.triggerQuery, meta);
83822
+ return this.logCustomEvent(SearchPageEvents.triggerQuery, meta, 'queryPipelineTriggers');
83821
83823
  };
83822
83824
  CoveoSearchPageClient.prototype.logUndoTriggerQuery = function (meta) {
83823
83825
  return this.logSearchEvent(SearchPageEvents.undoTriggerQuery, meta);
@@ -83949,6 +83951,15 @@ var CoveoSearchPageClient = (function () {
83949
83951
  CoveoSearchPageClient.prototype.logOpenSmartSnippetSuggestionSource = function (info, snippet) {
83950
83952
  return this.logClickEvent(SearchPageEvents.openSmartSnippetSuggestionSource, info, { contentIDKey: snippet.documentId.contentIdKey, contentIDValue: snippet.documentId.contentIdValue }, snippet);
83951
83953
  };
83954
+ CoveoSearchPageClient.prototype.logOpenSmartSnippetInlineLink = function (info, identifierAndLink) {
83955
+ return this.logClickEvent(SearchPageEvents.openSmartSnippetInlineLink, info, { contentIDKey: identifierAndLink.contentIDKey, contentIDValue: identifierAndLink.contentIDValue }, identifierAndLink);
83956
+ };
83957
+ CoveoSearchPageClient.prototype.logOpenSmartSnippetSuggestionInlineLink = function (info, snippetAndLink) {
83958
+ return this.logClickEvent(SearchPageEvents.openSmartSnippetSuggestionInlineLink, info, {
83959
+ contentIDKey: snippetAndLink.documentId.contentIdKey,
83960
+ contentIDValue: snippetAndLink.documentId.contentIdValue,
83961
+ }, snippetAndLink);
83962
+ };
83952
83963
  CoveoSearchPageClient.prototype.logRecentQueryClick = function () {
83953
83964
  return this.logSearchEvent(SearchPageEvents.recentQueryClick);
83954
83965
  };
@@ -83970,7 +83981,8 @@ var CoveoSearchPageClient = (function () {
83970
83981
  CoveoSearchPageClient.prototype.logShowLessFoldedResults = function () {
83971
83982
  return this.logCustomEvent(SearchPageEvents.showLessFoldedResults);
83972
83983
  };
83973
- CoveoSearchPageClient.prototype.logCustomEvent = function (event, metadata) {
83984
+ CoveoSearchPageClient.prototype.logCustomEvent = function (event, metadata, eventType) {
83985
+ if (eventType === void 0) { eventType = CustomEventsTypes[event]; }
83974
83986
  return __awaiter(this, void 0, void 0, function () {
83975
83987
  var customData, payload, _a;
83976
83988
  return __generator(this, function (_b) {
@@ -83980,7 +83992,7 @@ var CoveoSearchPageClient = (function () {
83980
83992
  _a = [{}];
83981
83993
  return [4, this.getBaseCustomEventRequest(customData)];
83982
83994
  case 1:
83983
- payload = __assign.apply(void 0, [__assign.apply(void 0, _a.concat([(_b.sent())])), { eventType: CustomEventsTypes[event], eventValue: event }]);
83995
+ payload = __assign.apply(void 0, [__assign.apply(void 0, _a.concat([(_b.sent())])), { eventType: eventType, eventValue: event }]);
83984
83996
  return [2, this.coveoAnalyticsClient.sendCustomEvent(payload)];
83985
83997
  }
83986
83998
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coveo.analytics",
3
- "version": "2.20.21",
3
+ "version": "2.20.23",
4
4
  "description": "📈 Coveo analytics client (node and browser compatible) ",
5
5
  "main": "dist/library.js",
6
6
  "module": "dist/library.es.js",
@@ -135,12 +135,16 @@ describe('SearchPageClient', () => {
135
135
  });
136
136
  };
137
137
 
138
- const expectMatchCustomEventPayload = (actionCause: SearchPageEvents, meta = {}) => {
138
+ const expectMatchCustomEventPayload = (
139
+ actionCause: SearchPageEvents,
140
+ meta = {},
141
+ eventType = CustomEventsTypes[actionCause]
142
+ ) => {
139
143
  const [, {body}] = fetchMock.lastCall();
140
144
  const customData = {foo: 'bar', ...meta};
141
145
  expect(JSON.parse(body.toString())).toMatchObject({
142
146
  eventValue: actionCause,
143
- eventType: CustomEventsTypes[actionCause],
147
+ eventType,
144
148
  lastSearchQueryUid: 'my-uid',
145
149
  customData,
146
150
  language: 'en',
@@ -282,7 +286,7 @@ describe('SearchPageClient', () => {
282
286
  query: 'queryText',
283
287
  };
284
288
  await client.logTriggerQuery();
285
- expectMatchCustomEventPayload(SearchPageEvents.triggerQuery, meta);
289
+ expectMatchCustomEventPayload(SearchPageEvents.triggerQuery, meta, 'queryPipelineTriggers');
286
290
  });
287
291
 
288
292
  it('should send proper payload for #logUndoTriggerQuery', async () => {
@@ -633,6 +637,32 @@ describe('SearchPageClient', () => {
633
637
  });
634
638
  });
635
639
 
640
+ it('should send proper payload for #logOpenSmartSnippetInlineLink', async () => {
641
+ const meta = {
642
+ ...fakeDocID,
643
+ linkText: 'Some text',
644
+ linkURL: 'https://invalid.com',
645
+ };
646
+ await client.logOpenSmartSnippetInlineLink(fakeDocInfo, meta);
647
+ expectMatchDocumentPayload(SearchPageEvents.openSmartSnippetInlineLink, fakeDocInfo, meta);
648
+ });
649
+
650
+ it('should send proper payload for #logOpenSmartSnippetSuggestionInlineLink', async () => {
651
+ const meta = {
652
+ question: 'Abc',
653
+ answerSnippet: 'Def',
654
+ documentId: {contentIdKey: 'permanentid', contentIdValue: 'foo'},
655
+ linkText: 'Some text',
656
+ linkURL: 'https://invalid.com',
657
+ };
658
+ await client.logOpenSmartSnippetSuggestionInlineLink(fakeDocInfo, meta);
659
+ expectMatchDocumentPayload(SearchPageEvents.openSmartSnippetSuggestionInlineLink, fakeDocInfo, {
660
+ ...meta,
661
+ contentIDKey: meta.documentId.contentIdKey,
662
+ contentIDValue: meta.documentId.contentIdValue,
663
+ });
664
+ });
665
+
636
666
  it('should send proper payload for #logRecentQueryClick', async () => {
637
667
  await client.logRecentQueryClick();
638
668
  expectMatchPayload(SearchPageEvents.recentQueryClick);
@@ -26,6 +26,7 @@ import {
26
26
  StaticFilterMetadata,
27
27
  StaticFilterToggleValueMetadata,
28
28
  UndoTriggerRedirectMetadata,
29
+ SmartSnippetLinkMeta,
29
30
  } from './searchPageEvents';
30
31
  import {NoopAnalytics} from '../client/noopAnalytics';
31
32
  import {formatOmniboxMetadata} from '../formatting/format-omnibox-metadata';
@@ -168,7 +169,7 @@ export class CoveoSearchPageClient {
168
169
 
169
170
  public logTriggerQuery() {
170
171
  const meta = {query: this.provider.getSearchEventRequestPayload().queryText};
171
- return this.logCustomEvent(SearchPageEvents.triggerQuery, meta);
172
+ return this.logCustomEvent(SearchPageEvents.triggerQuery, meta, 'queryPipelineTriggers');
172
173
  }
173
174
 
174
175
  public logUndoTriggerQuery(meta: UndoTriggerRedirectMetadata) {
@@ -328,6 +329,33 @@ export class CoveoSearchPageClient {
328
329
  );
329
330
  }
330
331
 
332
+ public logOpenSmartSnippetInlineLink(
333
+ info: PartialDocumentInformation,
334
+ identifierAndLink: DocumentIdentifier & SmartSnippetLinkMeta
335
+ ) {
336
+ return this.logClickEvent(
337
+ SearchPageEvents.openSmartSnippetInlineLink,
338
+ info,
339
+ {contentIDKey: identifierAndLink.contentIDKey, contentIDValue: identifierAndLink.contentIDValue},
340
+ identifierAndLink
341
+ );
342
+ }
343
+
344
+ public logOpenSmartSnippetSuggestionInlineLink(
345
+ info: PartialDocumentInformation,
346
+ snippetAndLink: SmartSnippetSuggestionMeta & SmartSnippetLinkMeta
347
+ ) {
348
+ return this.logClickEvent(
349
+ SearchPageEvents.openSmartSnippetSuggestionInlineLink,
350
+ info,
351
+ {
352
+ contentIDKey: snippetAndLink.documentId.contentIdKey,
353
+ contentIDValue: snippetAndLink.documentId.contentIdValue,
354
+ },
355
+ snippetAndLink
356
+ );
357
+ }
358
+
331
359
  public logRecentQueryClick() {
332
360
  return this.logSearchEvent(SearchPageEvents.recentQueryClick);
333
361
  }
@@ -356,12 +384,16 @@ export class CoveoSearchPageClient {
356
384
  return this.logCustomEvent(SearchPageEvents.showLessFoldedResults);
357
385
  }
358
386
 
359
- public async logCustomEvent(event: SearchPageEvents, metadata?: Record<string, any>) {
387
+ public async logCustomEvent(
388
+ event: SearchPageEvents,
389
+ metadata?: Record<string, any>,
390
+ eventType: string = CustomEventsTypes[event]!
391
+ ) {
360
392
  const customData = {...this.provider.getBaseMetadata(), ...metadata};
361
393
 
362
394
  const payload: CustomEventRequest = {
363
395
  ...(await this.getBaseCustomEventRequest(customData)),
364
- eventType: CustomEventsTypes[event]!,
396
+ eventType,
365
397
  eventValue: event,
366
398
  };
367
399
 
@@ -238,6 +238,14 @@ export enum SearchPageEvents {
238
238
  * Identifies the custom event that gets logged when a user clicks on the source of a snippet suggestion for a related question.
239
239
  */
240
240
  openSmartSnippetSuggestionSource = 'openSmartSnippetSuggestionSource',
241
+ /**
242
+ * Identifies the custom event that gets logged when a user clicks on a link in the answer of a smart snippet.
243
+ */
244
+ openSmartSnippetInlineLink = 'openSmartSnippetInlineLink',
245
+ /**
246
+ * Identifies the custom event that gets logged when a user clicks on a link in the snippet suggestion for a related question.
247
+ */
248
+ openSmartSnippetSuggestionInlineLink = 'openSmartSnippetSuggestionInlineLink',
241
249
  /**
242
250
  * Identifies the search event that gets logged when a recent queries list item gets clicked.
243
251
  */
@@ -419,6 +427,11 @@ export interface SmartSnippetSuggestionMeta {
419
427
  documentId: SmartSnippetDocumentIdentifier;
420
428
  }
421
429
 
430
+ export interface SmartSnippetLinkMeta {
431
+ linkText: string;
432
+ linkURL: string;
433
+ }
434
+
422
435
  export interface SmartSnippetDocumentIdentifier {
423
436
  contentIdKey: string;
424
437
  contentIdValue: string;