coveo.analytics 2.28.14 → 2.28.16
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.debug.js +41 -23
- 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/analyticsBeaconClient.d.ts +2 -1
- package/dist/definitions/version.d.ts +1 -1
- package/dist/{library.js → library.cjs} +41 -23
- package/dist/react-native.es.js +28 -10
- package/modules/package.json +11 -0
- package/package.json +6 -5
- package/src/client/analyticsBeaconClient.spec.ts +83 -22
- package/src/client/analyticsBeaconClient.ts +42 -13
- package/dist/library.es.js +0 -3123
package/dist/coveoua.debug.js
CHANGED
|
@@ -728,7 +728,7 @@
|
|
|
728
728
|
const v5 = v35('v5', 0x50, sha1);
|
|
729
729
|
var uuidv5 = v5;
|
|
730
730
|
|
|
731
|
-
var libVersion = "2.28.
|
|
731
|
+
var libVersion = "2.28.16" ;
|
|
732
732
|
|
|
733
733
|
var getFormattedLocation = function (location) {
|
|
734
734
|
return "".concat(location.protocol, "//").concat(location.hostname).concat(location.pathname.indexOf('/') === 0 ? location.pathname : "/".concat(location.pathname)).concat(location.search);
|
|
@@ -1202,37 +1202,26 @@
|
|
|
1202
1202
|
function AnalyticsBeaconClient(opts) {
|
|
1203
1203
|
this.opts = opts;
|
|
1204
1204
|
}
|
|
1205
|
-
AnalyticsBeaconClient.prototype.sendEvent = function (eventType,
|
|
1205
|
+
AnalyticsBeaconClient.prototype.sendEvent = function (eventType, originalPayload) {
|
|
1206
1206
|
return __awaiter(this, void 0, void 0, function () {
|
|
1207
|
-
var _a, baseUrl, preprocessRequest,
|
|
1208
|
-
return __generator(this, function (
|
|
1209
|
-
switch (
|
|
1207
|
+
var _a, baseUrl, preprocessRequest, paramsFragments, _b, url, payload, parsedRequestData, body;
|
|
1208
|
+
return __generator(this, function (_c) {
|
|
1209
|
+
switch (_c.label) {
|
|
1210
1210
|
case 0:
|
|
1211
1211
|
if (!this.isAvailable()) {
|
|
1212
1212
|
throw new Error("navigator.sendBeacon is not supported in this browser. Consider adding a polyfill like \"sendbeacon-polyfill\".");
|
|
1213
1213
|
}
|
|
1214
1214
|
_a = this.opts, baseUrl = _a.baseUrl, preprocessRequest = _a.preprocessRequest;
|
|
1215
|
-
parsedRequestData = this.encodeForEventType(eventType, payload);
|
|
1216
1215
|
return [4, this.getQueryParamsForEventType(eventType)];
|
|
1217
1216
|
case 1:
|
|
1218
|
-
paramsFragments =
|
|
1219
|
-
|
|
1220
|
-
url: "".concat(baseUrl, "/analytics/").concat(eventType, "?").concat(paramsFragments),
|
|
1221
|
-
body: new Blob([parsedRequestData], {
|
|
1222
|
-
type: 'application/x-www-form-urlencoded',
|
|
1223
|
-
}),
|
|
1224
|
-
};
|
|
1225
|
-
_c = [__assign({}, defaultOptions)];
|
|
1226
|
-
if (!preprocessRequest) return [3, 3];
|
|
1227
|
-
return [4, preprocessRequest(defaultOptions, 'analyticsBeacon')];
|
|
1217
|
+
paramsFragments = _c.sent();
|
|
1218
|
+
return [4, this.preProcessRequestAsPotentialJSONString("".concat(baseUrl, "/analytics/").concat(eventType, "?").concat(paramsFragments), originalPayload, preprocessRequest)];
|
|
1228
1219
|
case 2:
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
case 4:
|
|
1235
|
-
_b = __assign.apply(void 0, _c.concat([(_d)])), url = _b.url, body = _b.body;
|
|
1220
|
+
_b = _c.sent(), url = _b.url, payload = _b.payload;
|
|
1221
|
+
parsedRequestData = this.encodeForEventType(eventType, payload);
|
|
1222
|
+
body = new Blob([parsedRequestData], {
|
|
1223
|
+
type: 'application/x-www-form-urlencoded',
|
|
1224
|
+
});
|
|
1236
1225
|
navigator.sendBeacon(url, body);
|
|
1237
1226
|
return [2];
|
|
1238
1227
|
}
|
|
@@ -1245,6 +1234,35 @@
|
|
|
1245
1234
|
AnalyticsBeaconClient.prototype.deleteHttpCookieVisitorId = function () {
|
|
1246
1235
|
return Promise.resolve();
|
|
1247
1236
|
};
|
|
1237
|
+
AnalyticsBeaconClient.prototype.preProcessRequestAsPotentialJSONString = function (originalURL, originalPayload, preprocessRequest) {
|
|
1238
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1239
|
+
var returnedUrl, returnedPayload, processedRequest, processedURL, processedBody;
|
|
1240
|
+
return __generator(this, function (_a) {
|
|
1241
|
+
switch (_a.label) {
|
|
1242
|
+
case 0:
|
|
1243
|
+
returnedUrl = originalURL;
|
|
1244
|
+
returnedPayload = originalPayload;
|
|
1245
|
+
if (!preprocessRequest) return [3, 2];
|
|
1246
|
+
return [4, preprocessRequest({ url: originalURL, body: JSON.stringify(originalPayload) }, 'analyticsBeacon')];
|
|
1247
|
+
case 1:
|
|
1248
|
+
processedRequest = _a.sent();
|
|
1249
|
+
processedURL = processedRequest.url, processedBody = processedRequest.body;
|
|
1250
|
+
returnedUrl = processedURL || originalURL;
|
|
1251
|
+
try {
|
|
1252
|
+
returnedPayload = JSON.parse(processedBody);
|
|
1253
|
+
}
|
|
1254
|
+
catch (e) {
|
|
1255
|
+
console.error('Unable to process the request body as a JSON string', e);
|
|
1256
|
+
}
|
|
1257
|
+
_a.label = 2;
|
|
1258
|
+
case 2: return [2, {
|
|
1259
|
+
payload: returnedPayload,
|
|
1260
|
+
url: returnedUrl,
|
|
1261
|
+
}];
|
|
1262
|
+
}
|
|
1263
|
+
});
|
|
1264
|
+
});
|
|
1265
|
+
};
|
|
1248
1266
|
AnalyticsBeaconClient.prototype.encodeForEventType = function (eventType, payload) {
|
|
1249
1267
|
return this.isEventTypeLegacy(eventType)
|
|
1250
1268
|
? this.encodeForLegacyType(eventType, payload)
|