coveo.analytics 2.28.15 → 2.28.17
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 +3141 -0
- 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.cjs +41 -23
- package/dist/library.mjs +86154 -0
- package/dist/react-native.es.js +28 -10
- package/package.json +7 -3
- package/src/client/analyticsBeaconClient.spec.ts +83 -22
- package/src/client/analyticsBeaconClient.ts +42 -13
|
@@ -3,9 +3,10 @@ import { EventType, IRequestPayload } from '../events';
|
|
|
3
3
|
export declare class AnalyticsBeaconClient implements AnalyticsRequestClient {
|
|
4
4
|
private opts;
|
|
5
5
|
constructor(opts: IAnalyticsClientOptions);
|
|
6
|
-
sendEvent(eventType: EventType,
|
|
6
|
+
sendEvent(eventType: EventType, originalPayload: IRequestPayload): Promise<void>;
|
|
7
7
|
isAvailable(): boolean;
|
|
8
8
|
deleteHttpCookieVisitorId(): Promise<void>;
|
|
9
|
+
private preProcessRequestAsPotentialJSONString;
|
|
9
10
|
private encodeForEventType;
|
|
10
11
|
private getQueryParamsForEventType;
|
|
11
12
|
private isEventTypeLegacy;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const libVersion = "2.28.
|
|
1
|
+
export declare const libVersion = "2.28.17";
|
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.28.
|
|
734
|
+
var libVersion = "2.28.17" ;
|
|
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);
|
|
@@ -1205,37 +1205,26 @@ var AnalyticsBeaconClient = (function () {
|
|
|
1205
1205
|
function AnalyticsBeaconClient(opts) {
|
|
1206
1206
|
this.opts = opts;
|
|
1207
1207
|
}
|
|
1208
|
-
AnalyticsBeaconClient.prototype.sendEvent = function (eventType,
|
|
1208
|
+
AnalyticsBeaconClient.prototype.sendEvent = function (eventType, originalPayload) {
|
|
1209
1209
|
return __awaiter(this, void 0, void 0, function () {
|
|
1210
|
-
var _a, baseUrl, preprocessRequest,
|
|
1211
|
-
return __generator(this, function (
|
|
1212
|
-
switch (
|
|
1210
|
+
var _a, baseUrl, preprocessRequest, paramsFragments, _b, url, payload, parsedRequestData, body;
|
|
1211
|
+
return __generator(this, function (_c) {
|
|
1212
|
+
switch (_c.label) {
|
|
1213
1213
|
case 0:
|
|
1214
1214
|
if (!this.isAvailable()) {
|
|
1215
1215
|
throw new Error("navigator.sendBeacon is not supported in this browser. Consider adding a polyfill like \"sendbeacon-polyfill\".");
|
|
1216
1216
|
}
|
|
1217
1217
|
_a = this.opts, baseUrl = _a.baseUrl, preprocessRequest = _a.preprocessRequest;
|
|
1218
|
-
parsedRequestData = this.encodeForEventType(eventType, payload);
|
|
1219
1218
|
return [4, this.getQueryParamsForEventType(eventType)];
|
|
1220
1219
|
case 1:
|
|
1221
|
-
paramsFragments =
|
|
1222
|
-
|
|
1223
|
-
url: "".concat(baseUrl, "/analytics/").concat(eventType, "?").concat(paramsFragments),
|
|
1224
|
-
body: new Blob([parsedRequestData], {
|
|
1225
|
-
type: 'application/x-www-form-urlencoded',
|
|
1226
|
-
}),
|
|
1227
|
-
};
|
|
1228
|
-
_c = [__assign({}, defaultOptions)];
|
|
1229
|
-
if (!preprocessRequest) return [3, 3];
|
|
1230
|
-
return [4, preprocessRequest(defaultOptions, 'analyticsBeacon')];
|
|
1220
|
+
paramsFragments = _c.sent();
|
|
1221
|
+
return [4, this.preProcessRequestAsPotentialJSONString("".concat(baseUrl, "/analytics/").concat(eventType, "?").concat(paramsFragments), originalPayload, preprocessRequest)];
|
|
1231
1222
|
case 2:
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
case 4:
|
|
1238
|
-
_b = __assign.apply(void 0, _c.concat([(_d)])), url = _b.url, body = _b.body;
|
|
1223
|
+
_b = _c.sent(), url = _b.url, payload = _b.payload;
|
|
1224
|
+
parsedRequestData = this.encodeForEventType(eventType, payload);
|
|
1225
|
+
body = new Blob([parsedRequestData], {
|
|
1226
|
+
type: 'application/x-www-form-urlencoded',
|
|
1227
|
+
});
|
|
1239
1228
|
navigator.sendBeacon(url, body);
|
|
1240
1229
|
return [2];
|
|
1241
1230
|
}
|
|
@@ -1248,6 +1237,35 @@ var AnalyticsBeaconClient = (function () {
|
|
|
1248
1237
|
AnalyticsBeaconClient.prototype.deleteHttpCookieVisitorId = function () {
|
|
1249
1238
|
return Promise.resolve();
|
|
1250
1239
|
};
|
|
1240
|
+
AnalyticsBeaconClient.prototype.preProcessRequestAsPotentialJSONString = function (originalURL, originalPayload, preprocessRequest) {
|
|
1241
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1242
|
+
var returnedUrl, returnedPayload, processedRequest, processedURL, processedBody;
|
|
1243
|
+
return __generator(this, function (_a) {
|
|
1244
|
+
switch (_a.label) {
|
|
1245
|
+
case 0:
|
|
1246
|
+
returnedUrl = originalURL;
|
|
1247
|
+
returnedPayload = originalPayload;
|
|
1248
|
+
if (!preprocessRequest) return [3, 2];
|
|
1249
|
+
return [4, preprocessRequest({ url: originalURL, body: JSON.stringify(originalPayload) }, 'analyticsBeacon')];
|
|
1250
|
+
case 1:
|
|
1251
|
+
processedRequest = _a.sent();
|
|
1252
|
+
processedURL = processedRequest.url, processedBody = processedRequest.body;
|
|
1253
|
+
returnedUrl = processedURL || originalURL;
|
|
1254
|
+
try {
|
|
1255
|
+
returnedPayload = JSON.parse(processedBody);
|
|
1256
|
+
}
|
|
1257
|
+
catch (e) {
|
|
1258
|
+
console.error('Unable to process the request body as a JSON string', e);
|
|
1259
|
+
}
|
|
1260
|
+
_a.label = 2;
|
|
1261
|
+
case 2: return [2, {
|
|
1262
|
+
payload: returnedPayload,
|
|
1263
|
+
url: returnedUrl,
|
|
1264
|
+
}];
|
|
1265
|
+
}
|
|
1266
|
+
});
|
|
1267
|
+
});
|
|
1268
|
+
};
|
|
1251
1269
|
AnalyticsBeaconClient.prototype.encodeForEventType = function (eventType, payload) {
|
|
1252
1270
|
return this.isEventTypeLegacy(eventType)
|
|
1253
1271
|
? this.encodeForLegacyType(eventType, payload)
|