@uniformdev/context 19.176.1-alpha.9 → 19.177.1

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