coveo.analytics 2.19.9 → 2.19.12

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, StaticFilterMetadata, StaticFilterToggleValueMetadata } 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 } from './searchPageEvents';
4
4
  export interface SearchPageClientProvider {
5
5
  getBaseMetadata: () => Record<string, any>;
6
6
  getSearchEventRequestPayload: () => Omit<SearchEventRequest, 'actionCause' | 'searchQueryUid'>;
@@ -76,8 +76,10 @@ export declare class CoveoSearchPageClient {
76
76
  logOpenSmartSnippetFeedbackModal(): Promise<void | import("../events").CustomEventResponse>;
77
77
  logCloseSmartSnippetFeedbackModal(): Promise<void | import("../events").CustomEventResponse>;
78
78
  logSmartSnippetFeedbackReason(reason: SmartSnippetFeedbackReason, details?: string): Promise<void | import("../events").CustomEventResponse>;
79
- logExpandSmartSnippetSuggestion(documentId: SmartSnippetSuggestionMeta): Promise<void | import("../events").CustomEventResponse>;
80
- logCollapseSmartSnippetSuggestion(documentId: SmartSnippetSuggestionMeta): Promise<void | import("../events").CustomEventResponse>;
79
+ logExpandSmartSnippetSuggestion(snippet: SmartSnippetSuggestionMeta | SmartSnippetDocumentIdentifier): Promise<void | import("../events").CustomEventResponse>;
80
+ logCollapseSmartSnippetSuggestion(snippet: SmartSnippetSuggestionMeta | SmartSnippetDocumentIdentifier): Promise<void | import("../events").CustomEventResponse>;
81
+ logShowMoreSmartSnippetSuggestion(snippet: SmartSnippetSuggestionMeta): Promise<void | import("../events").CustomEventResponse>;
82
+ logShowLessSmartSnippetSuggestion(snippet: SmartSnippetSuggestionMeta): Promise<void | import("../events").CustomEventResponse>;
81
83
  logOpenSmartSnippetSource(info: PartialDocumentInformation, identifier: DocumentIdentifier): Promise<void | import("../events").ClickEventResponse>;
82
84
  logRecentQueryClick(): Promise<void | import("../events").SearchEventResponse>;
83
85
  logClearRecentQueries(): Promise<void | import("../events").CustomEventResponse>;
@@ -53,6 +53,8 @@ export declare enum SearchPageEvents {
53
53
  sendSmartSnippetReason = "sendSmartSnippetReason",
54
54
  expandSmartSnippetSuggestion = "expandSmartSnippetSuggestion",
55
55
  collapseSmartSnippetSuggestion = "collapseSmartSnippetSuggestion",
56
+ showMoreSmartSnippetSuggestion = "showMoreSmartSnippetSuggestion",
57
+ showLessSmartSnippetSuggestion = "showLessSmartSnippetSuggestion",
56
58
  openSmartSnippetSource = "openSmartSnippetSource",
57
59
  recentQueryClick = "recentQueriesClick",
58
60
  clearRecentQueries = "clearRecentQueries",
@@ -148,6 +150,11 @@ export interface QueryErrorMeta {
148
150
  }
149
151
  export declare type SmartSnippetFeedbackReason = 'does_not_answer' | 'partially_answers' | 'was_not_a_question' | 'other';
150
152
  export interface SmartSnippetSuggestionMeta {
153
+ question: string;
154
+ answerSnippet: string;
155
+ documentId: SmartSnippetDocumentIdentifier;
156
+ }
157
+ export interface SmartSnippetDocumentIdentifier {
151
158
  contentIdKey: string;
152
159
  contentIdValue: string;
153
160
  }
@@ -1111,6 +1111,8 @@ var SearchPageEvents;
1111
1111
  SearchPageEvents["sendSmartSnippetReason"] = "sendSmartSnippetReason";
1112
1112
  SearchPageEvents["expandSmartSnippetSuggestion"] = "expandSmartSnippetSuggestion";
1113
1113
  SearchPageEvents["collapseSmartSnippetSuggestion"] = "collapseSmartSnippetSuggestion";
1114
+ SearchPageEvents["showMoreSmartSnippetSuggestion"] = "showMoreSmartSnippetSuggestion";
1115
+ SearchPageEvents["showLessSmartSnippetSuggestion"] = "showLessSmartSnippetSuggestion";
1114
1116
  SearchPageEvents["openSmartSnippetSource"] = "openSmartSnippetSource";
1115
1117
  SearchPageEvents["recentQueryClick"] = "recentQueriesClick";
1116
1118
  SearchPageEvents["clearRecentQueries"] = "clearRecentQueries";
@@ -1147,6 +1149,8 @@ const CustomEventsTypes = {
1147
1149
  [SearchPageEvents.sendSmartSnippetReason]: 'smartSnippet',
1148
1150
  [SearchPageEvents.expandSmartSnippetSuggestion]: 'smartSnippetSuggestions',
1149
1151
  [SearchPageEvents.collapseSmartSnippetSuggestion]: 'smartSnippetSuggestions',
1152
+ [SearchPageEvents.showMoreSmartSnippetSuggestion]: 'smartSnippetSuggestions',
1153
+ [SearchPageEvents.showLessSmartSnippetSuggestion]: 'smartSnippetSuggestions',
1150
1154
  [SearchPageEvents.clearRecentQueries]: 'recentQueries',
1151
1155
  [SearchPageEvents.recentResultClick]: 'recentlyClickedDocuments',
1152
1156
  [SearchPageEvents.clearRecentResults]: 'recentlyClickedDocuments',
@@ -1409,11 +1413,17 @@ class CoveoSearchPageClient {
1409
1413
  logSmartSnippetFeedbackReason(reason, details) {
1410
1414
  return this.logCustomEvent(SearchPageEvents.sendSmartSnippetReason, { reason, details });
1411
1415
  }
1412
- logExpandSmartSnippetSuggestion(documentId) {
1413
- return this.logCustomEvent(SearchPageEvents.expandSmartSnippetSuggestion, { documentId });
1416
+ logExpandSmartSnippetSuggestion(snippet) {
1417
+ return this.logCustomEvent(SearchPageEvents.expandSmartSnippetSuggestion, 'documentId' in snippet ? snippet : { documentId: snippet });
1414
1418
  }
1415
- logCollapseSmartSnippetSuggestion(documentId) {
1416
- return this.logCustomEvent(SearchPageEvents.collapseSmartSnippetSuggestion, { documentId });
1419
+ logCollapseSmartSnippetSuggestion(snippet) {
1420
+ return this.logCustomEvent(SearchPageEvents.collapseSmartSnippetSuggestion, 'documentId' in snippet ? snippet : { documentId: snippet });
1421
+ }
1422
+ logShowMoreSmartSnippetSuggestion(snippet) {
1423
+ return this.logCustomEvent(SearchPageEvents.showMoreSmartSnippetSuggestion, snippet);
1424
+ }
1425
+ logShowLessSmartSnippetSuggestion(snippet) {
1426
+ return this.logCustomEvent(SearchPageEvents.showLessSmartSnippetSuggestion, snippet);
1417
1427
  }
1418
1428
  logOpenSmartSnippetSource(info, identifier) {
1419
1429
  return this.logClickEvent(SearchPageEvents.openSmartSnippetSource, info, identifier);
package/dist/library.js CHANGED
@@ -83553,6 +83553,8 @@ var SearchPageEvents;
83553
83553
  SearchPageEvents["sendSmartSnippetReason"] = "sendSmartSnippetReason";
83554
83554
  SearchPageEvents["expandSmartSnippetSuggestion"] = "expandSmartSnippetSuggestion";
83555
83555
  SearchPageEvents["collapseSmartSnippetSuggestion"] = "collapseSmartSnippetSuggestion";
83556
+ SearchPageEvents["showMoreSmartSnippetSuggestion"] = "showMoreSmartSnippetSuggestion";
83557
+ SearchPageEvents["showLessSmartSnippetSuggestion"] = "showLessSmartSnippetSuggestion";
83556
83558
  SearchPageEvents["openSmartSnippetSource"] = "openSmartSnippetSource";
83557
83559
  SearchPageEvents["recentQueryClick"] = "recentQueriesClick";
83558
83560
  SearchPageEvents["clearRecentQueries"] = "clearRecentQueries";
@@ -83589,6 +83591,8 @@ var CustomEventsTypes = (_a = {},
83589
83591
  _a[SearchPageEvents.sendSmartSnippetReason] = 'smartSnippet',
83590
83592
  _a[SearchPageEvents.expandSmartSnippetSuggestion] = 'smartSnippetSuggestions',
83591
83593
  _a[SearchPageEvents.collapseSmartSnippetSuggestion] = 'smartSnippetSuggestions',
83594
+ _a[SearchPageEvents.showMoreSmartSnippetSuggestion] = 'smartSnippetSuggestions',
83595
+ _a[SearchPageEvents.showLessSmartSnippetSuggestion] = 'smartSnippetSuggestions',
83592
83596
  _a[SearchPageEvents.clearRecentQueries] = 'recentQueries',
83593
83597
  _a[SearchPageEvents.recentResultClick] = 'recentlyClickedDocuments',
83594
83598
  _a[SearchPageEvents.clearRecentResults] = 'recentlyClickedDocuments',
@@ -83870,11 +83874,17 @@ var CoveoSearchPageClient = (function () {
83870
83874
  CoveoSearchPageClient.prototype.logSmartSnippetFeedbackReason = function (reason, details) {
83871
83875
  return this.logCustomEvent(SearchPageEvents.sendSmartSnippetReason, { reason: reason, details: details });
83872
83876
  };
83873
- CoveoSearchPageClient.prototype.logExpandSmartSnippetSuggestion = function (documentId) {
83874
- return this.logCustomEvent(SearchPageEvents.expandSmartSnippetSuggestion, { documentId: documentId });
83877
+ CoveoSearchPageClient.prototype.logExpandSmartSnippetSuggestion = function (snippet) {
83878
+ return this.logCustomEvent(SearchPageEvents.expandSmartSnippetSuggestion, 'documentId' in snippet ? snippet : { documentId: snippet });
83875
83879
  };
83876
- CoveoSearchPageClient.prototype.logCollapseSmartSnippetSuggestion = function (documentId) {
83877
- return this.logCustomEvent(SearchPageEvents.collapseSmartSnippetSuggestion, { documentId: documentId });
83880
+ CoveoSearchPageClient.prototype.logCollapseSmartSnippetSuggestion = function (snippet) {
83881
+ return this.logCustomEvent(SearchPageEvents.collapseSmartSnippetSuggestion, 'documentId' in snippet ? snippet : { documentId: snippet });
83882
+ };
83883
+ CoveoSearchPageClient.prototype.logShowMoreSmartSnippetSuggestion = function (snippet) {
83884
+ return this.logCustomEvent(SearchPageEvents.showMoreSmartSnippetSuggestion, snippet);
83885
+ };
83886
+ CoveoSearchPageClient.prototype.logShowLessSmartSnippetSuggestion = function (snippet) {
83887
+ return this.logCustomEvent(SearchPageEvents.showLessSmartSnippetSuggestion, snippet);
83878
83888
  };
83879
83889
  CoveoSearchPageClient.prototype.logOpenSmartSnippetSource = function (info, identifier) {
83880
83890
  return this.logClickEvent(SearchPageEvents.openSmartSnippetSource, info, identifier);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coveo.analytics",
3
- "version": "2.19.9",
3
+ "version": "2.19.12",
4
4
  "description": "📈 Coveo analytics client (node and browser compatible) ",
5
5
  "main": "dist/library.js",
6
6
  "module": "dist/library.es.js",
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "license": "MIT",
25
25
  "dependencies": {
26
- "@react-native-async-storage/async-storage": "^1.16.1",
26
+ "@react-native-async-storage/async-storage": "^1.17.3",
27
27
  "cross-fetch": "^3.1.5"
28
28
  },
29
29
  "devDependencies": {
@@ -524,19 +524,71 @@ describe('SearchPageClient', () => {
524
524
  });
525
525
 
526
526
  it('should send proper payload for #logExpandSmartSnippetSuggestion', async () => {
527
- await client.logExpandSmartSnippetSuggestion({contentIdKey: 'permanentid', contentIdValue: 'foo'});
527
+ await client.logExpandSmartSnippetSuggestion({
528
+ question: 'Abc',
529
+ answerSnippet: 'Def',
530
+ documentId: {contentIdKey: 'permanentid', contentIdValue: 'foo'},
531
+ });
528
532
  expectMatchCustomEventPayload(SearchPageEvents.expandSmartSnippetSuggestion, {
533
+ question: 'Abc',
534
+ answerSnippet: 'Def',
529
535
  documentId: {contentIdKey: 'permanentid', contentIdValue: 'foo'},
530
536
  });
531
537
  });
532
538
 
533
539
  it('should send proper payload for #logCollapseSmartSnippetSuggestion', async () => {
540
+ await client.logCollapseSmartSnippetSuggestion({
541
+ question: 'Abc',
542
+ answerSnippet: 'Def',
543
+ documentId: {contentIdKey: 'permanentid', contentIdValue: 'foo'},
544
+ });
545
+ expectMatchCustomEventPayload(SearchPageEvents.collapseSmartSnippetSuggestion, {
546
+ question: 'Abc',
547
+ answerSnippet: 'Def',
548
+ documentId: {contentIdKey: 'permanentid', contentIdValue: 'foo'},
549
+ });
550
+ });
551
+
552
+ it('should send proper payload for #logExpandSmartSnippetSuggestion when called with only the documentId', async () => {
553
+ await client.logExpandSmartSnippetSuggestion({contentIdKey: 'permanentid', contentIdValue: 'foo'});
554
+ expectMatchCustomEventPayload(SearchPageEvents.expandSmartSnippetSuggestion, {
555
+ documentId: {contentIdKey: 'permanentid', contentIdValue: 'foo'},
556
+ });
557
+ });
558
+
559
+ it('should send proper payload for #logCollapseSmartSnippetSuggestion when called with only the documentId', async () => {
534
560
  await client.logCollapseSmartSnippetSuggestion({contentIdKey: 'permanentid', contentIdValue: 'foo'});
535
561
  expectMatchCustomEventPayload(SearchPageEvents.collapseSmartSnippetSuggestion, {
536
562
  documentId: {contentIdKey: 'permanentid', contentIdValue: 'foo'},
537
563
  });
538
564
  });
539
565
 
566
+ it('should send proper payload for #logShowMoreSmartSnippetSuggestion', async () => {
567
+ await client.logShowMoreSmartSnippetSuggestion({
568
+ question: 'Abc',
569
+ answerSnippet: 'Def',
570
+ documentId: {contentIdKey: 'permanentid', contentIdValue: 'foo'},
571
+ });
572
+ expectMatchCustomEventPayload(SearchPageEvents.showMoreSmartSnippetSuggestion, {
573
+ question: 'Abc',
574
+ answerSnippet: 'Def',
575
+ documentId: {contentIdKey: 'permanentid', contentIdValue: 'foo'},
576
+ });
577
+ });
578
+
579
+ it('should send proper payload for #logShowLessSmartSnippetSuggestion', async () => {
580
+ await client.logShowLessSmartSnippetSuggestion({
581
+ question: 'Abc',
582
+ answerSnippet: 'Def',
583
+ documentId: {contentIdKey: 'permanentid', contentIdValue: 'foo'},
584
+ });
585
+ expectMatchCustomEventPayload(SearchPageEvents.showLessSmartSnippetSuggestion, {
586
+ question: 'Abc',
587
+ answerSnippet: 'Def',
588
+ documentId: {contentIdKey: 'permanentid', contentIdValue: 'foo'},
589
+ });
590
+ });
591
+
540
592
  it('should send proper payload for #logOpenSmartSnippetSource', async () => {
541
593
  await client.logOpenSmartSnippetSource(fakeDocInfo, fakeDocID);
542
594
  expectMatchDocumentPayload(SearchPageEvents.openSmartSnippetSource, fakeDocInfo, fakeDocID);
@@ -22,6 +22,7 @@ import {
22
22
  FacetStateMetadata,
23
23
  SmartSnippetFeedbackReason,
24
24
  SmartSnippetSuggestionMeta,
25
+ SmartSnippetDocumentIdentifier,
25
26
  StaticFilterMetadata,
26
27
  StaticFilterToggleValueMetadata,
27
28
  } from './searchPageEvents';
@@ -278,12 +279,26 @@ export class CoveoSearchPageClient {
278
279
  return this.logCustomEvent(SearchPageEvents.sendSmartSnippetReason, {reason, details});
279
280
  }
280
281
 
281
- public logExpandSmartSnippetSuggestion(documentId: SmartSnippetSuggestionMeta) {
282
- return this.logCustomEvent(SearchPageEvents.expandSmartSnippetSuggestion, {documentId});
282
+ public logExpandSmartSnippetSuggestion(snippet: SmartSnippetSuggestionMeta | SmartSnippetDocumentIdentifier) {
283
+ return this.logCustomEvent(
284
+ SearchPageEvents.expandSmartSnippetSuggestion,
285
+ 'documentId' in snippet ? snippet : {documentId: snippet}
286
+ );
283
287
  }
284
288
 
285
- public logCollapseSmartSnippetSuggestion(documentId: SmartSnippetSuggestionMeta) {
286
- return this.logCustomEvent(SearchPageEvents.collapseSmartSnippetSuggestion, {documentId});
289
+ public logCollapseSmartSnippetSuggestion(snippet: SmartSnippetSuggestionMeta | SmartSnippetDocumentIdentifier) {
290
+ return this.logCustomEvent(
291
+ SearchPageEvents.collapseSmartSnippetSuggestion,
292
+ 'documentId' in snippet ? snippet : {documentId: snippet}
293
+ );
294
+ }
295
+
296
+ public logShowMoreSmartSnippetSuggestion(snippet: SmartSnippetSuggestionMeta) {
297
+ return this.logCustomEvent(SearchPageEvents.showMoreSmartSnippetSuggestion, snippet);
298
+ }
299
+
300
+ public logShowLessSmartSnippetSuggestion(snippet: SmartSnippetSuggestionMeta) {
301
+ return this.logCustomEvent(SearchPageEvents.showLessSmartSnippetSuggestion, snippet);
287
302
  }
288
303
 
289
304
  public logOpenSmartSnippetSource(info: PartialDocumentInformation, identifier: DocumentIdentifier) {
@@ -213,6 +213,14 @@ export enum SearchPageEvents {
213
213
  * Identifies the custom event that gets logged when a snippet suggestion for a related question is collapsed.
214
214
  */
215
215
  collapseSmartSnippetSuggestion = 'collapseSmartSnippetSuggestion',
216
+ /**
217
+ * Identifies the custom event that gets logged when the user presses "show more" on a snippet suggestion for a related question.
218
+ */
219
+ showMoreSmartSnippetSuggestion = 'showMoreSmartSnippetSuggestion',
220
+ /**
221
+ * Identifies the custom event that gets logged when the user presses "show less" on a snippet suggestion for a related question.
222
+ */
223
+ showLessSmartSnippetSuggestion = 'showLessSmartSnippetSuggestion',
216
224
  /**
217
225
  * Identifies the custom event that gets logged when a user clicks on the source of an answer in a smart snippet.
218
226
  */
@@ -274,6 +282,8 @@ export const CustomEventsTypes: Partial<Record<SearchPageEvents, string>> = {
274
282
  [SearchPageEvents.sendSmartSnippetReason]: 'smartSnippet',
275
283
  [SearchPageEvents.expandSmartSnippetSuggestion]: 'smartSnippetSuggestions',
276
284
  [SearchPageEvents.collapseSmartSnippetSuggestion]: 'smartSnippetSuggestions',
285
+ [SearchPageEvents.showMoreSmartSnippetSuggestion]: 'smartSnippetSuggestions',
286
+ [SearchPageEvents.showLessSmartSnippetSuggestion]: 'smartSnippetSuggestions',
277
287
  [SearchPageEvents.clearRecentQueries]: 'recentQueries',
278
288
  [SearchPageEvents.recentResultClick]: 'recentlyClickedDocuments',
279
289
  [SearchPageEvents.clearRecentResults]: 'recentlyClickedDocuments',
@@ -386,6 +396,12 @@ export interface QueryErrorMeta {
386
396
  export type SmartSnippetFeedbackReason = 'does_not_answer' | 'partially_answers' | 'was_not_a_question' | 'other';
387
397
 
388
398
  export interface SmartSnippetSuggestionMeta {
399
+ question: string;
400
+ answerSnippet: string;
401
+ documentId: SmartSnippetDocumentIdentifier;
402
+ }
403
+
404
+ export interface SmartSnippetDocumentIdentifier {
389
405
  contentIdKey: string;
390
406
  contentIdValue: string;
391
407
  }