@uniformdev/context 19.177.1 → 19.178.0
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/index.esm.js +60 -76
- package/dist/index.js +60 -76
- package/dist/index.mjs +60 -76
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
@@ -651,75 +651,66 @@ function personalizeVariations({
|
|
651
651
|
take = 1,
|
652
652
|
onLogMessage
|
653
653
|
}) {
|
654
|
-
var _a, _b, _c
|
654
|
+
var _a, _b, _c;
|
655
655
|
onLogMessage == null ? void 0 : onLogMessage(["info", 300, "GROUP", { name, take }]);
|
656
656
|
try {
|
657
|
-
const
|
658
|
-
const results = [];
|
659
|
-
let personalized = false;
|
660
|
-
const scores = context.scores;
|
661
|
-
let index = 0;
|
657
|
+
const variantMatches = [];
|
662
658
|
const defaultVariants = [];
|
663
659
|
for (const variant of variations) {
|
664
|
-
if (
|
660
|
+
if ((_a = variant.pz) == null ? void 0 : _a.crit.length) {
|
661
|
+
if (variantMatches.length !== take && evaluateVariantMatch(variant.id, variant.pz, context.scores, onLogMessage)) {
|
662
|
+
variantMatches.push(variant);
|
663
|
+
}
|
664
|
+
} else {
|
665
665
|
defaultVariants.push(variant);
|
666
666
|
}
|
667
667
|
}
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
}
|
684
|
-
if (control) {
|
685
|
-
continue;
|
686
|
-
}
|
687
|
-
if (evaluateVariantMatch(variant.id, variant.pz, scores, onLogMessage)) {
|
688
|
-
let variantToAdd = variant;
|
689
|
-
let isControl = false;
|
690
|
-
const isDefault = defaultVariants.find((v) => v.id === variant.id);
|
691
|
-
if (take === 1 && !isDefault && defaultVariants.length && typeof variant.pz.control === "number") {
|
692
|
-
isControl = context.getPersonalizeVariantControl(name, currentIndex);
|
693
|
-
if (typeof isControl === "undefined") {
|
694
|
-
isControl = rollForControlGroup(variant.pz.control);
|
695
|
-
context.storage.updateData([
|
696
|
-
{
|
697
|
-
type: "setpersonalizecontrol",
|
698
|
-
data: {
|
699
|
-
personlizationName: name,
|
700
|
-
index: currentIndex,
|
701
|
-
control: isControl
|
702
|
-
}
|
668
|
+
const result = [];
|
669
|
+
for (let i = 0; i < variantMatches.length; i++) {
|
670
|
+
let isControl = (_b = context.storage.data.controlGroup) != null ? _b : false;
|
671
|
+
const variant = variantMatches[i];
|
672
|
+
if (!isControl && typeof ((_c = variant.pz) == null ? void 0 : _c.control) === "number") {
|
673
|
+
isControl = context.getPersonalizeVariantControl(name, i);
|
674
|
+
if (typeof isControl === "undefined") {
|
675
|
+
isControl = rollForControlGroup(variant.pz.control);
|
676
|
+
context.storage.updateData([
|
677
|
+
{
|
678
|
+
type: "setpersonalizecontrol",
|
679
|
+
data: {
|
680
|
+
personlizationName: name,
|
681
|
+
index: i,
|
682
|
+
control: isControl
|
703
683
|
}
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
684
|
+
}
|
685
|
+
]);
|
686
|
+
}
|
687
|
+
}
|
688
|
+
let variantToAdd = variant;
|
689
|
+
if (isControl) {
|
690
|
+
const defaultReplacement = defaultVariants.shift();
|
691
|
+
if (defaultReplacement) {
|
692
|
+
variantToAdd = {
|
693
|
+
...defaultReplacement,
|
694
|
+
id: variant.id
|
695
|
+
};
|
696
|
+
} else {
|
697
|
+
variantToAdd = void 0;
|
712
698
|
}
|
713
|
-
personalized = personalized || typeof variantToAdd.pz !== "undefined";
|
714
|
-
results.push({
|
715
|
-
...variantToAdd,
|
716
|
-
control: isControl
|
717
|
-
});
|
718
699
|
}
|
700
|
+
if (variantToAdd) {
|
701
|
+
result.push({ ...variantToAdd, control: isControl });
|
702
|
+
}
|
703
|
+
}
|
704
|
+
while (result.length < take && defaultVariants.length) {
|
705
|
+
result.push({ ...defaultVariants.shift(), control: false });
|
719
706
|
}
|
707
|
+
const personalized = result.some((v) => {
|
708
|
+
var _a2;
|
709
|
+
return (_a2 = v.pz) == null ? void 0 : _a2.crit.length;
|
710
|
+
});
|
720
711
|
return {
|
721
712
|
personalized,
|
722
|
-
variations:
|
713
|
+
variations: result
|
723
714
|
};
|
724
715
|
} finally {
|
725
716
|
onLogMessage == null ? void 0 : onLogMessage(["info", 300, "ENDGROUP"]);
|
@@ -1141,7 +1132,7 @@ import mitt2 from "mitt";
|
|
1141
1132
|
// src/storage/util/applyCommandsToData.ts
|
1142
1133
|
import rfdc from "rfdc";
|
1143
1134
|
var clone = rfdc();
|
1144
|
-
function applyCommandsToData(commands, state
|
1135
|
+
function applyCommandsToData(commands, state) {
|
1145
1136
|
const newData = state ? clone(state) : emptyVisitorData();
|
1146
1137
|
commands.forEach((command) => {
|
1147
1138
|
var _a, _b, _c;
|
@@ -1156,7 +1147,6 @@ function applyCommandsToData(commands, state, inControlGroup) {
|
|
1156
1147
|
newData.tests[command.data.test] = command.data.variant;
|
1157
1148
|
break;
|
1158
1149
|
case "modscore":
|
1159
|
-
if (inControlGroup) break;
|
1160
1150
|
const delta = Number(command.data.delta);
|
1161
1151
|
if (isNaN(delta)) {
|
1162
1152
|
throw new Error("Non-number delta received");
|
@@ -1165,7 +1155,6 @@ function applyCommandsToData(commands, state, inControlGroup) {
|
|
1165
1155
|
newData.scores[command.data.dimension] = existing + delta;
|
1166
1156
|
break;
|
1167
1157
|
case "modscoreS":
|
1168
|
-
if (inControlGroup) break;
|
1169
1158
|
const deltaS = Number(command.data.delta);
|
1170
1159
|
if (isNaN(deltaS)) {
|
1171
1160
|
throw new Error("Non-number delta received");
|
@@ -1322,17 +1311,17 @@ var VisitorDataStore = class {
|
|
1322
1311
|
}
|
1323
1312
|
/** Push data update command(s) into the visitor data */
|
1324
1313
|
async updateData(commands) {
|
1325
|
-
var _a, _b, _c
|
1314
|
+
var _a, _b, _c;
|
1326
1315
|
if (commands.length === 0) {
|
1327
1316
|
return;
|
1328
1317
|
}
|
1329
1318
|
(_b = (_a = __privateGet(this, _options)).onLogMessage) == null ? void 0 : _b.call(_a, ["debug", 101, commands]);
|
1330
|
-
const newData = applyCommandsToData(commands, this.data
|
1319
|
+
const newData = applyCommandsToData(commands, this.data);
|
1331
1320
|
if (commands.some((c) => c.type === "consent" && !c.data)) {
|
1332
1321
|
__privateGet(this, _persist).delete(STORAGE_KEY, true);
|
1333
1322
|
}
|
1334
1323
|
__privateMethod(this, _VisitorDataStore_instances, replaceData_fn).call(this, newData);
|
1335
|
-
await ((
|
1324
|
+
await ((_c = __privateGet(this, _options).transitionStore) == null ? void 0 : _c.updateData(commands, __privateGet(this, _VisitorDataStore_instances, currentData_get).visitorData));
|
1336
1325
|
__privateGet(this, _mitt2).emit("commandsExecuted", commands);
|
1337
1326
|
}
|
1338
1327
|
/**
|
@@ -1369,20 +1358,15 @@ replaceData_fn = function(data, quiet = false) {
|
|
1369
1358
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
1370
1359
|
const oldData = __privateGet(this, _VisitorDataStore_instances, currentData_get);
|
1371
1360
|
const now = Date.now();
|
1372
|
-
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1376
|
-
|
1377
|
-
|
1378
|
-
|
1379
|
-
|
1380
|
-
|
1381
|
-
scores: data.scores,
|
1382
|
-
sessionScores: data.sessionScores,
|
1383
|
-
onLogMessage: __privateGet(this, _options).onLogMessage
|
1384
|
-
});
|
1385
|
-
}
|
1361
|
+
__privateMethod(this, _VisitorDataStore_instances, handleCaps_fn).call(this, data.scores);
|
1362
|
+
__privateMethod(this, _VisitorDataStore_instances, handleCaps_fn).call(this, data.sessionScores);
|
1363
|
+
(_b = (_a = __privateGet(this, _options)).decay) == null ? void 0 : _b.call(_a, {
|
1364
|
+
now,
|
1365
|
+
lastUpd: oldData == null ? void 0 : oldData.updated,
|
1366
|
+
scores: data.scores,
|
1367
|
+
sessionScores: data.sessionScores,
|
1368
|
+
onLogMessage: __privateGet(this, _options).onLogMessage
|
1369
|
+
});
|
1386
1370
|
const haveScoresChanged = !dequal4(oldData == null ? void 0 : oldData.visitorData.scores, data.scores);
|
1387
1371
|
const haveSessionScoresChanged = !dequal4(oldData == null ? void 0 : oldData.visitorData.sessionScores, data.sessionScores);
|
1388
1372
|
const haveQuirksChanged = !dequal4(oldData == null ? void 0 : oldData.visitorData.quirks, data.quirks);
|
package/dist/index.js
CHANGED
@@ -723,75 +723,66 @@ function personalizeVariations({
|
|
723
723
|
take = 1,
|
724
724
|
onLogMessage
|
725
725
|
}) {
|
726
|
-
var _a, _b, _c
|
726
|
+
var _a, _b, _c;
|
727
727
|
onLogMessage == null ? void 0 : onLogMessage(["info", 300, "GROUP", { name, take }]);
|
728
728
|
try {
|
729
|
-
const
|
730
|
-
const results = [];
|
731
|
-
let personalized = false;
|
732
|
-
const scores = context.scores;
|
733
|
-
let index = 0;
|
729
|
+
const variantMatches = [];
|
734
730
|
const defaultVariants = [];
|
735
731
|
for (const variant of variations) {
|
736
|
-
if (
|
732
|
+
if ((_a = variant.pz) == null ? void 0 : _a.crit.length) {
|
733
|
+
if (variantMatches.length !== take && evaluateVariantMatch(variant.id, variant.pz, context.scores, onLogMessage)) {
|
734
|
+
variantMatches.push(variant);
|
735
|
+
}
|
736
|
+
} else {
|
737
737
|
defaultVariants.push(variant);
|
738
738
|
}
|
739
739
|
}
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
}
|
756
|
-
if (control) {
|
757
|
-
continue;
|
758
|
-
}
|
759
|
-
if (evaluateVariantMatch(variant.id, variant.pz, scores, onLogMessage)) {
|
760
|
-
let variantToAdd = variant;
|
761
|
-
let isControl = false;
|
762
|
-
const isDefault = defaultVariants.find((v) => v.id === variant.id);
|
763
|
-
if (take === 1 && !isDefault && defaultVariants.length && typeof variant.pz.control === "number") {
|
764
|
-
isControl = context.getPersonalizeVariantControl(name, currentIndex);
|
765
|
-
if (typeof isControl === "undefined") {
|
766
|
-
isControl = rollForControlGroup(variant.pz.control);
|
767
|
-
context.storage.updateData([
|
768
|
-
{
|
769
|
-
type: "setpersonalizecontrol",
|
770
|
-
data: {
|
771
|
-
personlizationName: name,
|
772
|
-
index: currentIndex,
|
773
|
-
control: isControl
|
774
|
-
}
|
740
|
+
const result = [];
|
741
|
+
for (let i = 0; i < variantMatches.length; i++) {
|
742
|
+
let isControl = (_b = context.storage.data.controlGroup) != null ? _b : false;
|
743
|
+
const variant = variantMatches[i];
|
744
|
+
if (!isControl && typeof ((_c = variant.pz) == null ? void 0 : _c.control) === "number") {
|
745
|
+
isControl = context.getPersonalizeVariantControl(name, i);
|
746
|
+
if (typeof isControl === "undefined") {
|
747
|
+
isControl = rollForControlGroup(variant.pz.control);
|
748
|
+
context.storage.updateData([
|
749
|
+
{
|
750
|
+
type: "setpersonalizecontrol",
|
751
|
+
data: {
|
752
|
+
personlizationName: name,
|
753
|
+
index: i,
|
754
|
+
control: isControl
|
775
755
|
}
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
756
|
+
}
|
757
|
+
]);
|
758
|
+
}
|
759
|
+
}
|
760
|
+
let variantToAdd = variant;
|
761
|
+
if (isControl) {
|
762
|
+
const defaultReplacement = defaultVariants.shift();
|
763
|
+
if (defaultReplacement) {
|
764
|
+
variantToAdd = {
|
765
|
+
...defaultReplacement,
|
766
|
+
id: variant.id
|
767
|
+
};
|
768
|
+
} else {
|
769
|
+
variantToAdd = void 0;
|
784
770
|
}
|
785
|
-
personalized = personalized || typeof variantToAdd.pz !== "undefined";
|
786
|
-
results.push({
|
787
|
-
...variantToAdd,
|
788
|
-
control: isControl
|
789
|
-
});
|
790
771
|
}
|
772
|
+
if (variantToAdd) {
|
773
|
+
result.push({ ...variantToAdd, control: isControl });
|
774
|
+
}
|
775
|
+
}
|
776
|
+
while (result.length < take && defaultVariants.length) {
|
777
|
+
result.push({ ...defaultVariants.shift(), control: false });
|
791
778
|
}
|
779
|
+
const personalized = result.some((v) => {
|
780
|
+
var _a2;
|
781
|
+
return (_a2 = v.pz) == null ? void 0 : _a2.crit.length;
|
782
|
+
});
|
792
783
|
return {
|
793
784
|
personalized,
|
794
|
-
variations:
|
785
|
+
variations: result
|
795
786
|
};
|
796
787
|
} finally {
|
797
788
|
onLogMessage == null ? void 0 : onLogMessage(["info", 300, "ENDGROUP"]);
|
@@ -1213,7 +1204,7 @@ var import_mitt2 = __toESM(require("mitt"));
|
|
1213
1204
|
// src/storage/util/applyCommandsToData.ts
|
1214
1205
|
var import_rfdc = __toESM(require("rfdc"));
|
1215
1206
|
var clone = (0, import_rfdc.default)();
|
1216
|
-
function applyCommandsToData(commands, state
|
1207
|
+
function applyCommandsToData(commands, state) {
|
1217
1208
|
const newData = state ? clone(state) : emptyVisitorData();
|
1218
1209
|
commands.forEach((command) => {
|
1219
1210
|
var _a, _b, _c;
|
@@ -1228,7 +1219,6 @@ function applyCommandsToData(commands, state, inControlGroup) {
|
|
1228
1219
|
newData.tests[command.data.test] = command.data.variant;
|
1229
1220
|
break;
|
1230
1221
|
case "modscore":
|
1231
|
-
if (inControlGroup) break;
|
1232
1222
|
const delta = Number(command.data.delta);
|
1233
1223
|
if (isNaN(delta)) {
|
1234
1224
|
throw new Error("Non-number delta received");
|
@@ -1237,7 +1227,6 @@ function applyCommandsToData(commands, state, inControlGroup) {
|
|
1237
1227
|
newData.scores[command.data.dimension] = existing + delta;
|
1238
1228
|
break;
|
1239
1229
|
case "modscoreS":
|
1240
|
-
if (inControlGroup) break;
|
1241
1230
|
const deltaS = Number(command.data.delta);
|
1242
1231
|
if (isNaN(deltaS)) {
|
1243
1232
|
throw new Error("Non-number delta received");
|
@@ -1394,17 +1383,17 @@ var VisitorDataStore = class {
|
|
1394
1383
|
}
|
1395
1384
|
/** Push data update command(s) into the visitor data */
|
1396
1385
|
async updateData(commands) {
|
1397
|
-
var _a, _b, _c
|
1386
|
+
var _a, _b, _c;
|
1398
1387
|
if (commands.length === 0) {
|
1399
1388
|
return;
|
1400
1389
|
}
|
1401
1390
|
(_b = (_a = __privateGet(this, _options)).onLogMessage) == null ? void 0 : _b.call(_a, ["debug", 101, commands]);
|
1402
|
-
const newData = applyCommandsToData(commands, this.data
|
1391
|
+
const newData = applyCommandsToData(commands, this.data);
|
1403
1392
|
if (commands.some((c) => c.type === "consent" && !c.data)) {
|
1404
1393
|
__privateGet(this, _persist).delete(STORAGE_KEY, true);
|
1405
1394
|
}
|
1406
1395
|
__privateMethod(this, _VisitorDataStore_instances, replaceData_fn).call(this, newData);
|
1407
|
-
await ((
|
1396
|
+
await ((_c = __privateGet(this, _options).transitionStore) == null ? void 0 : _c.updateData(commands, __privateGet(this, _VisitorDataStore_instances, currentData_get).visitorData));
|
1408
1397
|
__privateGet(this, _mitt2).emit("commandsExecuted", commands);
|
1409
1398
|
}
|
1410
1399
|
/**
|
@@ -1441,20 +1430,15 @@ replaceData_fn = function(data, quiet = false) {
|
|
1441
1430
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
1442
1431
|
const oldData = __privateGet(this, _VisitorDataStore_instances, currentData_get);
|
1443
1432
|
const now = Date.now();
|
1444
|
-
|
1445
|
-
|
1446
|
-
|
1447
|
-
|
1448
|
-
|
1449
|
-
|
1450
|
-
|
1451
|
-
|
1452
|
-
|
1453
|
-
scores: data.scores,
|
1454
|
-
sessionScores: data.sessionScores,
|
1455
|
-
onLogMessage: __privateGet(this, _options).onLogMessage
|
1456
|
-
});
|
1457
|
-
}
|
1433
|
+
__privateMethod(this, _VisitorDataStore_instances, handleCaps_fn).call(this, data.scores);
|
1434
|
+
__privateMethod(this, _VisitorDataStore_instances, handleCaps_fn).call(this, data.sessionScores);
|
1435
|
+
(_b = (_a = __privateGet(this, _options)).decay) == null ? void 0 : _b.call(_a, {
|
1436
|
+
now,
|
1437
|
+
lastUpd: oldData == null ? void 0 : oldData.updated,
|
1438
|
+
scores: data.scores,
|
1439
|
+
sessionScores: data.sessionScores,
|
1440
|
+
onLogMessage: __privateGet(this, _options).onLogMessage
|
1441
|
+
});
|
1458
1442
|
const haveScoresChanged = !(0, import_lite4.dequal)(oldData == null ? void 0 : oldData.visitorData.scores, data.scores);
|
1459
1443
|
const haveSessionScoresChanged = !(0, import_lite4.dequal)(oldData == null ? void 0 : oldData.visitorData.sessionScores, data.sessionScores);
|
1460
1444
|
const haveQuirksChanged = !(0, import_lite4.dequal)(oldData == null ? void 0 : oldData.visitorData.quirks, data.quirks);
|
package/dist/index.mjs
CHANGED
@@ -651,75 +651,66 @@ function personalizeVariations({
|
|
651
651
|
take = 1,
|
652
652
|
onLogMessage
|
653
653
|
}) {
|
654
|
-
var _a, _b, _c
|
654
|
+
var _a, _b, _c;
|
655
655
|
onLogMessage == null ? void 0 : onLogMessage(["info", 300, "GROUP", { name, take }]);
|
656
656
|
try {
|
657
|
-
const
|
658
|
-
const results = [];
|
659
|
-
let personalized = false;
|
660
|
-
const scores = context.scores;
|
661
|
-
let index = 0;
|
657
|
+
const variantMatches = [];
|
662
658
|
const defaultVariants = [];
|
663
659
|
for (const variant of variations) {
|
664
|
-
if (
|
660
|
+
if ((_a = variant.pz) == null ? void 0 : _a.crit.length) {
|
661
|
+
if (variantMatches.length !== take && evaluateVariantMatch(variant.id, variant.pz, context.scores, onLogMessage)) {
|
662
|
+
variantMatches.push(variant);
|
663
|
+
}
|
664
|
+
} else {
|
665
665
|
defaultVariants.push(variant);
|
666
666
|
}
|
667
667
|
}
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
}
|
684
|
-
if (control) {
|
685
|
-
continue;
|
686
|
-
}
|
687
|
-
if (evaluateVariantMatch(variant.id, variant.pz, scores, onLogMessage)) {
|
688
|
-
let variantToAdd = variant;
|
689
|
-
let isControl = false;
|
690
|
-
const isDefault = defaultVariants.find((v) => v.id === variant.id);
|
691
|
-
if (take === 1 && !isDefault && defaultVariants.length && typeof variant.pz.control === "number") {
|
692
|
-
isControl = context.getPersonalizeVariantControl(name, currentIndex);
|
693
|
-
if (typeof isControl === "undefined") {
|
694
|
-
isControl = rollForControlGroup(variant.pz.control);
|
695
|
-
context.storage.updateData([
|
696
|
-
{
|
697
|
-
type: "setpersonalizecontrol",
|
698
|
-
data: {
|
699
|
-
personlizationName: name,
|
700
|
-
index: currentIndex,
|
701
|
-
control: isControl
|
702
|
-
}
|
668
|
+
const result = [];
|
669
|
+
for (let i = 0; i < variantMatches.length; i++) {
|
670
|
+
let isControl = (_b = context.storage.data.controlGroup) != null ? _b : false;
|
671
|
+
const variant = variantMatches[i];
|
672
|
+
if (!isControl && typeof ((_c = variant.pz) == null ? void 0 : _c.control) === "number") {
|
673
|
+
isControl = context.getPersonalizeVariantControl(name, i);
|
674
|
+
if (typeof isControl === "undefined") {
|
675
|
+
isControl = rollForControlGroup(variant.pz.control);
|
676
|
+
context.storage.updateData([
|
677
|
+
{
|
678
|
+
type: "setpersonalizecontrol",
|
679
|
+
data: {
|
680
|
+
personlizationName: name,
|
681
|
+
index: i,
|
682
|
+
control: isControl
|
703
683
|
}
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
684
|
+
}
|
685
|
+
]);
|
686
|
+
}
|
687
|
+
}
|
688
|
+
let variantToAdd = variant;
|
689
|
+
if (isControl) {
|
690
|
+
const defaultReplacement = defaultVariants.shift();
|
691
|
+
if (defaultReplacement) {
|
692
|
+
variantToAdd = {
|
693
|
+
...defaultReplacement,
|
694
|
+
id: variant.id
|
695
|
+
};
|
696
|
+
} else {
|
697
|
+
variantToAdd = void 0;
|
712
698
|
}
|
713
|
-
personalized = personalized || typeof variantToAdd.pz !== "undefined";
|
714
|
-
results.push({
|
715
|
-
...variantToAdd,
|
716
|
-
control: isControl
|
717
|
-
});
|
718
699
|
}
|
700
|
+
if (variantToAdd) {
|
701
|
+
result.push({ ...variantToAdd, control: isControl });
|
702
|
+
}
|
703
|
+
}
|
704
|
+
while (result.length < take && defaultVariants.length) {
|
705
|
+
result.push({ ...defaultVariants.shift(), control: false });
|
719
706
|
}
|
707
|
+
const personalized = result.some((v) => {
|
708
|
+
var _a2;
|
709
|
+
return (_a2 = v.pz) == null ? void 0 : _a2.crit.length;
|
710
|
+
});
|
720
711
|
return {
|
721
712
|
personalized,
|
722
|
-
variations:
|
713
|
+
variations: result
|
723
714
|
};
|
724
715
|
} finally {
|
725
716
|
onLogMessage == null ? void 0 : onLogMessage(["info", 300, "ENDGROUP"]);
|
@@ -1141,7 +1132,7 @@ import mitt2 from "mitt";
|
|
1141
1132
|
// src/storage/util/applyCommandsToData.ts
|
1142
1133
|
import rfdc from "rfdc";
|
1143
1134
|
var clone = rfdc();
|
1144
|
-
function applyCommandsToData(commands, state
|
1135
|
+
function applyCommandsToData(commands, state) {
|
1145
1136
|
const newData = state ? clone(state) : emptyVisitorData();
|
1146
1137
|
commands.forEach((command) => {
|
1147
1138
|
var _a, _b, _c;
|
@@ -1156,7 +1147,6 @@ function applyCommandsToData(commands, state, inControlGroup) {
|
|
1156
1147
|
newData.tests[command.data.test] = command.data.variant;
|
1157
1148
|
break;
|
1158
1149
|
case "modscore":
|
1159
|
-
if (inControlGroup) break;
|
1160
1150
|
const delta = Number(command.data.delta);
|
1161
1151
|
if (isNaN(delta)) {
|
1162
1152
|
throw new Error("Non-number delta received");
|
@@ -1165,7 +1155,6 @@ function applyCommandsToData(commands, state, inControlGroup) {
|
|
1165
1155
|
newData.scores[command.data.dimension] = existing + delta;
|
1166
1156
|
break;
|
1167
1157
|
case "modscoreS":
|
1168
|
-
if (inControlGroup) break;
|
1169
1158
|
const deltaS = Number(command.data.delta);
|
1170
1159
|
if (isNaN(deltaS)) {
|
1171
1160
|
throw new Error("Non-number delta received");
|
@@ -1322,17 +1311,17 @@ var VisitorDataStore = class {
|
|
1322
1311
|
}
|
1323
1312
|
/** Push data update command(s) into the visitor data */
|
1324
1313
|
async updateData(commands) {
|
1325
|
-
var _a, _b, _c
|
1314
|
+
var _a, _b, _c;
|
1326
1315
|
if (commands.length === 0) {
|
1327
1316
|
return;
|
1328
1317
|
}
|
1329
1318
|
(_b = (_a = __privateGet(this, _options)).onLogMessage) == null ? void 0 : _b.call(_a, ["debug", 101, commands]);
|
1330
|
-
const newData = applyCommandsToData(commands, this.data
|
1319
|
+
const newData = applyCommandsToData(commands, this.data);
|
1331
1320
|
if (commands.some((c) => c.type === "consent" && !c.data)) {
|
1332
1321
|
__privateGet(this, _persist).delete(STORAGE_KEY, true);
|
1333
1322
|
}
|
1334
1323
|
__privateMethod(this, _VisitorDataStore_instances, replaceData_fn).call(this, newData);
|
1335
|
-
await ((
|
1324
|
+
await ((_c = __privateGet(this, _options).transitionStore) == null ? void 0 : _c.updateData(commands, __privateGet(this, _VisitorDataStore_instances, currentData_get).visitorData));
|
1336
1325
|
__privateGet(this, _mitt2).emit("commandsExecuted", commands);
|
1337
1326
|
}
|
1338
1327
|
/**
|
@@ -1369,20 +1358,15 @@ replaceData_fn = function(data, quiet = false) {
|
|
1369
1358
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
1370
1359
|
const oldData = __privateGet(this, _VisitorDataStore_instances, currentData_get);
|
1371
1360
|
const now = Date.now();
|
1372
|
-
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1376
|
-
|
1377
|
-
|
1378
|
-
|
1379
|
-
|
1380
|
-
|
1381
|
-
scores: data.scores,
|
1382
|
-
sessionScores: data.sessionScores,
|
1383
|
-
onLogMessage: __privateGet(this, _options).onLogMessage
|
1384
|
-
});
|
1385
|
-
}
|
1361
|
+
__privateMethod(this, _VisitorDataStore_instances, handleCaps_fn).call(this, data.scores);
|
1362
|
+
__privateMethod(this, _VisitorDataStore_instances, handleCaps_fn).call(this, data.sessionScores);
|
1363
|
+
(_b = (_a = __privateGet(this, _options)).decay) == null ? void 0 : _b.call(_a, {
|
1364
|
+
now,
|
1365
|
+
lastUpd: oldData == null ? void 0 : oldData.updated,
|
1366
|
+
scores: data.scores,
|
1367
|
+
sessionScores: data.sessionScores,
|
1368
|
+
onLogMessage: __privateGet(this, _options).onLogMessage
|
1369
|
+
});
|
1386
1370
|
const haveScoresChanged = !dequal4(oldData == null ? void 0 : oldData.visitorData.scores, data.scores);
|
1387
1371
|
const haveSessionScoresChanged = !dequal4(oldData == null ? void 0 : oldData.visitorData.sessionScores, data.sessionScores);
|
1388
1372
|
const haveQuirksChanged = !dequal4(oldData == null ? void 0 : oldData.visitorData.quirks, data.quirks);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@uniformdev/context",
|
3
|
-
"version": "19.
|
3
|
+
"version": "19.178.0",
|
4
4
|
"description": "Uniform Context core package",
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
6
6
|
"main": "./dist/index.js",
|
@@ -68,5 +68,5 @@
|
|
68
68
|
"publishConfig": {
|
69
69
|
"access": "public"
|
70
70
|
},
|
71
|
-
"gitHead": "
|
71
|
+
"gitHead": "66721c01d9bf53917e5c4d83e2e578248e72560d"
|
72
72
|
}
|