coveo.analytics 2.20.8 → 2.20.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.
- package/dist/coveoua.browser.js +1 -1
- package/dist/coveoua.browser.js.map +1 -1
- package/dist/coveoua.js +1 -1
- package/dist/coveoua.js.map +1 -1
- package/dist/definitions/client/analytics.d.ts +1 -0
- package/dist/definitions/client/analyticsBeaconClient.d.ts +1 -0
- package/dist/definitions/client/analyticsFetchClient.d.ts +1 -0
- package/dist/definitions/client/analyticsRequestClient.d.ts +2 -0
- package/dist/definitions/insight/insightClient.d.ts +2 -1
- package/dist/definitions/searchPage/searchPageClient.d.ts +3 -0
- package/dist/library.es.js +27 -1
- package/dist/library.js +38 -1
- package/dist/react-native.es.js +7 -0
- package/package.json +1 -1
- package/src/client/analytics.ts +4 -0
- package/src/client/analyticsBeaconClient.ts +4 -0
- package/src/client/analyticsFetchClient.ts +6 -0
- package/src/client/analyticsRequestClient.ts +5 -0
- package/src/insight/insightClient.spec.ts +30 -1
- package/src/insight/insightClient.ts +5 -0
- package/src/searchPage/searchPageClient.spec.ts +11 -0
- package/src/searchPage/searchPageClient.ts +12 -0
|
@@ -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>;
|
|
@@ -13,6 +13,8 @@ export interface SearchPageClientProvider {
|
|
|
13
13
|
getLanguage: () => string;
|
|
14
14
|
getIsAnonymous: () => boolean;
|
|
15
15
|
getFacetState?: () => FacetStateMetadata[];
|
|
16
|
+
getSplitTestRunName?: () => string | undefined;
|
|
17
|
+
getSplitTestRunVersion?: () => string | undefined;
|
|
16
18
|
}
|
|
17
19
|
export interface SearchPageClientOptions extends ClientOptions {
|
|
18
20
|
enableAnalytics: boolean;
|
|
@@ -98,4 +100,5 @@ export declare class CoveoSearchPageClient {
|
|
|
98
100
|
private getBaseEventRequest;
|
|
99
101
|
private getOrigins;
|
|
100
102
|
private getClientId;
|
|
103
|
+
private getSplitTestRun;
|
|
101
104
|
}
|
package/dist/library.es.js
CHANGED
|
@@ -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);
|
|
@@ -1492,7 +1510,7 @@ class CoveoSearchPageClient {
|
|
|
1492
1510
|
getBaseEventRequest(metadata) {
|
|
1493
1511
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1494
1512
|
const customData = Object.assign(Object.assign({}, this.provider.getBaseMetadata()), metadata);
|
|
1495
|
-
return Object.assign(Object.assign({}, this.getOrigins()), { customData, language: this.provider.getLanguage(), facetState: this.provider.getFacetState ? this.provider.getFacetState() : [], anonymous: this.provider.getIsAnonymous(), clientId: yield this.getClientId() });
|
|
1513
|
+
return Object.assign(Object.assign(Object.assign({}, this.getOrigins()), this.getSplitTestRun()), { customData, language: this.provider.getLanguage(), facetState: this.provider.getFacetState ? this.provider.getFacetState() : [], anonymous: this.provider.getIsAnonymous(), clientId: yield this.getClientId() });
|
|
1496
1514
|
});
|
|
1497
1515
|
}
|
|
1498
1516
|
getOrigins() {
|
|
@@ -1509,6 +1527,11 @@ class CoveoSearchPageClient {
|
|
|
1509
1527
|
? this.coveoAnalyticsClient.getCurrentVisitorId()
|
|
1510
1528
|
: undefined;
|
|
1511
1529
|
}
|
|
1530
|
+
getSplitTestRun() {
|
|
1531
|
+
const splitTestRunName = this.provider.getSplitTestRunName ? this.provider.getSplitTestRunName() : '';
|
|
1532
|
+
const splitTestRunVersion = this.provider.getSplitTestRunVersion ? this.provider.getSplitTestRunVersion() : '';
|
|
1533
|
+
return Object.assign(Object.assign({}, (splitTestRunName && { splitTestRunName })), (splitTestRunVersion && { splitTestRunVersion }));
|
|
1534
|
+
}
|
|
1512
1535
|
}
|
|
1513
1536
|
|
|
1514
1537
|
const getFormattedLocation = (location) => `${location.protocol}//${location.hostname}${location.pathname.indexOf('/') === 0 ? location.pathname : `/${location.pathname}`}${location.search}`;
|
|
@@ -1787,6 +1810,9 @@ class CoveoInsightClient {
|
|
|
1787
1810
|
logInterfaceChange(metadata) {
|
|
1788
1811
|
return this.logSearchEvent(SearchPageEvents.interfaceChange, metadata);
|
|
1789
1812
|
}
|
|
1813
|
+
logStaticFilterDeselect(meta) {
|
|
1814
|
+
return this.logSearchEvent(SearchPageEvents.staticFilterDeselect, meta);
|
|
1815
|
+
}
|
|
1790
1816
|
logFetchMoreResults() {
|
|
1791
1817
|
return this.logCustomEvent(SearchPageEvents.pagerScrolling, { type: 'getMoreResults' });
|
|
1792
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) {
|
|
@@ -84008,7 +84037,7 @@ var CoveoSearchPageClient = (function () {
|
|
|
84008
84037
|
switch (_c.label) {
|
|
84009
84038
|
case 0:
|
|
84010
84039
|
customData = __assign(__assign({}, this.provider.getBaseMetadata()), metadata);
|
|
84011
|
-
_a = [__assign({}, this.getOrigins())];
|
|
84040
|
+
_a = [__assign(__assign({}, this.getOrigins()), this.getSplitTestRun())];
|
|
84012
84041
|
_b = { customData: customData, language: this.provider.getLanguage(), facetState: this.provider.getFacetState ? this.provider.getFacetState() : [], anonymous: this.provider.getIsAnonymous() };
|
|
84013
84042
|
return [4, this.getClientId()];
|
|
84014
84043
|
case 1: return [2, __assign.apply(void 0, _a.concat([(_b.clientId = _c.sent(), _b)]))];
|
|
@@ -84030,6 +84059,11 @@ var CoveoSearchPageClient = (function () {
|
|
|
84030
84059
|
? this.coveoAnalyticsClient.getCurrentVisitorId()
|
|
84031
84060
|
: undefined;
|
|
84032
84061
|
};
|
|
84062
|
+
CoveoSearchPageClient.prototype.getSplitTestRun = function () {
|
|
84063
|
+
var splitTestRunName = this.provider.getSplitTestRunName ? this.provider.getSplitTestRunName() : '';
|
|
84064
|
+
var splitTestRunVersion = this.provider.getSplitTestRunVersion ? this.provider.getSplitTestRunVersion() : '';
|
|
84065
|
+
return __assign(__assign({}, (splitTestRunName && { splitTestRunName: splitTestRunName })), (splitTestRunVersion && { splitTestRunVersion: splitTestRunVersion }));
|
|
84066
|
+
};
|
|
84033
84067
|
return CoveoSearchPageClient;
|
|
84034
84068
|
}());
|
|
84035
84069
|
|
|
@@ -84168,6 +84202,9 @@ var CoveoInsightClient = (function () {
|
|
|
84168
84202
|
CoveoInsightClient.prototype.logInterfaceChange = function (metadata) {
|
|
84169
84203
|
return this.logSearchEvent(SearchPageEvents.interfaceChange, metadata);
|
|
84170
84204
|
};
|
|
84205
|
+
CoveoInsightClient.prototype.logStaticFilterDeselect = function (meta) {
|
|
84206
|
+
return this.logSearchEvent(SearchPageEvents.staticFilterDeselect, meta);
|
|
84207
|
+
};
|
|
84171
84208
|
CoveoInsightClient.prototype.logFetchMoreResults = function () {
|
|
84172
84209
|
return this.logCustomEvent(SearchPageEvents.pagerScrolling, { type: 'getMoreResults' });
|
|
84173
84210
|
};
|
package/dist/react-native.es.js
CHANGED
|
@@ -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
package/src/client/analytics.ts
CHANGED
|
@@ -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
|
}
|
|
@@ -69,6 +69,8 @@ describe('SearchPageClient', () => {
|
|
|
69
69
|
getLanguage: () => 'en',
|
|
70
70
|
getFacetState: () => fakeFacetState,
|
|
71
71
|
getIsAnonymous: () => false,
|
|
72
|
+
getSplitTestRunName: () => 'split-test-run-something',
|
|
73
|
+
getSplitTestRunVersion: () => 'split-test-run-something/foo',
|
|
72
74
|
};
|
|
73
75
|
|
|
74
76
|
beforeEach(() => {
|
|
@@ -96,6 +98,11 @@ describe('SearchPageClient', () => {
|
|
|
96
98
|
originLevel3: 'origin-level-3',
|
|
97
99
|
});
|
|
98
100
|
|
|
101
|
+
const expectSplitTestRun = () => ({
|
|
102
|
+
splitTestRunName: 'split-test-run-something',
|
|
103
|
+
splitTestRunVersion: 'split-test-run-something/foo',
|
|
104
|
+
});
|
|
105
|
+
|
|
99
106
|
const expectMatchPayload = (actionCause: SearchPageEvents, meta = {}) => {
|
|
100
107
|
const [, {body}] = fetchMock.lastCall();
|
|
101
108
|
const customData = {foo: 'bar', ...meta};
|
|
@@ -109,6 +116,7 @@ describe('SearchPageClient', () => {
|
|
|
109
116
|
language: 'en',
|
|
110
117
|
clientId: 'visitor-id',
|
|
111
118
|
...expectOrigins(),
|
|
119
|
+
...expectSplitTestRun(),
|
|
112
120
|
});
|
|
113
121
|
};
|
|
114
122
|
|
|
@@ -123,6 +131,7 @@ describe('SearchPageClient', () => {
|
|
|
123
131
|
clientId: 'visitor-id',
|
|
124
132
|
...doc,
|
|
125
133
|
...expectOrigins(),
|
|
134
|
+
...expectSplitTestRun(),
|
|
126
135
|
});
|
|
127
136
|
};
|
|
128
137
|
|
|
@@ -137,6 +146,7 @@ describe('SearchPageClient', () => {
|
|
|
137
146
|
language: 'en',
|
|
138
147
|
clientId: 'visitor-id',
|
|
139
148
|
...expectOrigins(),
|
|
149
|
+
...expectSplitTestRun(),
|
|
140
150
|
});
|
|
141
151
|
};
|
|
142
152
|
|
|
@@ -151,6 +161,7 @@ describe('SearchPageClient', () => {
|
|
|
151
161
|
language: 'en',
|
|
152
162
|
clientId: 'visitor-id',
|
|
153
163
|
...expectOrigins(),
|
|
164
|
+
...expectSplitTestRun(),
|
|
154
165
|
});
|
|
155
166
|
};
|
|
156
167
|
|
|
@@ -42,6 +42,8 @@ export interface SearchPageClientProvider {
|
|
|
42
42
|
getLanguage: () => string;
|
|
43
43
|
getIsAnonymous: () => boolean;
|
|
44
44
|
getFacetState?: () => FacetStateMetadata[];
|
|
45
|
+
getSplitTestRunName?: () => string | undefined;
|
|
46
|
+
getSplitTestRunVersion?: () => string | undefined;
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
export interface SearchPageClientOptions extends ClientOptions {
|
|
@@ -417,6 +419,7 @@ export class CoveoSearchPageClient {
|
|
|
417
419
|
const customData = {...this.provider.getBaseMetadata(), ...metadata};
|
|
418
420
|
return {
|
|
419
421
|
...this.getOrigins(),
|
|
422
|
+
...this.getSplitTestRun(),
|
|
420
423
|
customData,
|
|
421
424
|
language: this.provider.getLanguage(),
|
|
422
425
|
facetState: this.provider.getFacetState ? this.provider.getFacetState() : [],
|
|
@@ -439,4 +442,13 @@ export class CoveoSearchPageClient {
|
|
|
439
442
|
? this.coveoAnalyticsClient.getCurrentVisitorId()
|
|
440
443
|
: undefined;
|
|
441
444
|
}
|
|
445
|
+
|
|
446
|
+
private getSplitTestRun() {
|
|
447
|
+
const splitTestRunName = this.provider.getSplitTestRunName ? this.provider.getSplitTestRunName() : '';
|
|
448
|
+
const splitTestRunVersion = this.provider.getSplitTestRunVersion ? this.provider.getSplitTestRunVersion() : '';
|
|
449
|
+
return {
|
|
450
|
+
...(splitTestRunName && {splitTestRunName}),
|
|
451
|
+
...(splitTestRunVersion && {splitTestRunVersion}),
|
|
452
|
+
};
|
|
453
|
+
}
|
|
442
454
|
}
|