coveo.analytics 2.29.4 → 2.29.6
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/browser.mjs +13 -4
- package/dist/coveoua.browser.js +1 -1
- package/dist/coveoua.browser.js.map +1 -1
- package/dist/coveoua.debug.js +19 -8
- package/dist/coveoua.debug.js.map +1 -1
- package/dist/coveoua.js +1 -1
- package/dist/coveoua.js.map +1 -1
- package/dist/definitions/client/analyticsFetchClient.d.ts +1 -1
- package/dist/definitions/version.d.ts +1 -1
- package/dist/library.cjs +19 -8
- package/dist/library.es.js +13 -4
- package/dist/library.js +19 -8
- package/dist/library.mjs +19 -8
- package/dist/react-native.es.js +13 -4
- package/package.json +1 -1
- package/src/client/analytics.spec.ts +3 -2
- package/src/client/analytics.ts +3 -2
- package/src/client/analyticsFetchClient.ts +10 -2
|
@@ -3,7 +3,7 @@ import { AnyEventResponse, EventType, IRequestPayload } from '../events';
|
|
|
3
3
|
export declare class AnalyticsFetchClient implements AnalyticsRequestClient {
|
|
4
4
|
private opts;
|
|
5
5
|
constructor(opts: IAnalyticsClientOptions);
|
|
6
|
-
sendEvent(eventType: EventType, payload: IRequestPayload): Promise<AnyEventResponse>;
|
|
6
|
+
sendEvent(eventType: EventType, payload: IRequestPayload): Promise<AnyEventResponse | void>;
|
|
7
7
|
deleteHttpCookieVisitorId(): Promise<void>;
|
|
8
8
|
private shouldAppendVisitorId;
|
|
9
9
|
private getVisitorIdParam;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const libVersion = "2.29.
|
|
1
|
+
export declare const libVersion = "2.29.6";
|
package/dist/library.cjs
CHANGED
|
@@ -731,7 +731,7 @@ function sha1(bytes) {
|
|
|
731
731
|
const v5 = v35('v5', 0x50, sha1);
|
|
732
732
|
var uuidv5 = v5;
|
|
733
733
|
|
|
734
|
-
var libVersion = "2.29.
|
|
734
|
+
var libVersion = "2.29.6" ;
|
|
735
735
|
|
|
736
736
|
var getFormattedLocation = function (location) {
|
|
737
737
|
return "".concat(location.protocol, "//").concat(location.hostname).concat(location.pathname.indexOf('/') === 0 ? location.pathname : "/".concat(location.pathname)).concat(location.search);
|
|
@@ -82840,7 +82840,7 @@ var AnalyticsFetchClient = (function () {
|
|
|
82840
82840
|
}
|
|
82841
82841
|
AnalyticsFetchClient.prototype.sendEvent = function (eventType, payload) {
|
|
82842
82842
|
return __awaiter(this, void 0, void 0, function () {
|
|
82843
|
-
var _a, baseUrl, visitorIdProvider, preprocessRequest, visitorIdParam, _b, defaultOptions, _c, url, fetchData, _d, _e, response, visit;
|
|
82843
|
+
var _a, baseUrl, visitorIdProvider, preprocessRequest, visitorIdParam, _b, defaultOptions, _c, url, fetchData, _d, _e, response, error_1, visit;
|
|
82844
82844
|
return __generator(this, function (_f) {
|
|
82845
82845
|
switch (_f.label) {
|
|
82846
82846
|
case 0:
|
|
@@ -82874,18 +82874,27 @@ var AnalyticsFetchClient = (function () {
|
|
|
82874
82874
|
_f.label = 6;
|
|
82875
82875
|
case 6:
|
|
82876
82876
|
_c = __assign.apply(void 0, _d.concat([(_e)])), url = _c.url, fetchData = __rest(_c, ["url"]);
|
|
82877
|
-
|
|
82877
|
+
_f.label = 7;
|
|
82878
82878
|
case 7:
|
|
82879
|
+
_f.trys.push([7, 9, , 10]);
|
|
82880
|
+
return [4, nodePonyfillExports.fetch(url, fetchData)];
|
|
82881
|
+
case 8:
|
|
82879
82882
|
response = _f.sent();
|
|
82880
|
-
|
|
82883
|
+
return [3, 10];
|
|
82884
|
+
case 9:
|
|
82885
|
+
error_1 = _f.sent();
|
|
82886
|
+
console.error('An error has occured when sending the event.', error_1);
|
|
82887
|
+
return [2];
|
|
82888
|
+
case 10:
|
|
82889
|
+
if (!response.ok) return [3, 12];
|
|
82881
82890
|
return [4, response.json()];
|
|
82882
|
-
case
|
|
82891
|
+
case 11:
|
|
82883
82892
|
visit = (_f.sent());
|
|
82884
82893
|
if (visit.visitorId) {
|
|
82885
82894
|
visitorIdProvider.setCurrentVisitorId(visit.visitorId);
|
|
82886
82895
|
}
|
|
82887
82896
|
return [2, visit];
|
|
82888
|
-
case
|
|
82897
|
+
case 12:
|
|
82889
82898
|
try {
|
|
82890
82899
|
response.json();
|
|
82891
82900
|
}
|
|
@@ -83048,9 +83057,11 @@ var CoveoAnalyticsClient = (function () {
|
|
|
83048
83057
|
visitorIdProvider: this,
|
|
83049
83058
|
preprocessRequest: this.options.preprocessRequest,
|
|
83050
83059
|
};
|
|
83051
|
-
this.runtime = this.options.runtimeEnvironment || this.initRuntime(clientsOptions);
|
|
83052
83060
|
if (doNotTrack()) {
|
|
83053
|
-
this.runtime
|
|
83061
|
+
this.runtime = new NoopRuntime();
|
|
83062
|
+
}
|
|
83063
|
+
else {
|
|
83064
|
+
this.runtime = this.options.runtimeEnvironment || this.initRuntime(clientsOptions);
|
|
83054
83065
|
}
|
|
83055
83066
|
this.addEventTypeMapping(exports.EventType.view, { newEventType: exports.EventType.view, addClientIdParameter: true });
|
|
83056
83067
|
this.addEventTypeMapping(exports.EventType.click, { newEventType: exports.EventType.click, addClientIdParameter: true });
|
package/dist/library.es.js
CHANGED
|
@@ -596,7 +596,7 @@ function sha1(bytes) {
|
|
|
596
596
|
const v5 = v35('v5', 0x50, sha1);
|
|
597
597
|
var uuidv5 = v5;
|
|
598
598
|
|
|
599
|
-
const libVersion = "2.29.
|
|
599
|
+
const libVersion = "2.29.6" ;
|
|
600
600
|
|
|
601
601
|
const getFormattedLocation = (location) => `${location.protocol}//${location.hostname}${location.pathname.indexOf('/') === 0 ? location.pathname : `/${location.pathname}`}${location.search}`;
|
|
602
602
|
|
|
@@ -1112,7 +1112,14 @@ class AnalyticsFetchClient {
|
|
|
1112
1112
|
body: JSON.stringify(payload),
|
|
1113
1113
|
};
|
|
1114
1114
|
const _a = Object.assign(Object.assign({}, defaultOptions), (preprocessRequest ? yield preprocessRequest(defaultOptions, 'analyticsFetch') : {})), { url } = _a, fetchData = __rest(_a, ["url"]);
|
|
1115
|
-
|
|
1115
|
+
let response;
|
|
1116
|
+
try {
|
|
1117
|
+
response = yield fetch$1(url, fetchData);
|
|
1118
|
+
}
|
|
1119
|
+
catch (error) {
|
|
1120
|
+
console.error('An error has occured when sending the event.', error);
|
|
1121
|
+
return;
|
|
1122
|
+
}
|
|
1116
1123
|
if (response.ok) {
|
|
1117
1124
|
const visit = (yield response.json());
|
|
1118
1125
|
if (visit.visitorId) {
|
|
@@ -1267,9 +1274,11 @@ class CoveoAnalyticsClient {
|
|
|
1267
1274
|
visitorIdProvider: this,
|
|
1268
1275
|
preprocessRequest: this.options.preprocessRequest,
|
|
1269
1276
|
};
|
|
1270
|
-
this.runtime = this.options.runtimeEnvironment || this.initRuntime(clientsOptions);
|
|
1271
1277
|
if (doNotTrack()) {
|
|
1272
|
-
this.runtime
|
|
1278
|
+
this.runtime = new NoopRuntime();
|
|
1279
|
+
}
|
|
1280
|
+
else {
|
|
1281
|
+
this.runtime = this.options.runtimeEnvironment || this.initRuntime(clientsOptions);
|
|
1273
1282
|
}
|
|
1274
1283
|
this.addEventTypeMapping(EventType.view, { newEventType: EventType.view, addClientIdParameter: true });
|
|
1275
1284
|
this.addEventTypeMapping(EventType.click, { newEventType: EventType.click, addClientIdParameter: true });
|
package/dist/library.js
CHANGED
|
@@ -731,7 +731,7 @@ function sha1(bytes) {
|
|
|
731
731
|
const v5 = v35('v5', 0x50, sha1);
|
|
732
732
|
var uuidv5 = v5;
|
|
733
733
|
|
|
734
|
-
var libVersion = "2.29.
|
|
734
|
+
var libVersion = "2.29.6" ;
|
|
735
735
|
|
|
736
736
|
var getFormattedLocation = function (location) {
|
|
737
737
|
return "".concat(location.protocol, "//").concat(location.hostname).concat(location.pathname.indexOf('/') === 0 ? location.pathname : "/".concat(location.pathname)).concat(location.search);
|
|
@@ -82840,7 +82840,7 @@ var AnalyticsFetchClient = (function () {
|
|
|
82840
82840
|
}
|
|
82841
82841
|
AnalyticsFetchClient.prototype.sendEvent = function (eventType, payload) {
|
|
82842
82842
|
return __awaiter(this, void 0, void 0, function () {
|
|
82843
|
-
var _a, baseUrl, visitorIdProvider, preprocessRequest, visitorIdParam, _b, defaultOptions, _c, url, fetchData, _d, _e, response, visit;
|
|
82843
|
+
var _a, baseUrl, visitorIdProvider, preprocessRequest, visitorIdParam, _b, defaultOptions, _c, url, fetchData, _d, _e, response, error_1, visit;
|
|
82844
82844
|
return __generator(this, function (_f) {
|
|
82845
82845
|
switch (_f.label) {
|
|
82846
82846
|
case 0:
|
|
@@ -82874,18 +82874,27 @@ var AnalyticsFetchClient = (function () {
|
|
|
82874
82874
|
_f.label = 6;
|
|
82875
82875
|
case 6:
|
|
82876
82876
|
_c = __assign.apply(void 0, _d.concat([(_e)])), url = _c.url, fetchData = __rest(_c, ["url"]);
|
|
82877
|
-
|
|
82877
|
+
_f.label = 7;
|
|
82878
82878
|
case 7:
|
|
82879
|
+
_f.trys.push([7, 9, , 10]);
|
|
82880
|
+
return [4, nodePonyfillExports.fetch(url, fetchData)];
|
|
82881
|
+
case 8:
|
|
82879
82882
|
response = _f.sent();
|
|
82880
|
-
|
|
82883
|
+
return [3, 10];
|
|
82884
|
+
case 9:
|
|
82885
|
+
error_1 = _f.sent();
|
|
82886
|
+
console.error('An error has occured when sending the event.', error_1);
|
|
82887
|
+
return [2];
|
|
82888
|
+
case 10:
|
|
82889
|
+
if (!response.ok) return [3, 12];
|
|
82881
82890
|
return [4, response.json()];
|
|
82882
|
-
case
|
|
82891
|
+
case 11:
|
|
82883
82892
|
visit = (_f.sent());
|
|
82884
82893
|
if (visit.visitorId) {
|
|
82885
82894
|
visitorIdProvider.setCurrentVisitorId(visit.visitorId);
|
|
82886
82895
|
}
|
|
82887
82896
|
return [2, visit];
|
|
82888
|
-
case
|
|
82897
|
+
case 12:
|
|
82889
82898
|
try {
|
|
82890
82899
|
response.json();
|
|
82891
82900
|
}
|
|
@@ -83048,9 +83057,11 @@ var CoveoAnalyticsClient = (function () {
|
|
|
83048
83057
|
visitorIdProvider: this,
|
|
83049
83058
|
preprocessRequest: this.options.preprocessRequest,
|
|
83050
83059
|
};
|
|
83051
|
-
this.runtime = this.options.runtimeEnvironment || this.initRuntime(clientsOptions);
|
|
83052
83060
|
if (doNotTrack()) {
|
|
83053
|
-
this.runtime
|
|
83061
|
+
this.runtime = new NoopRuntime();
|
|
83062
|
+
}
|
|
83063
|
+
else {
|
|
83064
|
+
this.runtime = this.options.runtimeEnvironment || this.initRuntime(clientsOptions);
|
|
83054
83065
|
}
|
|
83055
83066
|
this.addEventTypeMapping(exports.EventType.view, { newEventType: exports.EventType.view, addClientIdParameter: true });
|
|
83056
83067
|
this.addEventTypeMapping(exports.EventType.click, { newEventType: exports.EventType.click, addClientIdParameter: true });
|
package/dist/library.mjs
CHANGED
|
@@ -729,7 +729,7 @@ function sha1(bytes) {
|
|
|
729
729
|
const v5 = v35('v5', 0x50, sha1);
|
|
730
730
|
var uuidv5 = v5;
|
|
731
731
|
|
|
732
|
-
var libVersion = "2.29.
|
|
732
|
+
var libVersion = "2.29.6" ;
|
|
733
733
|
|
|
734
734
|
var getFormattedLocation = function (location) {
|
|
735
735
|
return "".concat(location.protocol, "//").concat(location.hostname).concat(location.pathname.indexOf('/') === 0 ? location.pathname : "/".concat(location.pathname)).concat(location.search);
|
|
@@ -82838,7 +82838,7 @@ var AnalyticsFetchClient = (function () {
|
|
|
82838
82838
|
}
|
|
82839
82839
|
AnalyticsFetchClient.prototype.sendEvent = function (eventType, payload) {
|
|
82840
82840
|
return __awaiter(this, void 0, void 0, function () {
|
|
82841
|
-
var _a, baseUrl, visitorIdProvider, preprocessRequest, visitorIdParam, _b, defaultOptions, _c, url, fetchData, _d, _e, response, visit;
|
|
82841
|
+
var _a, baseUrl, visitorIdProvider, preprocessRequest, visitorIdParam, _b, defaultOptions, _c, url, fetchData, _d, _e, response, error_1, visit;
|
|
82842
82842
|
return __generator(this, function (_f) {
|
|
82843
82843
|
switch (_f.label) {
|
|
82844
82844
|
case 0:
|
|
@@ -82872,18 +82872,27 @@ var AnalyticsFetchClient = (function () {
|
|
|
82872
82872
|
_f.label = 6;
|
|
82873
82873
|
case 6:
|
|
82874
82874
|
_c = __assign.apply(void 0, _d.concat([(_e)])), url = _c.url, fetchData = __rest(_c, ["url"]);
|
|
82875
|
-
|
|
82875
|
+
_f.label = 7;
|
|
82876
82876
|
case 7:
|
|
82877
|
+
_f.trys.push([7, 9, , 10]);
|
|
82878
|
+
return [4, nodePonyfillExports.fetch(url, fetchData)];
|
|
82879
|
+
case 8:
|
|
82877
82880
|
response = _f.sent();
|
|
82878
|
-
|
|
82881
|
+
return [3, 10];
|
|
82882
|
+
case 9:
|
|
82883
|
+
error_1 = _f.sent();
|
|
82884
|
+
console.error('An error has occured when sending the event.', error_1);
|
|
82885
|
+
return [2];
|
|
82886
|
+
case 10:
|
|
82887
|
+
if (!response.ok) return [3, 12];
|
|
82879
82888
|
return [4, response.json()];
|
|
82880
|
-
case
|
|
82889
|
+
case 11:
|
|
82881
82890
|
visit = (_f.sent());
|
|
82882
82891
|
if (visit.visitorId) {
|
|
82883
82892
|
visitorIdProvider.setCurrentVisitorId(visit.visitorId);
|
|
82884
82893
|
}
|
|
82885
82894
|
return [2, visit];
|
|
82886
|
-
case
|
|
82895
|
+
case 12:
|
|
82887
82896
|
try {
|
|
82888
82897
|
response.json();
|
|
82889
82898
|
}
|
|
@@ -83046,9 +83055,11 @@ var CoveoAnalyticsClient = (function () {
|
|
|
83046
83055
|
visitorIdProvider: this,
|
|
83047
83056
|
preprocessRequest: this.options.preprocessRequest,
|
|
83048
83057
|
};
|
|
83049
|
-
this.runtime = this.options.runtimeEnvironment || this.initRuntime(clientsOptions);
|
|
83050
83058
|
if (doNotTrack()) {
|
|
83051
|
-
this.runtime
|
|
83059
|
+
this.runtime = new NoopRuntime();
|
|
83060
|
+
}
|
|
83061
|
+
else {
|
|
83062
|
+
this.runtime = this.options.runtimeEnvironment || this.initRuntime(clientsOptions);
|
|
83052
83063
|
}
|
|
83053
83064
|
this.addEventTypeMapping(EventType.view, { newEventType: EventType.view, addClientIdParameter: true });
|
|
83054
83065
|
this.addEventTypeMapping(EventType.click, { newEventType: EventType.click, addClientIdParameter: true });
|
package/dist/react-native.es.js
CHANGED
|
@@ -64,7 +64,14 @@ class AnalyticsFetchClient {
|
|
|
64
64
|
body: JSON.stringify(payload),
|
|
65
65
|
};
|
|
66
66
|
const _a = Object.assign(Object.assign({}, defaultOptions), (preprocessRequest ? yield preprocessRequest(defaultOptions, 'analyticsFetch') : {})), { url } = _a, fetchData = __rest(_a, ["url"]);
|
|
67
|
-
|
|
67
|
+
let response;
|
|
68
|
+
try {
|
|
69
|
+
response = yield fetch$1(url, fetchData);
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
console.error('An error has occured when sending the event.', error);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
68
75
|
if (response.ok) {
|
|
69
76
|
const visit = (yield response.json());
|
|
70
77
|
if (visit.visitorId) {
|
|
@@ -658,7 +665,7 @@ const addPageViewToHistory = (pageViewValue) => __awaiter(void 0, void 0, void 0
|
|
|
658
665
|
yield store.addElementAsync(historyElement);
|
|
659
666
|
});
|
|
660
667
|
|
|
661
|
-
const libVersion = "2.29.
|
|
668
|
+
const libVersion = "2.29.6" ;
|
|
662
669
|
|
|
663
670
|
const getFormattedLocation = (location) => `${location.protocol}//${location.hostname}${location.pathname.indexOf('/') === 0 ? location.pathname : `/${location.pathname}`}${location.search}`;
|
|
664
671
|
|
|
@@ -1268,9 +1275,11 @@ class CoveoAnalyticsClient {
|
|
|
1268
1275
|
visitorIdProvider: this,
|
|
1269
1276
|
preprocessRequest: this.options.preprocessRequest,
|
|
1270
1277
|
};
|
|
1271
|
-
this.runtime = this.options.runtimeEnvironment || this.initRuntime(clientsOptions);
|
|
1272
1278
|
if (doNotTrack()) {
|
|
1273
|
-
this.runtime
|
|
1279
|
+
this.runtime = new NoopRuntime();
|
|
1280
|
+
}
|
|
1281
|
+
else {
|
|
1282
|
+
this.runtime = this.options.runtimeEnvironment || this.initRuntime(clientsOptions);
|
|
1274
1283
|
}
|
|
1275
1284
|
this.addEventTypeMapping(EventType.view, { newEventType: EventType.view, addClientIdParameter: true });
|
|
1276
1285
|
this.addEventTypeMapping(EventType.click, { newEventType: EventType.click, addClientIdParameter: true });
|
package/package.json
CHANGED
|
@@ -11,10 +11,11 @@ import {IAnalyticsRequestOptions} from './analyticsRequestClient';
|
|
|
11
11
|
import {CookieAndLocalStorage, CookieStorage, NullStorage} from '../storage';
|
|
12
12
|
import HistoryStore from '../history';
|
|
13
13
|
import {mockFetch} from '../../tests/fetchMock';
|
|
14
|
-
import {BrowserRuntime} from './runtimeEnvironment';
|
|
14
|
+
import {BrowserRuntime, NoopRuntime} from './runtimeEnvironment';
|
|
15
15
|
import * as doNotTrack from '../donottrack';
|
|
16
16
|
import {Cookie} from '../cookieutils';
|
|
17
17
|
import {CoveoLinkParam} from '../plugins/link';
|
|
18
|
+
import {NoopAnalytics} from './noopAnalytics';
|
|
18
19
|
|
|
19
20
|
const aVisitorId = '123';
|
|
20
21
|
jest.mock('uuid', () => ({
|
|
@@ -663,7 +664,7 @@ describe('doNotTrack', () => {
|
|
|
663
664
|
|
|
664
665
|
let client = new CoveoAnalyticsClient({});
|
|
665
666
|
|
|
666
|
-
expect(client.runtime).toBeInstanceOf(
|
|
667
|
+
expect(client.runtime).toBeInstanceOf(NoopRuntime);
|
|
667
668
|
expect(client.runtime.storage).toBeInstanceOf(NullStorage);
|
|
668
669
|
});
|
|
669
670
|
|
package/src/client/analytics.ts
CHANGED
|
@@ -182,9 +182,10 @@ export class CoveoAnalyticsClient implements AnalyticsClient, VisitorIdProvider
|
|
|
182
182
|
preprocessRequest: this.options.preprocessRequest,
|
|
183
183
|
};
|
|
184
184
|
|
|
185
|
-
this.runtime = this.options.runtimeEnvironment || this.initRuntime(clientsOptions);
|
|
186
185
|
if (doNotTrack()) {
|
|
187
|
-
this.runtime
|
|
186
|
+
this.runtime = new NoopRuntime();
|
|
187
|
+
} else {
|
|
188
|
+
this.runtime = this.options.runtimeEnvironment || this.initRuntime(clientsOptions);
|
|
188
189
|
}
|
|
189
190
|
|
|
190
191
|
this.addEventTypeMapping(EventType.view, {newEventType: EventType.view, addClientIdParameter: true});
|
|
@@ -5,7 +5,7 @@ import {fetch} from 'cross-fetch';
|
|
|
5
5
|
export class AnalyticsFetchClient implements AnalyticsRequestClient {
|
|
6
6
|
constructor(private opts: IAnalyticsClientOptions) {}
|
|
7
7
|
|
|
8
|
-
public async sendEvent(eventType: EventType, payload: IRequestPayload): Promise<AnyEventResponse> {
|
|
8
|
+
public async sendEvent(eventType: EventType, payload: IRequestPayload): Promise<AnyEventResponse | void> {
|
|
9
9
|
const {baseUrl, visitorIdProvider, preprocessRequest} = this.opts;
|
|
10
10
|
|
|
11
11
|
const visitorIdParam = this.shouldAppendVisitorId(eventType) ? await this.getVisitorIdParam() : '';
|
|
@@ -22,7 +22,15 @@ export class AnalyticsFetchClient implements AnalyticsRequestClient {
|
|
|
22
22
|
...(preprocessRequest ? await preprocessRequest(defaultOptions, 'analyticsFetch') : {}),
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
let response: Response;
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
response = await fetch(url, fetchData);
|
|
29
|
+
} catch (error) {
|
|
30
|
+
console.error('An error has occured when sending the event.', error);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
26
34
|
if (response.ok) {
|
|
27
35
|
const visit = (await response.json()) as AnyEventResponse;
|
|
28
36
|
|