coveo.analytics 2.19.8 → 2.19.11

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,8 @@ 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
81
  logOpenSmartSnippetSource(info: PartialDocumentInformation, identifier: DocumentIdentifier): Promise<void | import("../events").ClickEventResponse>;
82
82
  logRecentQueryClick(): Promise<void | import("../events").SearchEventResponse>;
83
83
  logClearRecentQueries(): Promise<void | import("../events").CustomEventResponse>;
@@ -148,6 +148,11 @@ export interface QueryErrorMeta {
148
148
  }
149
149
  export declare type SmartSnippetFeedbackReason = 'does_not_answer' | 'partially_answers' | 'was_not_a_question' | 'other';
150
150
  export interface SmartSnippetSuggestionMeta {
151
+ question: string;
152
+ answerSnippet: string;
153
+ documentId: SmartSnippetDocumentIdentifier;
154
+ }
155
+ export interface SmartSnippetDocumentIdentifier {
151
156
  contentIdKey: string;
152
157
  contentIdValue: string;
153
158
  }
@@ -1409,11 +1409,11 @@ class CoveoSearchPageClient {
1409
1409
  logSmartSnippetFeedbackReason(reason, details) {
1410
1410
  return this.logCustomEvent(SearchPageEvents.sendSmartSnippetReason, { reason, details });
1411
1411
  }
1412
- logExpandSmartSnippetSuggestion(documentId) {
1413
- return this.logCustomEvent(SearchPageEvents.expandSmartSnippetSuggestion, { documentId });
1412
+ logExpandSmartSnippetSuggestion(snippet) {
1413
+ return this.logCustomEvent(SearchPageEvents.expandSmartSnippetSuggestion, 'documentId' in snippet ? snippet : { documentId: snippet });
1414
1414
  }
1415
- logCollapseSmartSnippetSuggestion(documentId) {
1416
- return this.logCustomEvent(SearchPageEvents.collapseSmartSnippetSuggestion, { documentId });
1415
+ logCollapseSmartSnippetSuggestion(snippet) {
1416
+ return this.logCustomEvent(SearchPageEvents.collapseSmartSnippetSuggestion, 'documentId' in snippet ? snippet : { documentId: snippet });
1417
1417
  }
1418
1418
  logOpenSmartSnippetSource(info, identifier) {
1419
1419
  return this.logClickEvent(SearchPageEvents.openSmartSnippetSource, info, identifier);
package/dist/library.js CHANGED
@@ -83870,11 +83870,11 @@ var CoveoSearchPageClient = (function () {
83870
83870
  CoveoSearchPageClient.prototype.logSmartSnippetFeedbackReason = function (reason, details) {
83871
83871
  return this.logCustomEvent(SearchPageEvents.sendSmartSnippetReason, { reason: reason, details: details });
83872
83872
  };
83873
- CoveoSearchPageClient.prototype.logExpandSmartSnippetSuggestion = function (documentId) {
83874
- return this.logCustomEvent(SearchPageEvents.expandSmartSnippetSuggestion, { documentId: documentId });
83873
+ CoveoSearchPageClient.prototype.logExpandSmartSnippetSuggestion = function (snippet) {
83874
+ return this.logCustomEvent(SearchPageEvents.expandSmartSnippetSuggestion, 'documentId' in snippet ? snippet : { documentId: snippet });
83875
83875
  };
83876
- CoveoSearchPageClient.prototype.logCollapseSmartSnippetSuggestion = function (documentId) {
83877
- return this.logCustomEvent(SearchPageEvents.collapseSmartSnippetSuggestion, { documentId: documentId });
83876
+ CoveoSearchPageClient.prototype.logCollapseSmartSnippetSuggestion = function (snippet) {
83877
+ return this.logCustomEvent(SearchPageEvents.collapseSmartSnippetSuggestion, 'documentId' in snippet ? snippet : { documentId: snippet });
83878
83878
  };
83879
83879
  CoveoSearchPageClient.prototype.logOpenSmartSnippetSource = function (info, identifier) {
83880
83880
  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.8",
3
+ "version": "2.19.11",
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.15.17",
26
+ "@react-native-async-storage/async-storage": "^1.17.3",
27
27
  "cross-fetch": "^3.1.5"
28
28
  },
29
29
  "devDependencies": {
@@ -524,13 +524,39 @@ 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'},
@@ -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,18 @@ 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
+ );
287
294
  }
288
295
 
289
296
  public logOpenSmartSnippetSource(info: PartialDocumentInformation, identifier: DocumentIdentifier) {
@@ -386,6 +386,12 @@ export interface QueryErrorMeta {
386
386
  export type SmartSnippetFeedbackReason = 'does_not_answer' | 'partially_answers' | 'was_not_a_question' | 'other';
387
387
 
388
388
  export interface SmartSnippetSuggestionMeta {
389
+ question: string;
390
+ answerSnippet: string;
391
+ documentId: SmartSnippetDocumentIdentifier;
392
+ }
393
+
394
+ export interface SmartSnippetDocumentIdentifier {
389
395
  contentIdKey: string;
390
396
  contentIdValue: string;
391
397
  }