coveo.analytics 2.20.8 → 2.20.9

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.
@@ -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
  }
@@ -1492,7 +1492,7 @@ class CoveoSearchPageClient {
1492
1492
  getBaseEventRequest(metadata) {
1493
1493
  return __awaiter(this, void 0, void 0, function* () {
1494
1494
  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() });
1495
+ 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
1496
  });
1497
1497
  }
1498
1498
  getOrigins() {
@@ -1509,6 +1509,11 @@ class CoveoSearchPageClient {
1509
1509
  ? this.coveoAnalyticsClient.getCurrentVisitorId()
1510
1510
  : undefined;
1511
1511
  }
1512
+ getSplitTestRun() {
1513
+ const splitTestRunName = this.provider.getSplitTestRunName ? this.provider.getSplitTestRunName() : '';
1514
+ const splitTestRunVersion = this.provider.getSplitTestRunVersion ? this.provider.getSplitTestRunVersion() : '';
1515
+ return Object.assign(Object.assign({}, (splitTestRunName && { splitTestRunName })), (splitTestRunVersion && { splitTestRunVersion }));
1516
+ }
1512
1517
  }
1513
1518
 
1514
1519
  const getFormattedLocation = (location) => `${location.protocol}//${location.hostname}${location.pathname.indexOf('/') === 0 ? location.pathname : `/${location.pathname}`}${location.search}`;
package/dist/library.js CHANGED
@@ -84008,7 +84008,7 @@ var CoveoSearchPageClient = (function () {
84008
84008
  switch (_c.label) {
84009
84009
  case 0:
84010
84010
  customData = __assign(__assign({}, this.provider.getBaseMetadata()), metadata);
84011
- _a = [__assign({}, this.getOrigins())];
84011
+ _a = [__assign(__assign({}, this.getOrigins()), this.getSplitTestRun())];
84012
84012
  _b = { customData: customData, language: this.provider.getLanguage(), facetState: this.provider.getFacetState ? this.provider.getFacetState() : [], anonymous: this.provider.getIsAnonymous() };
84013
84013
  return [4, this.getClientId()];
84014
84014
  case 1: return [2, __assign.apply(void 0, _a.concat([(_b.clientId = _c.sent(), _b)]))];
@@ -84030,6 +84030,11 @@ var CoveoSearchPageClient = (function () {
84030
84030
  ? this.coveoAnalyticsClient.getCurrentVisitorId()
84031
84031
  : undefined;
84032
84032
  };
84033
+ CoveoSearchPageClient.prototype.getSplitTestRun = function () {
84034
+ var splitTestRunName = this.provider.getSplitTestRunName ? this.provider.getSplitTestRunName() : '';
84035
+ var splitTestRunVersion = this.provider.getSplitTestRunVersion ? this.provider.getSplitTestRunVersion() : '';
84036
+ return __assign(__assign({}, (splitTestRunName && { splitTestRunName: splitTestRunName })), (splitTestRunVersion && { splitTestRunVersion: splitTestRunVersion }));
84037
+ };
84033
84038
  return CoveoSearchPageClient;
84034
84039
  }());
84035
84040
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coveo.analytics",
3
- "version": "2.20.8",
3
+ "version": "2.20.9",
4
4
  "description": "📈 Coveo analytics client (node and browser compatible) ",
5
5
  "main": "dist/library.js",
6
6
  "module": "dist/library.es.js",
@@ -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
  }