coveo.analytics 2.20.9 → 2.20.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.
@@ -68,6 +68,7 @@ export declare class CoveoAnalyticsClient implements AnalyticsClient, VisitorIdP
68
68
  private deferExecution;
69
69
  private sendFromBufferWithFetch;
70
70
  clear(): void;
71
+ deleteHttpOnlyVisitorId(): void;
71
72
  sendSearchEvent(request: SearchEventRequest): Promise<SearchEventResponse | void>;
72
73
  sendClickEvent(request: ClickEventRequest): Promise<ClickEventResponse | void>;
73
74
  sendCustomEvent(request: CustomEventRequest): Promise<CustomEventResponse | void>;
@@ -4,6 +4,7 @@ export declare class AnalyticsBeaconClient implements AnalyticsRequestClient {
4
4
  private opts;
5
5
  constructor(opts: IAnalyticsClientOptions);
6
6
  sendEvent(eventType: EventType, payload: IRequestPayload): Promise<void>;
7
+ deleteHttpCookieVisitorId(): Promise<void>;
7
8
  private encodeForEventType;
8
9
  private getQueryParamsForEventType;
9
10
  private isEventTypeLegacy;
@@ -4,6 +4,7 @@ export declare class AnalyticsFetchClient implements AnalyticsRequestClient {
4
4
  private opts;
5
5
  constructor(opts: IAnalyticsClientOptions);
6
6
  sendEvent(eventType: EventType, payload: IRequestPayload): Promise<AnyEventResponse>;
7
+ deleteHttpCookieVisitorId(): Promise<void>;
7
8
  private shouldAppendVisitorId;
8
9
  private getVisitorIdParam;
9
10
  private getHeaders;
@@ -5,6 +5,7 @@ export interface VisitorIdProvider {
5
5
  }
6
6
  export interface AnalyticsRequestClient {
7
7
  sendEvent(eventType: string, payload: IRequestPayload): Promise<AnyEventResponse | void>;
8
+ deleteHttpCookieVisitorId: () => Promise<void>;
8
9
  }
9
10
  export interface IAnalyticsClientOptions {
10
11
  baseUrl: string;
@@ -19,4 +20,5 @@ export interface IAnalyticsRequestOptions extends RequestInit {
19
20
  }
20
21
  export declare class NoopAnalyticsClient implements AnalyticsRequestClient {
21
22
  sendEvent(_: EventType, __: IRequestPayload): Promise<void>;
23
+ deleteHttpCookieVisitorId(): Promise<void>;
22
24
  }
@@ -1,6 +1,6 @@
1
1
  import { AnalyticsClient, ClientOptions } from '../client/analytics';
2
2
  import { SearchEventRequest } from '../events';
3
- import { FacetBaseMeta, FacetMetadata, FacetSortMeta, FacetStateMetadata, PagerMetadata, InterfaceChangeMetadata, QueryErrorMeta, SearchPageEvents, ResultsSortMetadata, FacetRangeMetadata, CategoryFacetMetadata } from '../searchPage/searchPageEvents';
3
+ import { FacetBaseMeta, FacetMetadata, FacetSortMeta, FacetStateMetadata, PagerMetadata, InterfaceChangeMetadata, QueryErrorMeta, SearchPageEvents, ResultsSortMetadata, FacetRangeMetadata, CategoryFacetMetadata, StaticFilterToggleValueMetadata } from '../searchPage/searchPageEvents';
4
4
  export interface InsightClientProvider {
5
5
  getSearchEventRequestPayload: () => Omit<SearchEventRequest, 'actionCause' | 'searchQueryUid'>;
6
6
  getSearchUID: () => string;
@@ -26,6 +26,7 @@ export declare class CoveoInsightClient {
26
26
  enable(): void;
27
27
  logInterfaceLoad(): Promise<void | import("../events").SearchEventResponse>;
28
28
  logInterfaceChange(metadata: InterfaceChangeMetadata): Promise<void | import("../events").SearchEventResponse>;
29
+ logStaticFilterDeselect(meta: StaticFilterToggleValueMetadata): Promise<void | import("../events").SearchEventResponse>;
29
30
  logFetchMoreResults(): Promise<void | import("../events").CustomEventResponse>;
30
31
  logBreadcrumbFacet(metadata: FacetMetadata | FacetRangeMetadata | CategoryFacetMetadata): Promise<void | import("../events").SearchEventResponse>;
31
32
  logBreadcrumbResetAll(): Promise<void | import("../events").SearchEventResponse>;
@@ -594,6 +594,9 @@ class AnalyticsBeaconClient {
594
594
  return;
595
595
  });
596
596
  }
597
+ deleteHttpCookieVisitorId() {
598
+ return Promise.resolve();
599
+ }
597
600
  encodeForEventType(eventType, payload) {
598
601
  return this.isEventTypeLegacy(eventType)
599
602
  ? this.encodeForLegacyType(eventType, payload)
@@ -637,6 +640,11 @@ class NoopAnalyticsClient {
637
640
  return Promise.resolve();
638
641
  });
639
642
  }
643
+ deleteHttpCookieVisitorId() {
644
+ return __awaiter(this, void 0, void 0, function* () {
645
+ return Promise.resolve();
646
+ });
647
+ }
640
648
  }
641
649
 
642
650
  const fetch$1 = window.fetch;
@@ -677,6 +685,13 @@ class AnalyticsFetchClient {
677
685
  }
678
686
  });
679
687
  }
688
+ deleteHttpCookieVisitorId() {
689
+ return __awaiter(this, void 0, void 0, function* () {
690
+ const { baseUrl } = this.opts;
691
+ const url = `${baseUrl}/analytics/visit`;
692
+ yield fetch$1(url, { headers: this.getHeaders(), method: 'DELETE' });
693
+ });
694
+ }
680
695
  shouldAppendVisitorId(eventType) {
681
696
  return [EventType.click, EventType.custom, EventType.search, EventType.view].indexOf(eventType) !== -1;
682
697
  }
@@ -938,6 +953,9 @@ class CoveoAnalyticsClient {
938
953
  const store = new HistoryStore();
939
954
  store.clear();
940
955
  }
956
+ deleteHttpOnlyVisitorId() {
957
+ this.runtime.client.deleteHttpCookieVisitorId();
958
+ }
941
959
  sendSearchEvent(request) {
942
960
  return __awaiter(this, void 0, void 0, function* () {
943
961
  return this.sendEvent(EventType.search, request);
@@ -1792,6 +1810,9 @@ class CoveoInsightClient {
1792
1810
  logInterfaceChange(metadata) {
1793
1811
  return this.logSearchEvent(SearchPageEvents.interfaceChange, metadata);
1794
1812
  }
1813
+ logStaticFilterDeselect(meta) {
1814
+ return this.logSearchEvent(SearchPageEvents.staticFilterDeselect, meta);
1815
+ }
1795
1816
  logFetchMoreResults() {
1796
1817
  return this.logCustomEvent(SearchPageEvents.pagerScrolling, { type: 'getMoreResults' });
1797
1818
  }
package/dist/library.js CHANGED
@@ -792,6 +792,9 @@ var AnalyticsBeaconClient = (function () {
792
792
  });
793
793
  });
794
794
  };
795
+ AnalyticsBeaconClient.prototype.deleteHttpCookieVisitorId = function () {
796
+ return Promise.resolve();
797
+ };
795
798
  AnalyticsBeaconClient.prototype.encodeForEventType = function (eventType, payload) {
796
799
  return this.isEventTypeLegacy(eventType)
797
800
  ? this.encodeForLegacyType(eventType, payload)
@@ -849,6 +852,13 @@ var NoopAnalyticsClient = (function () {
849
852
  });
850
853
  });
851
854
  };
855
+ NoopAnalyticsClient.prototype.deleteHttpCookieVisitorId = function () {
856
+ return __awaiter(this, void 0, void 0, function () {
857
+ return __generator(this, function (_a) {
858
+ return [2, Promise.resolve()];
859
+ });
860
+ });
861
+ };
852
862
  return NoopAnalyticsClient;
853
863
  }());
854
864
 
@@ -82413,6 +82423,22 @@ var AnalyticsFetchClient = (function () {
82413
82423
  });
82414
82424
  });
82415
82425
  };
82426
+ AnalyticsFetchClient.prototype.deleteHttpCookieVisitorId = function () {
82427
+ return __awaiter(this, void 0, void 0, function () {
82428
+ var baseUrl, url;
82429
+ return __generator(this, function (_a) {
82430
+ switch (_a.label) {
82431
+ case 0:
82432
+ baseUrl = this.opts.baseUrl;
82433
+ url = baseUrl + "/analytics/visit";
82434
+ return [4, nodePonyfill.exports.fetch(url, { headers: this.getHeaders(), method: 'DELETE' })];
82435
+ case 1:
82436
+ _a.sent();
82437
+ return [2];
82438
+ }
82439
+ });
82440
+ });
82441
+ };
82416
82442
  AnalyticsFetchClient.prototype.shouldAppendVisitorId = function (eventType) {
82417
82443
  return [EventType.click, EventType.custom, EventType.search, EventType.view].indexOf(eventType) !== -1;
82418
82444
  };
@@ -82841,6 +82867,9 @@ var CoveoAnalyticsClient = (function () {
82841
82867
  var store = new HistoryStore();
82842
82868
  store.clear();
82843
82869
  };
82870
+ CoveoAnalyticsClient.prototype.deleteHttpOnlyVisitorId = function () {
82871
+ this.runtime.client.deleteHttpCookieVisitorId();
82872
+ };
82844
82873
  CoveoAnalyticsClient.prototype.sendSearchEvent = function (request) {
82845
82874
  return __awaiter(this, void 0, void 0, function () {
82846
82875
  return __generator(this, function (_a) {
@@ -84173,6 +84202,9 @@ var CoveoInsightClient = (function () {
84173
84202
  CoveoInsightClient.prototype.logInterfaceChange = function (metadata) {
84174
84203
  return this.logSearchEvent(SearchPageEvents.interfaceChange, metadata);
84175
84204
  };
84205
+ CoveoInsightClient.prototype.logStaticFilterDeselect = function (meta) {
84206
+ return this.logSearchEvent(SearchPageEvents.staticFilterDeselect, meta);
84207
+ };
84176
84208
  CoveoInsightClient.prototype.logFetchMoreResults = function () {
84177
84209
  return this.logCustomEvent(SearchPageEvents.pagerScrolling, { type: 'getMoreResults' });
84178
84210
  };
@@ -83,6 +83,13 @@ class AnalyticsFetchClient {
83
83
  }
84
84
  });
85
85
  }
86
+ deleteHttpCookieVisitorId() {
87
+ return __awaiter(this, void 0, void 0, function* () {
88
+ const { baseUrl } = this.opts;
89
+ const url = `${baseUrl}/analytics/visit`;
90
+ yield fetch(url, { headers: this.getHeaders(), method: 'DELETE' });
91
+ });
92
+ }
86
93
  shouldAppendVisitorId(eventType) {
87
94
  return [EventType.click, EventType.custom, EventType.search, EventType.view].indexOf(eventType) !== -1;
88
95
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coveo.analytics",
3
- "version": "2.20.9",
3
+ "version": "2.20.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.17.6",
26
+ "@react-native-async-storage/async-storage": "^1.17.7",
27
27
  "cross-fetch": "^3.1.5"
28
28
  },
29
29
  "devDependencies": {
@@ -303,6 +303,10 @@ export class CoveoAnalyticsClient implements AnalyticsClient, VisitorIdProvider
303
303
  store.clear();
304
304
  }
305
305
 
306
+ public deleteHttpOnlyVisitorId() {
307
+ this.runtime.client.deleteHttpCookieVisitorId();
308
+ }
309
+
306
310
  async sendSearchEvent(request: SearchEventRequest): Promise<SearchEventResponse | void> {
307
311
  return this.sendEvent(EventType.search, request);
308
312
  }
@@ -31,6 +31,10 @@ export class AnalyticsBeaconClient implements AnalyticsRequestClient {
31
31
  return;
32
32
  }
33
33
 
34
+ public deleteHttpCookieVisitorId() {
35
+ return Promise.resolve();
36
+ }
37
+
34
38
  private encodeForEventType(eventType: EventType, payload: IRequestPayload): string {
35
39
  return this.isEventTypeLegacy(eventType)
36
40
  ? this.encodeForLegacyType(eventType, payload)
@@ -44,6 +44,12 @@ export class AnalyticsFetchClient implements AnalyticsRequestClient {
44
44
  }
45
45
  }
46
46
 
47
+ public async deleteHttpCookieVisitorId() {
48
+ const {baseUrl} = this.opts;
49
+ const url = `${baseUrl}/analytics/visit`;
50
+ await fetch(url, {headers: this.getHeaders(), method: 'DELETE'});
51
+ }
52
+
47
53
  private shouldAppendVisitorId(eventType: EventType) {
48
54
  return [EventType.click, EventType.custom, EventType.search, EventType.view].indexOf(eventType) !== -1;
49
55
  }
@@ -7,6 +7,7 @@ export interface VisitorIdProvider {
7
7
 
8
8
  export interface AnalyticsRequestClient {
9
9
  sendEvent(eventType: string, payload: IRequestPayload): Promise<AnyEventResponse | void>;
10
+ deleteHttpCookieVisitorId: () => Promise<void>;
10
11
  }
11
12
 
12
13
  export interface IAnalyticsClientOptions {
@@ -31,4 +32,8 @@ export class NoopAnalyticsClient implements AnalyticsRequestClient {
31
32
  public async sendEvent(_: EventType, __: IRequestPayload): Promise<void> {
32
33
  return Promise.resolve();
33
34
  }
35
+
36
+ public async deleteHttpCookieVisitorId() {
37
+ return Promise.resolve();
38
+ }
34
39
  }
@@ -1,7 +1,7 @@
1
1
  import {mockFetch} from '../../tests/fetchMock';
2
2
  import CoveoAnalyticsClient from '../client/analytics';
3
3
  import {NoopAnalytics} from '../client/noopAnalytics';
4
- import {CustomEventsTypes, SearchPageEvents} from '../searchPage/searchPageEvents';
4
+ import {CustomEventsTypes, SearchPageEvents, StaticFilterToggleValueMetadata} from '../searchPage/searchPageEvents';
5
5
  import {CoveoInsightClient, InsightClientProvider} from './insightClient';
6
6
  import doNotTrack from '../donottrack';
7
7
 
@@ -119,6 +119,35 @@ describe('InsightClient', () => {
119
119
  expectMatchCustomEventPayload(SearchPageEvents.pagerScrolling, {type: 'getMoreResults'});
120
120
  });
121
121
 
122
+ it('should send proper payload for #staticFilterDeselect', async () => {
123
+ const meta: StaticFilterToggleValueMetadata = {
124
+ staticFilterId: 'filetypes',
125
+ staticFilterValue: {
126
+ caption: 'Youtube',
127
+ expression: '@filetype="youtubevideo"',
128
+ },
129
+ };
130
+ await client.logStaticFilterDeselect(meta);
131
+
132
+ expectMatchPayload(SearchPageEvents.staticFilterDeselect, meta);
133
+ });
134
+
135
+ it('should send proper payload for #breadcrumbResetAll', async () => {
136
+ await client.logBreadcrumbResetAll();
137
+ expectMatchPayload(SearchPageEvents.breadcrumbResetAll);
138
+ });
139
+
140
+ it('should send proper payload for #breadcrumbFacet', async () => {
141
+ const meta = {
142
+ facetField: '@foo',
143
+ facetId: 'bar',
144
+ facetTitle: 'title',
145
+ facetValue: 'qwerty',
146
+ };
147
+ await client.logBreadcrumbFacet(meta);
148
+ expectMatchPayload(SearchPageEvents.breadcrumbFacet, meta);
149
+ });
150
+
122
151
  it('should send proper payload for #breadcrumbResetAll', async () => {
123
152
  await client.logBreadcrumbResetAll();
124
153
  expectMatchPayload(SearchPageEvents.breadcrumbResetAll);
@@ -15,6 +15,7 @@ import {
15
15
  ResultsSortMetadata,
16
16
  FacetRangeMetadata,
17
17
  CategoryFacetMetadata,
18
+ StaticFilterToggleValueMetadata,
18
19
  } from '../searchPage/searchPageEvents';
19
20
 
20
21
  export interface InsightClientProvider {
@@ -62,6 +63,10 @@ export class CoveoInsightClient {
62
63
  return this.logSearchEvent(SearchPageEvents.interfaceChange, metadata);
63
64
  }
64
65
 
66
+ public logStaticFilterDeselect(meta: StaticFilterToggleValueMetadata) {
67
+ return this.logSearchEvent(SearchPageEvents.staticFilterDeselect, meta);
68
+ }
69
+
65
70
  public logFetchMoreResults() {
66
71
  return this.logCustomEvent(SearchPageEvents.pagerScrolling, {type: 'getMoreResults'});
67
72
  }