coveo.analytics 2.23.8 → 2.23.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.
- package/dist/coveoua.browser.js +1 -1
- package/dist/coveoua.browser.js.map +1 -1
- package/dist/coveoua.debug.js +28 -9
- 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/analytics.d.ts +1 -0
- package/dist/definitions/client/utils.d.ts +1 -0
- package/dist/library.es.js +27 -5
- package/dist/library.js +28 -9
- package/dist/react-native.es.js +27 -5
- package/package.json +1 -1
- package/src/client/analytics.ts +24 -12
- package/src/client/utils.ts +3 -0
- package/src/coveoua/plugins.ts +1 -1
- package/src/coveoua/simpleanalytics.spec.ts +207 -125
|
@@ -99,6 +99,7 @@ export declare class CoveoAnalyticsClient implements AnalyticsClient, VisitorIdP
|
|
|
99
99
|
private removeEmptyPayloadValues;
|
|
100
100
|
private removeUnknownParameters;
|
|
101
101
|
private processCustomParameters;
|
|
102
|
+
private mapCustomParametersToCustomData;
|
|
102
103
|
private lowercaseKeys;
|
|
103
104
|
private validateParams;
|
|
104
105
|
private ensureAnonymousUserWhenUsingApiKey;
|
package/dist/library.es.js
CHANGED
|
@@ -359,7 +359,10 @@ const getRandomValues = (rnds) => {
|
|
|
359
359
|
return rnds;
|
|
360
360
|
};
|
|
361
361
|
|
|
362
|
-
const keysOf = Object.keys;
|
|
362
|
+
const keysOf = Object.keys;
|
|
363
|
+
function isObject(o) {
|
|
364
|
+
return o !== null && typeof o === 'object' && !Array.isArray(o);
|
|
365
|
+
}
|
|
363
366
|
|
|
364
367
|
const ticketKeysMapping = {
|
|
365
368
|
id: 'svc_ticket_id',
|
|
@@ -912,7 +915,9 @@ class CoveoAnalyticsClient {
|
|
|
912
915
|
const validateParams = (currentPayload) => this.validateParams(currentPayload);
|
|
913
916
|
const processMeasurementProtocolConversionStep = (currentPayload) => usesMeasurementProtocol ? convertKeysToMeasurementProtocol(currentPayload) : currentPayload;
|
|
914
917
|
const removeUnknownParameters = (currentPayload) => usesMeasurementProtocol ? this.removeUnknownParameters(currentPayload) : currentPayload;
|
|
915
|
-
const processCustomParameters = (currentPayload) => usesMeasurementProtocol
|
|
918
|
+
const processCustomParameters = (currentPayload) => usesMeasurementProtocol
|
|
919
|
+
? this.processCustomParameters(currentPayload)
|
|
920
|
+
: this.mapCustomParametersToCustomData(currentPayload);
|
|
916
921
|
const payloadToSend = yield [
|
|
917
922
|
cleanPayloadStep,
|
|
918
923
|
validateParams,
|
|
@@ -1078,13 +1083,30 @@ class CoveoAnalyticsClient {
|
|
|
1078
1083
|
}
|
|
1079
1084
|
processCustomParameters(payload) {
|
|
1080
1085
|
const { custom } = payload, rest = __rest(payload, ["custom"]);
|
|
1081
|
-
|
|
1086
|
+
let lowercasedCustom = {};
|
|
1087
|
+
if (custom && isObject(custom)) {
|
|
1088
|
+
lowercasedCustom = this.lowercaseKeys(custom);
|
|
1089
|
+
}
|
|
1082
1090
|
const newPayload = convertCustomMeasurementProtocolKeys(rest);
|
|
1083
1091
|
return Object.assign(Object.assign({}, lowercasedCustom), newPayload);
|
|
1084
1092
|
}
|
|
1093
|
+
mapCustomParametersToCustomData(payload) {
|
|
1094
|
+
const { custom } = payload, rest = __rest(payload, ["custom"]);
|
|
1095
|
+
if (custom && isObject(custom)) {
|
|
1096
|
+
const lowercasedCustom = this.lowercaseKeys(custom);
|
|
1097
|
+
return Object.assign(Object.assign({}, rest), { customData: Object.assign(Object.assign({}, lowercasedCustom), payload.customData) });
|
|
1098
|
+
}
|
|
1099
|
+
else {
|
|
1100
|
+
return payload;
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1085
1103
|
lowercaseKeys(custom) {
|
|
1086
|
-
const keys = Object.keys(custom
|
|
1087
|
-
|
|
1104
|
+
const keys = Object.keys(custom);
|
|
1105
|
+
let result = {};
|
|
1106
|
+
keys.forEach((key) => {
|
|
1107
|
+
result[key.toLowerCase()] = custom[key];
|
|
1108
|
+
});
|
|
1109
|
+
return result;
|
|
1088
1110
|
}
|
|
1089
1111
|
validateParams(payload) {
|
|
1090
1112
|
const { anonymizeIp } = payload, rest = __rest(payload, ["anonymizeIp"]);
|
package/dist/library.js
CHANGED
|
@@ -506,7 +506,10 @@ var getRandomValues = function (rnds) {
|
|
|
506
506
|
return rnds;
|
|
507
507
|
};
|
|
508
508
|
|
|
509
|
-
var keysOf = Object.keys;
|
|
509
|
+
var keysOf = Object.keys;
|
|
510
|
+
function isObject(o) {
|
|
511
|
+
return o !== null && typeof o === 'object' && !Array.isArray(o);
|
|
512
|
+
}
|
|
510
513
|
|
|
511
514
|
var ticketKeysMapping = {
|
|
512
515
|
id: 'svc_ticket_id',
|
|
@@ -82808,7 +82811,9 @@ var CoveoAnalyticsClient = (function () {
|
|
|
82808
82811
|
return usesMeasurementProtocol ? _this.removeUnknownParameters(currentPayload) : currentPayload;
|
|
82809
82812
|
};
|
|
82810
82813
|
processCustomParameters = function (currentPayload) {
|
|
82811
|
-
return usesMeasurementProtocol
|
|
82814
|
+
return usesMeasurementProtocol
|
|
82815
|
+
? _this.processCustomParameters(currentPayload)
|
|
82816
|
+
: _this.mapCustomParametersToCustomData(currentPayload);
|
|
82812
82817
|
};
|
|
82813
82818
|
return [4, [
|
|
82814
82819
|
cleanPayloadStep,
|
|
@@ -83078,16 +83083,30 @@ var CoveoAnalyticsClient = (function () {
|
|
|
83078
83083
|
};
|
|
83079
83084
|
CoveoAnalyticsClient.prototype.processCustomParameters = function (payload) {
|
|
83080
83085
|
var custom = payload.custom, rest = __rest(payload, ["custom"]);
|
|
83081
|
-
var lowercasedCustom =
|
|
83086
|
+
var lowercasedCustom = {};
|
|
83087
|
+
if (custom && isObject(custom)) {
|
|
83088
|
+
lowercasedCustom = this.lowercaseKeys(custom);
|
|
83089
|
+
}
|
|
83082
83090
|
var newPayload = convertCustomMeasurementProtocolKeys(rest);
|
|
83083
83091
|
return __assign(__assign({}, lowercasedCustom), newPayload);
|
|
83084
83092
|
};
|
|
83093
|
+
CoveoAnalyticsClient.prototype.mapCustomParametersToCustomData = function (payload) {
|
|
83094
|
+
var custom = payload.custom, rest = __rest(payload, ["custom"]);
|
|
83095
|
+
if (custom && isObject(custom)) {
|
|
83096
|
+
var lowercasedCustom = this.lowercaseKeys(custom);
|
|
83097
|
+
return __assign(__assign({}, rest), { customData: __assign(__assign({}, lowercasedCustom), payload.customData) });
|
|
83098
|
+
}
|
|
83099
|
+
else {
|
|
83100
|
+
return payload;
|
|
83101
|
+
}
|
|
83102
|
+
};
|
|
83085
83103
|
CoveoAnalyticsClient.prototype.lowercaseKeys = function (custom) {
|
|
83086
|
-
var keys = Object.keys(custom
|
|
83087
|
-
|
|
83088
|
-
|
|
83089
|
-
|
|
83090
|
-
}
|
|
83104
|
+
var keys = Object.keys(custom);
|
|
83105
|
+
var result = {};
|
|
83106
|
+
keys.forEach(function (key) {
|
|
83107
|
+
result[key.toLowerCase()] = custom[key];
|
|
83108
|
+
});
|
|
83109
|
+
return result;
|
|
83091
83110
|
};
|
|
83092
83111
|
CoveoAnalyticsClient.prototype.validateParams = function (payload) {
|
|
83093
83112
|
var anonymizeIp = payload.anonymizeIp, rest = __rest(payload, ["anonymizeIp"]);
|
|
@@ -83450,7 +83469,7 @@ var Plugins = (function () {
|
|
|
83450
83469
|
}
|
|
83451
83470
|
var actionFunction = plugin[fn];
|
|
83452
83471
|
if (!actionFunction) {
|
|
83453
|
-
throw new Error("The function \"" + fn + "\" does not
|
|
83472
|
+
throw new Error("The function \"" + fn + "\" does not exist on the plugin \"" + name + "\".");
|
|
83454
83473
|
}
|
|
83455
83474
|
if (typeof actionFunction !== 'function') {
|
|
83456
83475
|
throw new Error("\"" + fn + "\" of the plugin \"" + name + "\" is not a function.");
|
package/dist/react-native.es.js
CHANGED
|
@@ -420,7 +420,10 @@ const addPageViewToHistory = (pageViewValue) => __awaiter(void 0, void 0, void 0
|
|
|
420
420
|
yield store.addElementAsync(historyElement);
|
|
421
421
|
});
|
|
422
422
|
|
|
423
|
-
const keysOf = Object.keys;
|
|
423
|
+
const keysOf = Object.keys;
|
|
424
|
+
function isObject(o) {
|
|
425
|
+
return o !== null && typeof o === 'object' && !Array.isArray(o);
|
|
426
|
+
}
|
|
424
427
|
|
|
425
428
|
const ticketKeysMapping = {
|
|
426
429
|
id: 'svc_ticket_id',
|
|
@@ -912,7 +915,9 @@ class CoveoAnalyticsClient {
|
|
|
912
915
|
const validateParams = (currentPayload) => this.validateParams(currentPayload);
|
|
913
916
|
const processMeasurementProtocolConversionStep = (currentPayload) => usesMeasurementProtocol ? convertKeysToMeasurementProtocol(currentPayload) : currentPayload;
|
|
914
917
|
const removeUnknownParameters = (currentPayload) => usesMeasurementProtocol ? this.removeUnknownParameters(currentPayload) : currentPayload;
|
|
915
|
-
const processCustomParameters = (currentPayload) => usesMeasurementProtocol
|
|
918
|
+
const processCustomParameters = (currentPayload) => usesMeasurementProtocol
|
|
919
|
+
? this.processCustomParameters(currentPayload)
|
|
920
|
+
: this.mapCustomParametersToCustomData(currentPayload);
|
|
916
921
|
const payloadToSend = yield [
|
|
917
922
|
cleanPayloadStep,
|
|
918
923
|
validateParams,
|
|
@@ -1078,13 +1083,30 @@ class CoveoAnalyticsClient {
|
|
|
1078
1083
|
}
|
|
1079
1084
|
processCustomParameters(payload) {
|
|
1080
1085
|
const { custom } = payload, rest = __rest(payload, ["custom"]);
|
|
1081
|
-
|
|
1086
|
+
let lowercasedCustom = {};
|
|
1087
|
+
if (custom && isObject(custom)) {
|
|
1088
|
+
lowercasedCustom = this.lowercaseKeys(custom);
|
|
1089
|
+
}
|
|
1082
1090
|
const newPayload = convertCustomMeasurementProtocolKeys(rest);
|
|
1083
1091
|
return Object.assign(Object.assign({}, lowercasedCustom), newPayload);
|
|
1084
1092
|
}
|
|
1093
|
+
mapCustomParametersToCustomData(payload) {
|
|
1094
|
+
const { custom } = payload, rest = __rest(payload, ["custom"]);
|
|
1095
|
+
if (custom && isObject(custom)) {
|
|
1096
|
+
const lowercasedCustom = this.lowercaseKeys(custom);
|
|
1097
|
+
return Object.assign(Object.assign({}, rest), { customData: Object.assign(Object.assign({}, lowercasedCustom), payload.customData) });
|
|
1098
|
+
}
|
|
1099
|
+
else {
|
|
1100
|
+
return payload;
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1085
1103
|
lowercaseKeys(custom) {
|
|
1086
|
-
const keys = Object.keys(custom
|
|
1087
|
-
|
|
1104
|
+
const keys = Object.keys(custom);
|
|
1105
|
+
let result = {};
|
|
1106
|
+
keys.forEach((key) => {
|
|
1107
|
+
result[key.toLowerCase()] = custom[key];
|
|
1108
|
+
});
|
|
1109
|
+
return result;
|
|
1088
1110
|
}
|
|
1089
1111
|
validateParams(payload) {
|
|
1090
1112
|
const { anonymizeIp } = payload, rest = __rest(payload, ["anonymizeIp"]);
|
package/package.json
CHANGED
package/src/client/analytics.ts
CHANGED
|
@@ -34,6 +34,7 @@ import {isApiKey} from './token';
|
|
|
34
34
|
import {isReactNative, ReactNativeRuntimeWarning} from '../react-native/react-native-utils';
|
|
35
35
|
import {doNotTrack} from '../donottrack';
|
|
36
36
|
import {NullStorage} from '../storage';
|
|
37
|
+
import {isObject} from './utils';
|
|
37
38
|
|
|
38
39
|
export const Version = 'v15';
|
|
39
40
|
|
|
@@ -294,7 +295,9 @@ export class CoveoAnalyticsClient implements AnalyticsClient, VisitorIdProvider
|
|
|
294
295
|
const removeUnknownParameters: ProcessPayloadStep = (currentPayload) =>
|
|
295
296
|
usesMeasurementProtocol ? this.removeUnknownParameters(currentPayload) : currentPayload;
|
|
296
297
|
const processCustomParameters: ProcessPayloadStep = (currentPayload) =>
|
|
297
|
-
usesMeasurementProtocol
|
|
298
|
+
usesMeasurementProtocol
|
|
299
|
+
? this.processCustomParameters(currentPayload)
|
|
300
|
+
: this.mapCustomParametersToCustomData(currentPayload);
|
|
298
301
|
|
|
299
302
|
const payloadToSend = await [
|
|
300
303
|
cleanPayloadStep,
|
|
@@ -489,8 +492,10 @@ export class CoveoAnalyticsClient implements AnalyticsClient, VisitorIdProvider
|
|
|
489
492
|
|
|
490
493
|
private processCustomParameters(payload: IRequestPayload): IRequestPayload {
|
|
491
494
|
const {custom, ...rest} = payload;
|
|
492
|
-
|
|
493
|
-
|
|
495
|
+
let lowercasedCustom = {};
|
|
496
|
+
if (custom && isObject(custom)) {
|
|
497
|
+
lowercasedCustom = this.lowercaseKeys(custom);
|
|
498
|
+
}
|
|
494
499
|
|
|
495
500
|
const newPayload = convertCustomMeasurementProtocolKeys(rest);
|
|
496
501
|
|
|
@@ -500,16 +505,23 @@ export class CoveoAnalyticsClient implements AnalyticsClient, VisitorIdProvider
|
|
|
500
505
|
};
|
|
501
506
|
}
|
|
502
507
|
|
|
503
|
-
private
|
|
504
|
-
const
|
|
508
|
+
private mapCustomParametersToCustomData(payload: IRequestPayload): IRequestPayload {
|
|
509
|
+
const {custom, ...rest} = payload;
|
|
510
|
+
if (custom && isObject(custom)) {
|
|
511
|
+
const lowercasedCustom = this.lowercaseKeys(custom);
|
|
512
|
+
return {...rest, customData: {...lowercasedCustom, ...payload.customData}};
|
|
513
|
+
} else {
|
|
514
|
+
return payload;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
505
517
|
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
518
|
+
private lowercaseKeys(custom: Record<string, unknown>) {
|
|
519
|
+
const keys = Object.keys(custom);
|
|
520
|
+
let result: Record<string, unknown> = {};
|
|
521
|
+
keys.forEach((key) => {
|
|
522
|
+
result[key.toLowerCase() as string] = custom[key];
|
|
523
|
+
});
|
|
524
|
+
return result;
|
|
513
525
|
}
|
|
514
526
|
|
|
515
527
|
private validateParams(payload: IRequestPayload): IRequestPayload {
|
package/src/client/utils.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
// Object.keys returns `string[]` this adds types
|
|
2
2
|
// see https://github.com/microsoft/TypeScript/pull/12253#issuecomment-393954723
|
|
3
3
|
export const keysOf = Object.keys as <T>(o: T) => Extract<keyof T, string>[];
|
|
4
|
+
export function isObject(o: any): boolean {
|
|
5
|
+
return o !== null && typeof o === 'object' && !Array.isArray(o);
|
|
6
|
+
}
|
package/src/coveoua/plugins.ts
CHANGED
|
@@ -38,7 +38,7 @@ export class Plugins {
|
|
|
38
38
|
}
|
|
39
39
|
const actionFunction = plugin[fn];
|
|
40
40
|
if (!actionFunction) {
|
|
41
|
-
throw new Error(`The function "${fn}" does not
|
|
41
|
+
throw new Error(`The function "${fn}" does not exist on the plugin "${name}".`);
|
|
42
42
|
}
|
|
43
43
|
if (typeof actionFunction !== 'function') {
|
|
44
44
|
throw new Error(`"${fn}" of the plugin "${name}" is not a function.`);
|