@uniformdev/context 19.132.0 → 19.133.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/api/api.d.mts +1 -1
- package/dist/api/api.d.ts +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.esm.js +174 -26
- package/dist/index.js +174 -26
- package/dist/index.mjs +174 -26
- package/dist/{types-R41eD1zH.d.mts → types-o-_vpf1P.d.mts} +34 -7
- package/dist/{types-R41eD1zH.d.ts → types-o-_vpf1P.d.ts} +34 -7
- package/package.json +2 -2
package/dist/api/api.d.mts
CHANGED
package/dist/api/api.d.ts
CHANGED
package/dist/index.d.mts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { O as OutputSeverity, L as LogDrain, C as ContextPlugin, S as ScoreVector, A as AggregateDimension, T as TransitionDataStore, a as StorageCommands, V as VisitorData, b as TransitionDataStoreOptions, D as DecayFunction, c as CriteriaEvaluator, d as StringMatch, e as VariantMatchCriteria, f as LogMessage, g as DevToolsEvents } from './types-
|
2
|
-
export { _ as AggregateDimensionInput, a4 as BehaviorTag, h as CONTEXTUAL_EDITING_TEST_NAME, i as CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID, n as Context, l as ContextEvents, m as ContextInstance, j as ContextOptions,
|
1
|
+
import { O as OutputSeverity, L as LogDrain, C as ContextPlugin, S as ScoreVector, A as AggregateDimension, T as TransitionDataStore, a as StorageCommands, V as VisitorData, b as TransitionDataStoreOptions, D as DecayFunction, c as CriteriaEvaluator, d as StringMatch, e as VariantMatchCriteria, f as LogMessage, g as DevToolsEvents } from './types-o-_vpf1P.mjs';
|
2
|
+
export { _ as AggregateDimensionInput, a4 as BehaviorTag, h as CONTEXTUAL_EDITING_TEST_NAME, i as CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID, n as Context, l as ContextEvents, m as ContextInstance, j as ContextOptions, aw as ContextState, ax as ContextStateUpdate, J as CriteriaEvaluatorParameters, I as CriteriaEvaluatorResult, al as DecayOptions, q as DevToolsActions, t as DevToolsDataEvent, r as DevToolsEvent, x as DevToolsForgetEvent, u as DevToolsHelloEvent, s as DevToolsLogEvent, w as DevToolsRawCommandsEvent, p as DevToolsState, o as DevToolsUiVersion, v as DevToolsUpdateEvent, a1 as DimensionMatch, X as EnrichmentCategory, ar as EnrichmentData, au as EventData, H as GroupCriteriaEvaluator, af as IdentifyCommand, F as LogMessageGroup, E as LogMessageSingle, y as LogMessages, G as ManifestInstance, N as ManifestV2, M as MessageCategory, B as MessageFunc, aa as ModifyScoreCommand, ab as ModifySessionScoreCommand, Y as NumberMatch, P as PersonalizationEvent, Q as PersonalizationManifest, as as PersonalizeControlVariant, a2 as PersonalizeOptions, at as PersonalizeVariants, a6 as PersonalizedResult, a5 as PersonalizedVariant, ap as Quirks, aj as SERVER_STATE_ID, ai as ServerToClientTransitionState, ac as SetConsentCommand, ag as SetControlGroupCommand, ah as SetPersonalizeVariantControlCommand, ad as SetQuirkCommand, ae as SetTestCommand, z as Severity, R as Signal, W as SignalCriteria, U as SignalCriteriaGroup, K as SignalData, a9 as StorageCommand, Z as TestDefinition, k as TestEvent, $ as TestOptions, a8 as TestResult, a7 as TestVariant, aq as Tests, ak as TransitionDataStoreEvents, ao as VisitorDataStore, an as VisitorDataStoreEvents, am as VisitorDataStoreOptions, av as emptyVisitorData, a3 as personalizeVariations, a0 as testVariations } from './types-o-_vpf1P.mjs';
|
3
3
|
import Cookies from 'js-cookie';
|
4
4
|
import 'mitt';
|
5
5
|
|
package/dist/index.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { O as OutputSeverity, L as LogDrain, C as ContextPlugin, S as ScoreVector, A as AggregateDimension, T as TransitionDataStore, a as StorageCommands, V as VisitorData, b as TransitionDataStoreOptions, D as DecayFunction, c as CriteriaEvaluator, d as StringMatch, e as VariantMatchCriteria, f as LogMessage, g as DevToolsEvents } from './types-
|
2
|
-
export { _ as AggregateDimensionInput, a4 as BehaviorTag, h as CONTEXTUAL_EDITING_TEST_NAME, i as CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID, n as Context, l as ContextEvents, m as ContextInstance, j as ContextOptions,
|
1
|
+
import { O as OutputSeverity, L as LogDrain, C as ContextPlugin, S as ScoreVector, A as AggregateDimension, T as TransitionDataStore, a as StorageCommands, V as VisitorData, b as TransitionDataStoreOptions, D as DecayFunction, c as CriteriaEvaluator, d as StringMatch, e as VariantMatchCriteria, f as LogMessage, g as DevToolsEvents } from './types-o-_vpf1P.js';
|
2
|
+
export { _ as AggregateDimensionInput, a4 as BehaviorTag, h as CONTEXTUAL_EDITING_TEST_NAME, i as CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID, n as Context, l as ContextEvents, m as ContextInstance, j as ContextOptions, aw as ContextState, ax as ContextStateUpdate, J as CriteriaEvaluatorParameters, I as CriteriaEvaluatorResult, al as DecayOptions, q as DevToolsActions, t as DevToolsDataEvent, r as DevToolsEvent, x as DevToolsForgetEvent, u as DevToolsHelloEvent, s as DevToolsLogEvent, w as DevToolsRawCommandsEvent, p as DevToolsState, o as DevToolsUiVersion, v as DevToolsUpdateEvent, a1 as DimensionMatch, X as EnrichmentCategory, ar as EnrichmentData, au as EventData, H as GroupCriteriaEvaluator, af as IdentifyCommand, F as LogMessageGroup, E as LogMessageSingle, y as LogMessages, G as ManifestInstance, N as ManifestV2, M as MessageCategory, B as MessageFunc, aa as ModifyScoreCommand, ab as ModifySessionScoreCommand, Y as NumberMatch, P as PersonalizationEvent, Q as PersonalizationManifest, as as PersonalizeControlVariant, a2 as PersonalizeOptions, at as PersonalizeVariants, a6 as PersonalizedResult, a5 as PersonalizedVariant, ap as Quirks, aj as SERVER_STATE_ID, ai as ServerToClientTransitionState, ac as SetConsentCommand, ag as SetControlGroupCommand, ah as SetPersonalizeVariantControlCommand, ad as SetQuirkCommand, ae as SetTestCommand, z as Severity, R as Signal, W as SignalCriteria, U as SignalCriteriaGroup, K as SignalData, a9 as StorageCommand, Z as TestDefinition, k as TestEvent, $ as TestOptions, a8 as TestResult, a7 as TestVariant, aq as Tests, ak as TransitionDataStoreEvents, ao as VisitorDataStore, an as VisitorDataStoreEvents, am as VisitorDataStoreOptions, av as emptyVisitorData, a3 as personalizeVariations, a0 as testVariations } from './types-o-_vpf1P.js';
|
3
3
|
import Cookies from 'js-cookie';
|
4
4
|
import 'mitt';
|
5
5
|
|
package/dist/index.esm.js
CHANGED
@@ -123,6 +123,15 @@ var SignalInstance = class {
|
|
123
123
|
_evaluator = new WeakMap();
|
124
124
|
_onLogMessage = new WeakMap();
|
125
125
|
|
126
|
+
// src/manifest/utils/control.ts
|
127
|
+
var rollForControlGroup = (value) => {
|
128
|
+
let control = value;
|
129
|
+
if (control >= 1) {
|
130
|
+
control = control / 100;
|
131
|
+
}
|
132
|
+
return Math.random() < control;
|
133
|
+
};
|
134
|
+
|
126
135
|
// src/manifest/ManifestInstance.ts
|
127
136
|
var _mf, _signalInstances, _onLogMessage2;
|
128
137
|
var ManifestInstance = class {
|
@@ -146,12 +155,8 @@ var ManifestInstance = class {
|
|
146
155
|
__privateSet(this, _onLogMessage2, onLogMessage);
|
147
156
|
}
|
148
157
|
rollForControlGroup() {
|
149
|
-
var _a
|
150
|
-
|
151
|
-
if (control >= 1) {
|
152
|
-
control = control / 100;
|
153
|
-
}
|
154
|
-
return Math.random() < control;
|
158
|
+
var _a;
|
159
|
+
return rollForControlGroup(((_a = __privateGet(this, _mf).pz) == null ? void 0 : _a.control) || 0);
|
155
160
|
}
|
156
161
|
getTest(name) {
|
157
162
|
var _a;
|
@@ -499,7 +504,30 @@ function evaluateDimensionMatch(crit, vec, onLogMessage) {
|
|
499
504
|
var _a, _b;
|
500
505
|
const { op, l: lhs } = crit;
|
501
506
|
const lhsScore = (_a = vec[lhs]) != null ? _a : 0;
|
502
|
-
if (op === "
|
507
|
+
if (op === "^") {
|
508
|
+
const [cat] = lhs.split(ENR_SEPARATOR);
|
509
|
+
let topVectorName = void 0;
|
510
|
+
let topScore = 0;
|
511
|
+
Object.keys(vec).forEach((vectorName) => {
|
512
|
+
if (vectorName.startsWith(`${cat}${ENR_SEPARATOR}`)) {
|
513
|
+
const score = vec[vectorName];
|
514
|
+
if (score > topScore) {
|
515
|
+
topVectorName = vectorName;
|
516
|
+
topScore = score;
|
517
|
+
}
|
518
|
+
}
|
519
|
+
});
|
520
|
+
const result = topVectorName === lhs;
|
521
|
+
onLogMessage == null ? void 0 : onLogMessage([
|
522
|
+
"info",
|
523
|
+
302,
|
524
|
+
{
|
525
|
+
matched: result,
|
526
|
+
description: `${crit.l} has the highest score in the category`
|
527
|
+
}
|
528
|
+
]);
|
529
|
+
return result;
|
530
|
+
} else if (op === "+") {
|
503
531
|
const result = Math.max(...Object.values(vec)) === lhsScore && lhsScore > 0;
|
504
532
|
onLogMessage == null ? void 0 : onLogMessage([
|
505
533
|
"info",
|
@@ -586,31 +614,70 @@ function personalizeVariations({
|
|
586
614
|
take = 1,
|
587
615
|
onLogMessage
|
588
616
|
}) {
|
589
|
-
var _a, _b, _c;
|
617
|
+
var _a, _b, _c, _d;
|
590
618
|
onLogMessage == null ? void 0 : onLogMessage(["info", 300, "GROUP", { name, take }]);
|
591
619
|
try {
|
592
620
|
const control = (_a = context.storage.data.controlGroup) != null ? _a : false;
|
593
621
|
const results = [];
|
594
622
|
let personalized = false;
|
595
623
|
const scores = context.scores;
|
624
|
+
let index = 0;
|
625
|
+
const defaultVariants = [];
|
626
|
+
for (const variant of variations) {
|
627
|
+
if (!((_b = variant.pz) == null ? void 0 : _b.crit.length)) {
|
628
|
+
defaultVariants.push(variant);
|
629
|
+
}
|
630
|
+
}
|
596
631
|
for (const variant of variations) {
|
632
|
+
const currentIndex = index++;
|
597
633
|
if (results.length === take) {
|
598
634
|
break;
|
599
635
|
}
|
600
|
-
if (!((
|
601
|
-
onLogMessage == null ? void 0 : onLogMessage(["info", 301, "GROUP", { id: variant.id, op: (
|
636
|
+
if (!((_c = variant.pz) == null ? void 0 : _c.crit.length)) {
|
637
|
+
onLogMessage == null ? void 0 : onLogMessage(["info", 301, "GROUP", { id: variant.id, op: (_d = variant.pz) == null ? void 0 : _d.op }]);
|
602
638
|
onLogMessage == null ? void 0 : onLogMessage(["info", 302, { matched: true, description: "default variation" }]);
|
603
639
|
onLogMessage == null ? void 0 : onLogMessage(["info", 303, true]);
|
604
640
|
onLogMessage == null ? void 0 : onLogMessage(["info", 301, "ENDGROUP"]);
|
605
|
-
results.push(
|
641
|
+
results.push({
|
642
|
+
...variant,
|
643
|
+
control: false
|
644
|
+
});
|
606
645
|
continue;
|
607
646
|
}
|
608
647
|
if (control) {
|
609
648
|
continue;
|
610
649
|
}
|
611
650
|
if (evaluateVariantMatch(variant.id, variant.pz, scores, onLogMessage)) {
|
612
|
-
|
613
|
-
|
651
|
+
let variantToAdd = variant;
|
652
|
+
let isControl = false;
|
653
|
+
const isDefault = defaultVariants.find((v) => v.id === variant.id);
|
654
|
+
if (take === 1 && !isDefault && defaultVariants.length && typeof variant.pz.control === "number") {
|
655
|
+
isControl = context.getPersonalizeVariantControl(name, currentIndex);
|
656
|
+
if (typeof isControl === "undefined") {
|
657
|
+
isControl = rollForControlGroup(variant.pz.control);
|
658
|
+
context.storage.updateData([
|
659
|
+
{
|
660
|
+
type: "setpersonalizecontrol",
|
661
|
+
data: {
|
662
|
+
personlizationName: name,
|
663
|
+
index: currentIndex,
|
664
|
+
control: isControl
|
665
|
+
}
|
666
|
+
}
|
667
|
+
]);
|
668
|
+
}
|
669
|
+
if (isControl) {
|
670
|
+
variantToAdd = {
|
671
|
+
...defaultVariants[0],
|
672
|
+
id: variant.id
|
673
|
+
};
|
674
|
+
}
|
675
|
+
}
|
676
|
+
personalized = personalized || typeof variantToAdd.pz !== "undefined";
|
677
|
+
results.push({
|
678
|
+
...variantToAdd,
|
679
|
+
control: isControl
|
680
|
+
});
|
614
681
|
}
|
615
682
|
}
|
616
683
|
return {
|
@@ -857,16 +924,19 @@ function parseScoreCookie(cookieValue) {
|
|
857
924
|
if (!cookieValue)
|
858
925
|
return;
|
859
926
|
const types = cookieValue.split(TYPE_SEP);
|
860
|
-
if (types.length >
|
927
|
+
if (types.length > 5)
|
861
928
|
return;
|
862
|
-
const [abTestData, sessionScores, visitorScores] = types;
|
863
|
-
|
929
|
+
const [abTestData, sessionScores, visitorScores, controlGroup, personalizeVariants] = types;
|
930
|
+
const data = {
|
864
931
|
// this is true since we're reading a cookie, which wouldn't exist if consent wasn't given
|
865
932
|
consent: true,
|
866
933
|
sessionScores: decodeCookieType(parseCookieType(sessionScores)),
|
867
934
|
scores: decodeCookieType(parseCookieType(visitorScores)),
|
868
|
-
tests: parseCookieType(abTestData)
|
935
|
+
tests: parseCookieType(abTestData),
|
936
|
+
controlGroup: controlGroup === "1",
|
937
|
+
personalizeVariants: decodePersonalizeVariants(personalizeVariants)
|
869
938
|
};
|
939
|
+
return data;
|
870
940
|
}
|
871
941
|
function parseCookieType(type) {
|
872
942
|
if (!type) {
|
@@ -890,9 +960,48 @@ function serializeCookie(data) {
|
|
890
960
|
return [
|
891
961
|
serializeCookieType(data.tests),
|
892
962
|
serializeCookieType(encodeCookieType(data.sessionScores)),
|
893
|
-
serializeCookieType(encodeCookieType(data.scores))
|
963
|
+
serializeCookieType(encodeCookieType(data.scores)),
|
964
|
+
data.controlGroup ? "1" : "0",
|
965
|
+
serializePersonalizeVariants(data)
|
894
966
|
].join(TYPE_SEP);
|
895
967
|
}
|
968
|
+
function serializePersonalizeVariants({
|
969
|
+
personalizeVariants
|
970
|
+
}) {
|
971
|
+
const data = {};
|
972
|
+
if (typeof personalizeVariants === "object") {
|
973
|
+
Object.keys(personalizeVariants).forEach((personalizationName) => {
|
974
|
+
const results = [];
|
975
|
+
const variants = personalizeVariants[personalizationName];
|
976
|
+
variants.forEach((variant) => {
|
977
|
+
results.push(`${variant.index}:${variant.control ? "1" : "0"}`);
|
978
|
+
});
|
979
|
+
data[personalizationName] = results.join(",");
|
980
|
+
});
|
981
|
+
}
|
982
|
+
const serialized = serializeCookieType(data);
|
983
|
+
return serialized;
|
984
|
+
}
|
985
|
+
function decodePersonalizeVariants(data) {
|
986
|
+
const parsed = parseCookieType(data);
|
987
|
+
const keys = Object.keys(parsed);
|
988
|
+
if (!keys.length) {
|
989
|
+
return void 0;
|
990
|
+
}
|
991
|
+
const results = {};
|
992
|
+
Object.keys(parsed).forEach((k) => {
|
993
|
+
const variants = parsed[k].split(",");
|
994
|
+
const key = decodeURIComponent(k);
|
995
|
+
results[key] = variants.map((variant) => {
|
996
|
+
const [index, control] = variant.split(":");
|
997
|
+
return {
|
998
|
+
index: parseInt(index, 10),
|
999
|
+
control: control === "1"
|
1000
|
+
};
|
1001
|
+
});
|
1002
|
+
});
|
1003
|
+
return results;
|
1004
|
+
}
|
896
1005
|
function encodeCookieType(type) {
|
897
1006
|
return Object.entries(type).reduce((acc, [key, value]) => {
|
898
1007
|
acc[key] = ntob(value);
|
@@ -980,7 +1089,8 @@ var emptyVisitorData = () => ({
|
|
980
1089
|
sessionScores: {},
|
981
1090
|
tests: {},
|
982
1091
|
consent: false,
|
983
|
-
controlGroup: false
|
1092
|
+
controlGroup: false,
|
1093
|
+
personalizeVariants: {}
|
984
1094
|
});
|
985
1095
|
|
986
1096
|
// src/storage/VisitorDataStore.ts
|
@@ -1029,6 +1139,25 @@ function applyCommandsToData(commands, state, inControlGroup) {
|
|
1029
1139
|
case "setcontrol":
|
1030
1140
|
newData.controlGroup = command.data;
|
1031
1141
|
break;
|
1142
|
+
case "setpersonalizecontrol":
|
1143
|
+
if (!newData.personalizeVariants) {
|
1144
|
+
newData.personalizeVariants = {};
|
1145
|
+
}
|
1146
|
+
if (!newData.personalizeVariants[command.data.personlizationName]) {
|
1147
|
+
newData.personalizeVariants[command.data.personlizationName] = [];
|
1148
|
+
}
|
1149
|
+
const existingDef = newData.personalizeVariants[command.data.personlizationName].find(
|
1150
|
+
(i) => i.index === command.data.index
|
1151
|
+
);
|
1152
|
+
if (!existingDef) {
|
1153
|
+
newData.personalizeVariants[command.data.personlizationName].push({
|
1154
|
+
index: command.data.index,
|
1155
|
+
control: command.data.control
|
1156
|
+
});
|
1157
|
+
} else {
|
1158
|
+
console.warn("Overwriting existing control group definition is not allowed");
|
1159
|
+
}
|
1160
|
+
break;
|
1032
1161
|
default:
|
1033
1162
|
throw new Error(`Unknown command`);
|
1034
1163
|
}
|
@@ -1390,7 +1519,7 @@ var Context = class {
|
|
1390
1519
|
* will NOT result in a recomputation of signal state.
|
1391
1520
|
*/
|
1392
1521
|
async update(newData) {
|
1393
|
-
var _a, _b, _c;
|
1522
|
+
var _a, _b, _c, _d;
|
1394
1523
|
const commands = [];
|
1395
1524
|
const newServerSideTests = {};
|
1396
1525
|
if ((_a = __privateGet(this, _serverTransitionState)) == null ? void 0 : _a.quirks) {
|
@@ -1420,6 +1549,17 @@ var Context = class {
|
|
1420
1549
|
);
|
1421
1550
|
}
|
1422
1551
|
}
|
1552
|
+
if ((_c = __privateGet(this, _serverTransitionState)) == null ? void 0 : _c.personalizeVariants) {
|
1553
|
+
Object.keys(__privateGet(this, _serverTransitionState).personalizeVariants).forEach((personalizationName) => {
|
1554
|
+
const variants = __privateGet(this, _serverTransitionState).personalizeVariants[personalizationName];
|
1555
|
+
variants.forEach((e) => {
|
1556
|
+
commands.push({
|
1557
|
+
type: "setpersonalizecontrol",
|
1558
|
+
data: { personlizationName: personalizationName, index: e.index, control: e.control }
|
1559
|
+
});
|
1560
|
+
});
|
1561
|
+
});
|
1562
|
+
}
|
1423
1563
|
try {
|
1424
1564
|
__privateGet(this, _mitt3).emit("log", [
|
1425
1565
|
"info",
|
@@ -1429,7 +1569,7 @@ var Context = class {
|
|
1429
1569
|
...newData,
|
1430
1570
|
// need to convert url to string so it can be json serialized
|
1431
1571
|
// to go over postMessage to chrome extension
|
1432
|
-
url: (
|
1572
|
+
url: (_d = newData.url) == null ? void 0 : _d.toString()
|
1433
1573
|
}
|
1434
1574
|
]);
|
1435
1575
|
if (newData.quirks) {
|
@@ -1511,6 +1651,13 @@ var Context = class {
|
|
1511
1651
|
}
|
1512
1652
|
]);
|
1513
1653
|
}
|
1654
|
+
getPersonalizeVariantControl(name, index) {
|
1655
|
+
var _a, _b, _c;
|
1656
|
+
const source = (_b = (_a = __privateGet(this, _serverTransitionState)) == null ? void 0 : _a.personalizeVariants) != null ? _b : this.storage.data.personalizeVariants;
|
1657
|
+
const variants = (_c = source == null ? void 0 : source[name]) != null ? _c : [];
|
1658
|
+
const variant = variants.find((v) => v.index === index);
|
1659
|
+
return variant == null ? void 0 : variant.control;
|
1660
|
+
}
|
1514
1661
|
/**
|
1515
1662
|
* Writes a message to the Context log sink.
|
1516
1663
|
* Used by Uniform internal SDK; not intended for public use.
|
@@ -1553,10 +1700,10 @@ var Context = class {
|
|
1553
1700
|
const previousPlacement = __privateGet(this, _pzCache)[options.name];
|
1554
1701
|
const eventData = {
|
1555
1702
|
name: options.name,
|
1556
|
-
variantIds: value.variations.map((variation) => {
|
1557
|
-
|
1558
|
-
|
1559
|
-
}),
|
1703
|
+
variantIds: value.variations.map((variation) => ({
|
1704
|
+
id: variation.id || "Unknown",
|
1705
|
+
control: variation.control
|
1706
|
+
})),
|
1560
1707
|
control: this.storage.data.controlGroup,
|
1561
1708
|
changed: true
|
1562
1709
|
};
|
@@ -1584,7 +1731,8 @@ var Context = class {
|
|
1584
1731
|
const transitionState = {
|
1585
1732
|
quirks: this.storage.data.quirks,
|
1586
1733
|
ssv: __privateGet(this, _scores),
|
1587
|
-
tests: {}
|
1734
|
+
tests: {},
|
1735
|
+
personalizeVariants: this.storage.data.personalizeVariants
|
1588
1736
|
};
|
1589
1737
|
const allTests = this.storage.data.tests;
|
1590
1738
|
Object.entries(allTests).map(([testName, testValue]) => {
|
package/dist/index.js
CHANGED
@@ -193,6 +193,15 @@ var SignalInstance = class {
|
|
193
193
|
_evaluator = new WeakMap();
|
194
194
|
_onLogMessage = new WeakMap();
|
195
195
|
|
196
|
+
// src/manifest/utils/control.ts
|
197
|
+
var rollForControlGroup = (value) => {
|
198
|
+
let control = value;
|
199
|
+
if (control >= 1) {
|
200
|
+
control = control / 100;
|
201
|
+
}
|
202
|
+
return Math.random() < control;
|
203
|
+
};
|
204
|
+
|
196
205
|
// src/manifest/ManifestInstance.ts
|
197
206
|
var _mf, _signalInstances, _onLogMessage2;
|
198
207
|
var ManifestInstance = class {
|
@@ -216,12 +225,8 @@ var ManifestInstance = class {
|
|
216
225
|
__privateSet(this, _onLogMessage2, onLogMessage);
|
217
226
|
}
|
218
227
|
rollForControlGroup() {
|
219
|
-
var _a
|
220
|
-
|
221
|
-
if (control >= 1) {
|
222
|
-
control = control / 100;
|
223
|
-
}
|
224
|
-
return Math.random() < control;
|
228
|
+
var _a;
|
229
|
+
return rollForControlGroup(((_a = __privateGet(this, _mf).pz) == null ? void 0 : _a.control) || 0);
|
225
230
|
}
|
226
231
|
getTest(name) {
|
227
232
|
var _a;
|
@@ -569,7 +574,30 @@ function evaluateDimensionMatch(crit, vec, onLogMessage) {
|
|
569
574
|
var _a, _b;
|
570
575
|
const { op, l: lhs } = crit;
|
571
576
|
const lhsScore = (_a = vec[lhs]) != null ? _a : 0;
|
572
|
-
if (op === "
|
577
|
+
if (op === "^") {
|
578
|
+
const [cat] = lhs.split(ENR_SEPARATOR);
|
579
|
+
let topVectorName = void 0;
|
580
|
+
let topScore = 0;
|
581
|
+
Object.keys(vec).forEach((vectorName) => {
|
582
|
+
if (vectorName.startsWith(`${cat}${ENR_SEPARATOR}`)) {
|
583
|
+
const score = vec[vectorName];
|
584
|
+
if (score > topScore) {
|
585
|
+
topVectorName = vectorName;
|
586
|
+
topScore = score;
|
587
|
+
}
|
588
|
+
}
|
589
|
+
});
|
590
|
+
const result = topVectorName === lhs;
|
591
|
+
onLogMessage == null ? void 0 : onLogMessage([
|
592
|
+
"info",
|
593
|
+
302,
|
594
|
+
{
|
595
|
+
matched: result,
|
596
|
+
description: `${crit.l} has the highest score in the category`
|
597
|
+
}
|
598
|
+
]);
|
599
|
+
return result;
|
600
|
+
} else if (op === "+") {
|
573
601
|
const result = Math.max(...Object.values(vec)) === lhsScore && lhsScore > 0;
|
574
602
|
onLogMessage == null ? void 0 : onLogMessage([
|
575
603
|
"info",
|
@@ -656,31 +684,70 @@ function personalizeVariations({
|
|
656
684
|
take = 1,
|
657
685
|
onLogMessage
|
658
686
|
}) {
|
659
|
-
var _a, _b, _c;
|
687
|
+
var _a, _b, _c, _d;
|
660
688
|
onLogMessage == null ? void 0 : onLogMessage(["info", 300, "GROUP", { name, take }]);
|
661
689
|
try {
|
662
690
|
const control = (_a = context.storage.data.controlGroup) != null ? _a : false;
|
663
691
|
const results = [];
|
664
692
|
let personalized = false;
|
665
693
|
const scores = context.scores;
|
694
|
+
let index = 0;
|
695
|
+
const defaultVariants = [];
|
696
|
+
for (const variant of variations) {
|
697
|
+
if (!((_b = variant.pz) == null ? void 0 : _b.crit.length)) {
|
698
|
+
defaultVariants.push(variant);
|
699
|
+
}
|
700
|
+
}
|
666
701
|
for (const variant of variations) {
|
702
|
+
const currentIndex = index++;
|
667
703
|
if (results.length === take) {
|
668
704
|
break;
|
669
705
|
}
|
670
|
-
if (!((
|
671
|
-
onLogMessage == null ? void 0 : onLogMessage(["info", 301, "GROUP", { id: variant.id, op: (
|
706
|
+
if (!((_c = variant.pz) == null ? void 0 : _c.crit.length)) {
|
707
|
+
onLogMessage == null ? void 0 : onLogMessage(["info", 301, "GROUP", { id: variant.id, op: (_d = variant.pz) == null ? void 0 : _d.op }]);
|
672
708
|
onLogMessage == null ? void 0 : onLogMessage(["info", 302, { matched: true, description: "default variation" }]);
|
673
709
|
onLogMessage == null ? void 0 : onLogMessage(["info", 303, true]);
|
674
710
|
onLogMessage == null ? void 0 : onLogMessage(["info", 301, "ENDGROUP"]);
|
675
|
-
results.push(
|
711
|
+
results.push({
|
712
|
+
...variant,
|
713
|
+
control: false
|
714
|
+
});
|
676
715
|
continue;
|
677
716
|
}
|
678
717
|
if (control) {
|
679
718
|
continue;
|
680
719
|
}
|
681
720
|
if (evaluateVariantMatch(variant.id, variant.pz, scores, onLogMessage)) {
|
682
|
-
|
683
|
-
|
721
|
+
let variantToAdd = variant;
|
722
|
+
let isControl = false;
|
723
|
+
const isDefault = defaultVariants.find((v) => v.id === variant.id);
|
724
|
+
if (take === 1 && !isDefault && defaultVariants.length && typeof variant.pz.control === "number") {
|
725
|
+
isControl = context.getPersonalizeVariantControl(name, currentIndex);
|
726
|
+
if (typeof isControl === "undefined") {
|
727
|
+
isControl = rollForControlGroup(variant.pz.control);
|
728
|
+
context.storage.updateData([
|
729
|
+
{
|
730
|
+
type: "setpersonalizecontrol",
|
731
|
+
data: {
|
732
|
+
personlizationName: name,
|
733
|
+
index: currentIndex,
|
734
|
+
control: isControl
|
735
|
+
}
|
736
|
+
}
|
737
|
+
]);
|
738
|
+
}
|
739
|
+
if (isControl) {
|
740
|
+
variantToAdd = {
|
741
|
+
...defaultVariants[0],
|
742
|
+
id: variant.id
|
743
|
+
};
|
744
|
+
}
|
745
|
+
}
|
746
|
+
personalized = personalized || typeof variantToAdd.pz !== "undefined";
|
747
|
+
results.push({
|
748
|
+
...variantToAdd,
|
749
|
+
control: isControl
|
750
|
+
});
|
684
751
|
}
|
685
752
|
}
|
686
753
|
return {
|
@@ -927,16 +994,19 @@ function parseScoreCookie(cookieValue) {
|
|
927
994
|
if (!cookieValue)
|
928
995
|
return;
|
929
996
|
const types = cookieValue.split(TYPE_SEP);
|
930
|
-
if (types.length >
|
997
|
+
if (types.length > 5)
|
931
998
|
return;
|
932
|
-
const [abTestData, sessionScores, visitorScores] = types;
|
933
|
-
|
999
|
+
const [abTestData, sessionScores, visitorScores, controlGroup, personalizeVariants] = types;
|
1000
|
+
const data = {
|
934
1001
|
// this is true since we're reading a cookie, which wouldn't exist if consent wasn't given
|
935
1002
|
consent: true,
|
936
1003
|
sessionScores: decodeCookieType(parseCookieType(sessionScores)),
|
937
1004
|
scores: decodeCookieType(parseCookieType(visitorScores)),
|
938
|
-
tests: parseCookieType(abTestData)
|
1005
|
+
tests: parseCookieType(abTestData),
|
1006
|
+
controlGroup: controlGroup === "1",
|
1007
|
+
personalizeVariants: decodePersonalizeVariants(personalizeVariants)
|
939
1008
|
};
|
1009
|
+
return data;
|
940
1010
|
}
|
941
1011
|
function parseCookieType(type) {
|
942
1012
|
if (!type) {
|
@@ -960,9 +1030,48 @@ function serializeCookie(data) {
|
|
960
1030
|
return [
|
961
1031
|
serializeCookieType(data.tests),
|
962
1032
|
serializeCookieType(encodeCookieType(data.sessionScores)),
|
963
|
-
serializeCookieType(encodeCookieType(data.scores))
|
1033
|
+
serializeCookieType(encodeCookieType(data.scores)),
|
1034
|
+
data.controlGroup ? "1" : "0",
|
1035
|
+
serializePersonalizeVariants(data)
|
964
1036
|
].join(TYPE_SEP);
|
965
1037
|
}
|
1038
|
+
function serializePersonalizeVariants({
|
1039
|
+
personalizeVariants
|
1040
|
+
}) {
|
1041
|
+
const data = {};
|
1042
|
+
if (typeof personalizeVariants === "object") {
|
1043
|
+
Object.keys(personalizeVariants).forEach((personalizationName) => {
|
1044
|
+
const results = [];
|
1045
|
+
const variants = personalizeVariants[personalizationName];
|
1046
|
+
variants.forEach((variant) => {
|
1047
|
+
results.push(`${variant.index}:${variant.control ? "1" : "0"}`);
|
1048
|
+
});
|
1049
|
+
data[personalizationName] = results.join(",");
|
1050
|
+
});
|
1051
|
+
}
|
1052
|
+
const serialized = serializeCookieType(data);
|
1053
|
+
return serialized;
|
1054
|
+
}
|
1055
|
+
function decodePersonalizeVariants(data) {
|
1056
|
+
const parsed = parseCookieType(data);
|
1057
|
+
const keys = Object.keys(parsed);
|
1058
|
+
if (!keys.length) {
|
1059
|
+
return void 0;
|
1060
|
+
}
|
1061
|
+
const results = {};
|
1062
|
+
Object.keys(parsed).forEach((k) => {
|
1063
|
+
const variants = parsed[k].split(",");
|
1064
|
+
const key = decodeURIComponent(k);
|
1065
|
+
results[key] = variants.map((variant) => {
|
1066
|
+
const [index, control] = variant.split(":");
|
1067
|
+
return {
|
1068
|
+
index: parseInt(index, 10),
|
1069
|
+
control: control === "1"
|
1070
|
+
};
|
1071
|
+
});
|
1072
|
+
});
|
1073
|
+
return results;
|
1074
|
+
}
|
966
1075
|
function encodeCookieType(type) {
|
967
1076
|
return Object.entries(type).reduce((acc, [key, value]) => {
|
968
1077
|
acc[key] = ntob(value);
|
@@ -1050,7 +1159,8 @@ var emptyVisitorData = () => ({
|
|
1050
1159
|
sessionScores: {},
|
1051
1160
|
tests: {},
|
1052
1161
|
consent: false,
|
1053
|
-
controlGroup: false
|
1162
|
+
controlGroup: false,
|
1163
|
+
personalizeVariants: {}
|
1054
1164
|
});
|
1055
1165
|
|
1056
1166
|
// src/storage/VisitorDataStore.ts
|
@@ -1099,6 +1209,25 @@ function applyCommandsToData(commands, state, inControlGroup) {
|
|
1099
1209
|
case "setcontrol":
|
1100
1210
|
newData.controlGroup = command.data;
|
1101
1211
|
break;
|
1212
|
+
case "setpersonalizecontrol":
|
1213
|
+
if (!newData.personalizeVariants) {
|
1214
|
+
newData.personalizeVariants = {};
|
1215
|
+
}
|
1216
|
+
if (!newData.personalizeVariants[command.data.personlizationName]) {
|
1217
|
+
newData.personalizeVariants[command.data.personlizationName] = [];
|
1218
|
+
}
|
1219
|
+
const existingDef = newData.personalizeVariants[command.data.personlizationName].find(
|
1220
|
+
(i) => i.index === command.data.index
|
1221
|
+
);
|
1222
|
+
if (!existingDef) {
|
1223
|
+
newData.personalizeVariants[command.data.personlizationName].push({
|
1224
|
+
index: command.data.index,
|
1225
|
+
control: command.data.control
|
1226
|
+
});
|
1227
|
+
} else {
|
1228
|
+
console.warn("Overwriting existing control group definition is not allowed");
|
1229
|
+
}
|
1230
|
+
break;
|
1102
1231
|
default:
|
1103
1232
|
throw new Error(`Unknown command`);
|
1104
1233
|
}
|
@@ -1460,7 +1589,7 @@ var Context = class {
|
|
1460
1589
|
* will NOT result in a recomputation of signal state.
|
1461
1590
|
*/
|
1462
1591
|
async update(newData) {
|
1463
|
-
var _a, _b, _c;
|
1592
|
+
var _a, _b, _c, _d;
|
1464
1593
|
const commands = [];
|
1465
1594
|
const newServerSideTests = {};
|
1466
1595
|
if ((_a = __privateGet(this, _serverTransitionState)) == null ? void 0 : _a.quirks) {
|
@@ -1490,6 +1619,17 @@ var Context = class {
|
|
1490
1619
|
);
|
1491
1620
|
}
|
1492
1621
|
}
|
1622
|
+
if ((_c = __privateGet(this, _serverTransitionState)) == null ? void 0 : _c.personalizeVariants) {
|
1623
|
+
Object.keys(__privateGet(this, _serverTransitionState).personalizeVariants).forEach((personalizationName) => {
|
1624
|
+
const variants = __privateGet(this, _serverTransitionState).personalizeVariants[personalizationName];
|
1625
|
+
variants.forEach((e) => {
|
1626
|
+
commands.push({
|
1627
|
+
type: "setpersonalizecontrol",
|
1628
|
+
data: { personlizationName: personalizationName, index: e.index, control: e.control }
|
1629
|
+
});
|
1630
|
+
});
|
1631
|
+
});
|
1632
|
+
}
|
1493
1633
|
try {
|
1494
1634
|
__privateGet(this, _mitt3).emit("log", [
|
1495
1635
|
"info",
|
@@ -1499,7 +1639,7 @@ var Context = class {
|
|
1499
1639
|
...newData,
|
1500
1640
|
// need to convert url to string so it can be json serialized
|
1501
1641
|
// to go over postMessage to chrome extension
|
1502
|
-
url: (
|
1642
|
+
url: (_d = newData.url) == null ? void 0 : _d.toString()
|
1503
1643
|
}
|
1504
1644
|
]);
|
1505
1645
|
if (newData.quirks) {
|
@@ -1581,6 +1721,13 @@ var Context = class {
|
|
1581
1721
|
}
|
1582
1722
|
]);
|
1583
1723
|
}
|
1724
|
+
getPersonalizeVariantControl(name, index) {
|
1725
|
+
var _a, _b, _c;
|
1726
|
+
const source = (_b = (_a = __privateGet(this, _serverTransitionState)) == null ? void 0 : _a.personalizeVariants) != null ? _b : this.storage.data.personalizeVariants;
|
1727
|
+
const variants = (_c = source == null ? void 0 : source[name]) != null ? _c : [];
|
1728
|
+
const variant = variants.find((v) => v.index === index);
|
1729
|
+
return variant == null ? void 0 : variant.control;
|
1730
|
+
}
|
1584
1731
|
/**
|
1585
1732
|
* Writes a message to the Context log sink.
|
1586
1733
|
* Used by Uniform internal SDK; not intended for public use.
|
@@ -1623,10 +1770,10 @@ var Context = class {
|
|
1623
1770
|
const previousPlacement = __privateGet(this, _pzCache)[options.name];
|
1624
1771
|
const eventData = {
|
1625
1772
|
name: options.name,
|
1626
|
-
variantIds: value.variations.map((variation) => {
|
1627
|
-
|
1628
|
-
|
1629
|
-
}),
|
1773
|
+
variantIds: value.variations.map((variation) => ({
|
1774
|
+
id: variation.id || "Unknown",
|
1775
|
+
control: variation.control
|
1776
|
+
})),
|
1630
1777
|
control: this.storage.data.controlGroup,
|
1631
1778
|
changed: true
|
1632
1779
|
};
|
@@ -1654,7 +1801,8 @@ var Context = class {
|
|
1654
1801
|
const transitionState = {
|
1655
1802
|
quirks: this.storage.data.quirks,
|
1656
1803
|
ssv: __privateGet(this, _scores),
|
1657
|
-
tests: {}
|
1804
|
+
tests: {},
|
1805
|
+
personalizeVariants: this.storage.data.personalizeVariants
|
1658
1806
|
};
|
1659
1807
|
const allTests = this.storage.data.tests;
|
1660
1808
|
Object.entries(allTests).map(([testName, testValue]) => {
|
package/dist/index.mjs
CHANGED
@@ -123,6 +123,15 @@ var SignalInstance = class {
|
|
123
123
|
_evaluator = new WeakMap();
|
124
124
|
_onLogMessage = new WeakMap();
|
125
125
|
|
126
|
+
// src/manifest/utils/control.ts
|
127
|
+
var rollForControlGroup = (value) => {
|
128
|
+
let control = value;
|
129
|
+
if (control >= 1) {
|
130
|
+
control = control / 100;
|
131
|
+
}
|
132
|
+
return Math.random() < control;
|
133
|
+
};
|
134
|
+
|
126
135
|
// src/manifest/ManifestInstance.ts
|
127
136
|
var _mf, _signalInstances, _onLogMessage2;
|
128
137
|
var ManifestInstance = class {
|
@@ -146,12 +155,8 @@ var ManifestInstance = class {
|
|
146
155
|
__privateSet(this, _onLogMessage2, onLogMessage);
|
147
156
|
}
|
148
157
|
rollForControlGroup() {
|
149
|
-
var _a
|
150
|
-
|
151
|
-
if (control >= 1) {
|
152
|
-
control = control / 100;
|
153
|
-
}
|
154
|
-
return Math.random() < control;
|
158
|
+
var _a;
|
159
|
+
return rollForControlGroup(((_a = __privateGet(this, _mf).pz) == null ? void 0 : _a.control) || 0);
|
155
160
|
}
|
156
161
|
getTest(name) {
|
157
162
|
var _a;
|
@@ -499,7 +504,30 @@ function evaluateDimensionMatch(crit, vec, onLogMessage) {
|
|
499
504
|
var _a, _b;
|
500
505
|
const { op, l: lhs } = crit;
|
501
506
|
const lhsScore = (_a = vec[lhs]) != null ? _a : 0;
|
502
|
-
if (op === "
|
507
|
+
if (op === "^") {
|
508
|
+
const [cat] = lhs.split(ENR_SEPARATOR);
|
509
|
+
let topVectorName = void 0;
|
510
|
+
let topScore = 0;
|
511
|
+
Object.keys(vec).forEach((vectorName) => {
|
512
|
+
if (vectorName.startsWith(`${cat}${ENR_SEPARATOR}`)) {
|
513
|
+
const score = vec[vectorName];
|
514
|
+
if (score > topScore) {
|
515
|
+
topVectorName = vectorName;
|
516
|
+
topScore = score;
|
517
|
+
}
|
518
|
+
}
|
519
|
+
});
|
520
|
+
const result = topVectorName === lhs;
|
521
|
+
onLogMessage == null ? void 0 : onLogMessage([
|
522
|
+
"info",
|
523
|
+
302,
|
524
|
+
{
|
525
|
+
matched: result,
|
526
|
+
description: `${crit.l} has the highest score in the category`
|
527
|
+
}
|
528
|
+
]);
|
529
|
+
return result;
|
530
|
+
} else if (op === "+") {
|
503
531
|
const result = Math.max(...Object.values(vec)) === lhsScore && lhsScore > 0;
|
504
532
|
onLogMessage == null ? void 0 : onLogMessage([
|
505
533
|
"info",
|
@@ -586,31 +614,70 @@ function personalizeVariations({
|
|
586
614
|
take = 1,
|
587
615
|
onLogMessage
|
588
616
|
}) {
|
589
|
-
var _a, _b, _c;
|
617
|
+
var _a, _b, _c, _d;
|
590
618
|
onLogMessage == null ? void 0 : onLogMessage(["info", 300, "GROUP", { name, take }]);
|
591
619
|
try {
|
592
620
|
const control = (_a = context.storage.data.controlGroup) != null ? _a : false;
|
593
621
|
const results = [];
|
594
622
|
let personalized = false;
|
595
623
|
const scores = context.scores;
|
624
|
+
let index = 0;
|
625
|
+
const defaultVariants = [];
|
626
|
+
for (const variant of variations) {
|
627
|
+
if (!((_b = variant.pz) == null ? void 0 : _b.crit.length)) {
|
628
|
+
defaultVariants.push(variant);
|
629
|
+
}
|
630
|
+
}
|
596
631
|
for (const variant of variations) {
|
632
|
+
const currentIndex = index++;
|
597
633
|
if (results.length === take) {
|
598
634
|
break;
|
599
635
|
}
|
600
|
-
if (!((
|
601
|
-
onLogMessage == null ? void 0 : onLogMessage(["info", 301, "GROUP", { id: variant.id, op: (
|
636
|
+
if (!((_c = variant.pz) == null ? void 0 : _c.crit.length)) {
|
637
|
+
onLogMessage == null ? void 0 : onLogMessage(["info", 301, "GROUP", { id: variant.id, op: (_d = variant.pz) == null ? void 0 : _d.op }]);
|
602
638
|
onLogMessage == null ? void 0 : onLogMessage(["info", 302, { matched: true, description: "default variation" }]);
|
603
639
|
onLogMessage == null ? void 0 : onLogMessage(["info", 303, true]);
|
604
640
|
onLogMessage == null ? void 0 : onLogMessage(["info", 301, "ENDGROUP"]);
|
605
|
-
results.push(
|
641
|
+
results.push({
|
642
|
+
...variant,
|
643
|
+
control: false
|
644
|
+
});
|
606
645
|
continue;
|
607
646
|
}
|
608
647
|
if (control) {
|
609
648
|
continue;
|
610
649
|
}
|
611
650
|
if (evaluateVariantMatch(variant.id, variant.pz, scores, onLogMessage)) {
|
612
|
-
|
613
|
-
|
651
|
+
let variantToAdd = variant;
|
652
|
+
let isControl = false;
|
653
|
+
const isDefault = defaultVariants.find((v) => v.id === variant.id);
|
654
|
+
if (take === 1 && !isDefault && defaultVariants.length && typeof variant.pz.control === "number") {
|
655
|
+
isControl = context.getPersonalizeVariantControl(name, currentIndex);
|
656
|
+
if (typeof isControl === "undefined") {
|
657
|
+
isControl = rollForControlGroup(variant.pz.control);
|
658
|
+
context.storage.updateData([
|
659
|
+
{
|
660
|
+
type: "setpersonalizecontrol",
|
661
|
+
data: {
|
662
|
+
personlizationName: name,
|
663
|
+
index: currentIndex,
|
664
|
+
control: isControl
|
665
|
+
}
|
666
|
+
}
|
667
|
+
]);
|
668
|
+
}
|
669
|
+
if (isControl) {
|
670
|
+
variantToAdd = {
|
671
|
+
...defaultVariants[0],
|
672
|
+
id: variant.id
|
673
|
+
};
|
674
|
+
}
|
675
|
+
}
|
676
|
+
personalized = personalized || typeof variantToAdd.pz !== "undefined";
|
677
|
+
results.push({
|
678
|
+
...variantToAdd,
|
679
|
+
control: isControl
|
680
|
+
});
|
614
681
|
}
|
615
682
|
}
|
616
683
|
return {
|
@@ -857,16 +924,19 @@ function parseScoreCookie(cookieValue) {
|
|
857
924
|
if (!cookieValue)
|
858
925
|
return;
|
859
926
|
const types = cookieValue.split(TYPE_SEP);
|
860
|
-
if (types.length >
|
927
|
+
if (types.length > 5)
|
861
928
|
return;
|
862
|
-
const [abTestData, sessionScores, visitorScores] = types;
|
863
|
-
|
929
|
+
const [abTestData, sessionScores, visitorScores, controlGroup, personalizeVariants] = types;
|
930
|
+
const data = {
|
864
931
|
// this is true since we're reading a cookie, which wouldn't exist if consent wasn't given
|
865
932
|
consent: true,
|
866
933
|
sessionScores: decodeCookieType(parseCookieType(sessionScores)),
|
867
934
|
scores: decodeCookieType(parseCookieType(visitorScores)),
|
868
|
-
tests: parseCookieType(abTestData)
|
935
|
+
tests: parseCookieType(abTestData),
|
936
|
+
controlGroup: controlGroup === "1",
|
937
|
+
personalizeVariants: decodePersonalizeVariants(personalizeVariants)
|
869
938
|
};
|
939
|
+
return data;
|
870
940
|
}
|
871
941
|
function parseCookieType(type) {
|
872
942
|
if (!type) {
|
@@ -890,9 +960,48 @@ function serializeCookie(data) {
|
|
890
960
|
return [
|
891
961
|
serializeCookieType(data.tests),
|
892
962
|
serializeCookieType(encodeCookieType(data.sessionScores)),
|
893
|
-
serializeCookieType(encodeCookieType(data.scores))
|
963
|
+
serializeCookieType(encodeCookieType(data.scores)),
|
964
|
+
data.controlGroup ? "1" : "0",
|
965
|
+
serializePersonalizeVariants(data)
|
894
966
|
].join(TYPE_SEP);
|
895
967
|
}
|
968
|
+
function serializePersonalizeVariants({
|
969
|
+
personalizeVariants
|
970
|
+
}) {
|
971
|
+
const data = {};
|
972
|
+
if (typeof personalizeVariants === "object") {
|
973
|
+
Object.keys(personalizeVariants).forEach((personalizationName) => {
|
974
|
+
const results = [];
|
975
|
+
const variants = personalizeVariants[personalizationName];
|
976
|
+
variants.forEach((variant) => {
|
977
|
+
results.push(`${variant.index}:${variant.control ? "1" : "0"}`);
|
978
|
+
});
|
979
|
+
data[personalizationName] = results.join(",");
|
980
|
+
});
|
981
|
+
}
|
982
|
+
const serialized = serializeCookieType(data);
|
983
|
+
return serialized;
|
984
|
+
}
|
985
|
+
function decodePersonalizeVariants(data) {
|
986
|
+
const parsed = parseCookieType(data);
|
987
|
+
const keys = Object.keys(parsed);
|
988
|
+
if (!keys.length) {
|
989
|
+
return void 0;
|
990
|
+
}
|
991
|
+
const results = {};
|
992
|
+
Object.keys(parsed).forEach((k) => {
|
993
|
+
const variants = parsed[k].split(",");
|
994
|
+
const key = decodeURIComponent(k);
|
995
|
+
results[key] = variants.map((variant) => {
|
996
|
+
const [index, control] = variant.split(":");
|
997
|
+
return {
|
998
|
+
index: parseInt(index, 10),
|
999
|
+
control: control === "1"
|
1000
|
+
};
|
1001
|
+
});
|
1002
|
+
});
|
1003
|
+
return results;
|
1004
|
+
}
|
896
1005
|
function encodeCookieType(type) {
|
897
1006
|
return Object.entries(type).reduce((acc, [key, value]) => {
|
898
1007
|
acc[key] = ntob(value);
|
@@ -980,7 +1089,8 @@ var emptyVisitorData = () => ({
|
|
980
1089
|
sessionScores: {},
|
981
1090
|
tests: {},
|
982
1091
|
consent: false,
|
983
|
-
controlGroup: false
|
1092
|
+
controlGroup: false,
|
1093
|
+
personalizeVariants: {}
|
984
1094
|
});
|
985
1095
|
|
986
1096
|
// src/storage/VisitorDataStore.ts
|
@@ -1029,6 +1139,25 @@ function applyCommandsToData(commands, state, inControlGroup) {
|
|
1029
1139
|
case "setcontrol":
|
1030
1140
|
newData.controlGroup = command.data;
|
1031
1141
|
break;
|
1142
|
+
case "setpersonalizecontrol":
|
1143
|
+
if (!newData.personalizeVariants) {
|
1144
|
+
newData.personalizeVariants = {};
|
1145
|
+
}
|
1146
|
+
if (!newData.personalizeVariants[command.data.personlizationName]) {
|
1147
|
+
newData.personalizeVariants[command.data.personlizationName] = [];
|
1148
|
+
}
|
1149
|
+
const existingDef = newData.personalizeVariants[command.data.personlizationName].find(
|
1150
|
+
(i) => i.index === command.data.index
|
1151
|
+
);
|
1152
|
+
if (!existingDef) {
|
1153
|
+
newData.personalizeVariants[command.data.personlizationName].push({
|
1154
|
+
index: command.data.index,
|
1155
|
+
control: command.data.control
|
1156
|
+
});
|
1157
|
+
} else {
|
1158
|
+
console.warn("Overwriting existing control group definition is not allowed");
|
1159
|
+
}
|
1160
|
+
break;
|
1032
1161
|
default:
|
1033
1162
|
throw new Error(`Unknown command`);
|
1034
1163
|
}
|
@@ -1390,7 +1519,7 @@ var Context = class {
|
|
1390
1519
|
* will NOT result in a recomputation of signal state.
|
1391
1520
|
*/
|
1392
1521
|
async update(newData) {
|
1393
|
-
var _a, _b, _c;
|
1522
|
+
var _a, _b, _c, _d;
|
1394
1523
|
const commands = [];
|
1395
1524
|
const newServerSideTests = {};
|
1396
1525
|
if ((_a = __privateGet(this, _serverTransitionState)) == null ? void 0 : _a.quirks) {
|
@@ -1420,6 +1549,17 @@ var Context = class {
|
|
1420
1549
|
);
|
1421
1550
|
}
|
1422
1551
|
}
|
1552
|
+
if ((_c = __privateGet(this, _serverTransitionState)) == null ? void 0 : _c.personalizeVariants) {
|
1553
|
+
Object.keys(__privateGet(this, _serverTransitionState).personalizeVariants).forEach((personalizationName) => {
|
1554
|
+
const variants = __privateGet(this, _serverTransitionState).personalizeVariants[personalizationName];
|
1555
|
+
variants.forEach((e) => {
|
1556
|
+
commands.push({
|
1557
|
+
type: "setpersonalizecontrol",
|
1558
|
+
data: { personlizationName: personalizationName, index: e.index, control: e.control }
|
1559
|
+
});
|
1560
|
+
});
|
1561
|
+
});
|
1562
|
+
}
|
1423
1563
|
try {
|
1424
1564
|
__privateGet(this, _mitt3).emit("log", [
|
1425
1565
|
"info",
|
@@ -1429,7 +1569,7 @@ var Context = class {
|
|
1429
1569
|
...newData,
|
1430
1570
|
// need to convert url to string so it can be json serialized
|
1431
1571
|
// to go over postMessage to chrome extension
|
1432
|
-
url: (
|
1572
|
+
url: (_d = newData.url) == null ? void 0 : _d.toString()
|
1433
1573
|
}
|
1434
1574
|
]);
|
1435
1575
|
if (newData.quirks) {
|
@@ -1511,6 +1651,13 @@ var Context = class {
|
|
1511
1651
|
}
|
1512
1652
|
]);
|
1513
1653
|
}
|
1654
|
+
getPersonalizeVariantControl(name, index) {
|
1655
|
+
var _a, _b, _c;
|
1656
|
+
const source = (_b = (_a = __privateGet(this, _serverTransitionState)) == null ? void 0 : _a.personalizeVariants) != null ? _b : this.storage.data.personalizeVariants;
|
1657
|
+
const variants = (_c = source == null ? void 0 : source[name]) != null ? _c : [];
|
1658
|
+
const variant = variants.find((v) => v.index === index);
|
1659
|
+
return variant == null ? void 0 : variant.control;
|
1660
|
+
}
|
1514
1661
|
/**
|
1515
1662
|
* Writes a message to the Context log sink.
|
1516
1663
|
* Used by Uniform internal SDK; not intended for public use.
|
@@ -1553,10 +1700,10 @@ var Context = class {
|
|
1553
1700
|
const previousPlacement = __privateGet(this, _pzCache)[options.name];
|
1554
1701
|
const eventData = {
|
1555
1702
|
name: options.name,
|
1556
|
-
variantIds: value.variations.map((variation) => {
|
1557
|
-
|
1558
|
-
|
1559
|
-
}),
|
1703
|
+
variantIds: value.variations.map((variation) => ({
|
1704
|
+
id: variation.id || "Unknown",
|
1705
|
+
control: variation.control
|
1706
|
+
})),
|
1560
1707
|
control: this.storage.data.controlGroup,
|
1561
1708
|
changed: true
|
1562
1709
|
};
|
@@ -1584,7 +1731,8 @@ var Context = class {
|
|
1584
1731
|
const transitionState = {
|
1585
1732
|
quirks: this.storage.data.quirks,
|
1586
1733
|
ssv: __privateGet(this, _scores),
|
1587
|
-
tests: {}
|
1734
|
+
tests: {},
|
1735
|
+
personalizeVariants: this.storage.data.personalizeVariants
|
1588
1736
|
};
|
1589
1737
|
const allTests = this.storage.data.tests;
|
1590
1738
|
Object.entries(allTests).map(([testName, testValue]) => {
|
@@ -17,6 +17,13 @@ type EnrichmentData = {
|
|
17
17
|
/** Strength value (amount of score added when viewing content) */
|
18
18
|
str: number;
|
19
19
|
};
|
20
|
+
type PersonalizeControlVariant = {
|
21
|
+
index: number;
|
22
|
+
control: boolean;
|
23
|
+
};
|
24
|
+
type PersonalizeVariants = {
|
25
|
+
[key: string]: PersonalizeControlVariant[];
|
26
|
+
};
|
20
27
|
/** An event that has occurred (i.e. an analytics track) which may trigger an Event signal */
|
21
28
|
type EventData = {
|
22
29
|
/** The event name that has been fired */
|
@@ -55,6 +62,10 @@ type VisitorData = {
|
|
55
62
|
* based on the control group size.
|
56
63
|
*/
|
57
64
|
controlGroup?: boolean;
|
65
|
+
/**
|
66
|
+
* Records of personalized variants that have been shown to the visitor and their control group status
|
67
|
+
*/
|
68
|
+
personalizeVariants?: PersonalizeVariants;
|
58
69
|
};
|
59
70
|
declare const emptyVisitorData: () => VisitorData;
|
60
71
|
/**
|
@@ -79,7 +90,7 @@ type StorageCommand<TID extends string = string, TData = unknown> = {
|
|
79
90
|
data: TData;
|
80
91
|
};
|
81
92
|
/** Commands that can be issued to alter the storage of Uniform Context data */
|
82
|
-
type StorageCommands = ModifyScoreCommand | ModifySessionScoreCommand | SetConsentCommand | SetQuirkCommand | SetTestCommand | IdentifyCommand | SetControlGroupCommand;
|
93
|
+
type StorageCommands = ModifyScoreCommand | ModifySessionScoreCommand | SetConsentCommand | SetQuirkCommand | SetTestCommand | IdentifyCommand | SetControlGroupCommand | SetPersonalizeVariantControlCommand;
|
83
94
|
/**
|
84
95
|
* Changes the visitor's permanent score for a given dimension
|
85
96
|
*/
|
@@ -125,11 +136,16 @@ type IdentifyCommand = StorageCommand<'identify', {
|
|
125
136
|
* this command is intended mostly for diagnostics and testing purposes.
|
126
137
|
*/
|
127
138
|
type SetControlGroupCommand = StorageCommand<'setcontrol', boolean>;
|
139
|
+
type SetPersonalizeVariantControlCommand = StorageCommand<'setpersonalizecontrol', {
|
140
|
+
personlizationName: string;
|
141
|
+
index: number;
|
142
|
+
control: boolean;
|
143
|
+
}>;
|
128
144
|
|
129
145
|
type TransitionDataStoreOptions = {
|
130
146
|
initialData?: Partial<VisitorData>;
|
131
147
|
};
|
132
|
-
type ServerToClientTransitionState = Pick<Partial<VisitorData>, 'quirks' | 'tests'> & {
|
148
|
+
type ServerToClientTransitionState = Pick<Partial<VisitorData>, 'quirks' | 'tests' | 'personalizeVariants'> & {
|
133
149
|
/**
|
134
150
|
* Server Score Vector - the resultant scores _on the server side_ after the server/edge render completes
|
135
151
|
* Note that the client side does not trust these scores; they are only used until it's done with initial
|
@@ -826,6 +842,10 @@ type VariantMatchCriteria = {
|
|
826
842
|
* Name of the variant for analytics tracking.
|
827
843
|
*/
|
828
844
|
name?: string;
|
845
|
+
/**
|
846
|
+
* Control group percentage for the variant.
|
847
|
+
*/
|
848
|
+
control?: number;
|
829
849
|
};
|
830
850
|
type DimensionMatch = {
|
831
851
|
/**
|
@@ -836,7 +856,8 @@ type DimensionMatch = {
|
|
836
856
|
/**
|
837
857
|
* Operator of the match expression
|
838
858
|
* Whole-vector (RHS only) operators - these do not require a `r` or `rDim` set:
|
839
|
-
* +: `l` is the strongest dimension in the score vector
|
859
|
+
* +: `l` is the strongest dimension in the score vector across all categories
|
860
|
+
* ^: `l` is the strongest dimension in the specified category
|
840
861
|
* -: `l` is the weakest dimension in the score vector. This does not match if the dimension has no score at all.
|
841
862
|
*
|
842
863
|
* Comparison operators:
|
@@ -847,7 +868,7 @@ type DimensionMatch = {
|
|
847
868
|
* =: `l` is equal to the right hand side expression
|
848
869
|
* !=: `l` is not equal to the right hand side expression
|
849
870
|
*/
|
850
|
-
op: '+' | '-' | '>' | '>=' | '<' | '<=' | '=' | '!=';
|
871
|
+
op: '+' | '-' | '>' | '>=' | '<' | '<=' | '=' | '!=' | '^';
|
851
872
|
/**
|
852
873
|
* Right hand side of the match expression (not required for op = + or - which have no right side)
|
853
874
|
* This value is treated as a constant value, if it is present. If it's a string, it is parsed to an integer.
|
@@ -881,7 +902,9 @@ type PersonalizedResult<TVariant> = {
|
|
881
902
|
/** Whether or not this result contains a personalized result */
|
882
903
|
personalized: boolean;
|
883
904
|
/** Matching variations */
|
884
|
-
variations: Array<TVariant
|
905
|
+
variations: Array<TVariant & {
|
906
|
+
control: boolean;
|
907
|
+
}>;
|
885
908
|
};
|
886
909
|
/** Defines the shape of a A/B test variant */
|
887
910
|
type TestVariant = {
|
@@ -957,7 +980,10 @@ type PersonalizationEvent = {
|
|
957
980
|
/** Name of the personalized placement */
|
958
981
|
name: string;
|
959
982
|
/** Selected variant ID(s) */
|
960
|
-
variantIds:
|
983
|
+
variantIds: {
|
984
|
+
id: string;
|
985
|
+
control: boolean;
|
986
|
+
}[];
|
961
987
|
/** Whether the user was part of the control group (and did not receive any personalization) */
|
962
988
|
control: boolean | undefined;
|
963
989
|
/**
|
@@ -1056,6 +1082,7 @@ declare class Context implements ContextInstance {
|
|
1056
1082
|
getTestVariantId(testName: string): string | null | undefined;
|
1057
1083
|
/** use test() instead */
|
1058
1084
|
setTestVariantId(testName: string, variantId: string): void;
|
1085
|
+
getPersonalizeVariantControl(name: string, index: number): boolean | undefined;
|
1059
1086
|
/**
|
1060
1087
|
* Writes a message to the Context log sink.
|
1061
1088
|
* Used by Uniform internal SDK; not intended for public use.
|
@@ -1146,4 +1173,4 @@ declare global {
|
|
1146
1173
|
}
|
1147
1174
|
}
|
1148
1175
|
|
1149
|
-
export { type TestOptions as $, type AggregateDimension as A, type MessageFunc as B, type ContextPlugin as C, type DecayFunction as D, type LogMessageSingle as E, type LogMessageGroup as F, ManifestInstance as G, GroupCriteriaEvaluator as H, type CriteriaEvaluatorResult as I, type CriteriaEvaluatorParameters as J, type SignalData as K, type LogDrain as L, type MessageCategory as M, type ManifestV2 as N, type OutputSeverity as O, type PersonalizationEvent as P, type PersonalizationManifest as Q, type Signal as R, type ScoreVector as S, TransitionDataStore as T, type SignalCriteriaGroup as U, type VisitorData as V, type SignalCriteria as W, type EnrichmentCategory as X, type NumberMatch as Y, type TestDefinition as Z, type AggregateDimensionInput as _, type StorageCommands as a, testVariations as a0, type DimensionMatch as a1, type PersonalizeOptions as a2, personalizeVariations as a3, type BehaviorTag as a4, type PersonalizedVariant as a5, type PersonalizedResult as a6, type TestVariant as a7, type TestResult as a8, type StorageCommand as a9, type ModifyScoreCommand as aa, type ModifySessionScoreCommand as ab, type SetConsentCommand as ac, type SetQuirkCommand as ad, type SetTestCommand as ae, type IdentifyCommand as af, type SetControlGroupCommand as ag, type
|
1176
|
+
export { type TestOptions as $, type AggregateDimension as A, type MessageFunc as B, type ContextPlugin as C, type DecayFunction as D, type LogMessageSingle as E, type LogMessageGroup as F, ManifestInstance as G, GroupCriteriaEvaluator as H, type CriteriaEvaluatorResult as I, type CriteriaEvaluatorParameters as J, type SignalData as K, type LogDrain as L, type MessageCategory as M, type ManifestV2 as N, type OutputSeverity as O, type PersonalizationEvent as P, type PersonalizationManifest as Q, type Signal as R, type ScoreVector as S, TransitionDataStore as T, type SignalCriteriaGroup as U, type VisitorData as V, type SignalCriteria as W, type EnrichmentCategory as X, type NumberMatch as Y, type TestDefinition as Z, type AggregateDimensionInput as _, type StorageCommands as a, testVariations as a0, type DimensionMatch as a1, type PersonalizeOptions as a2, personalizeVariations as a3, type BehaviorTag as a4, type PersonalizedVariant as a5, type PersonalizedResult as a6, type TestVariant as a7, type TestResult as a8, type StorageCommand as a9, type ModifyScoreCommand as aa, type ModifySessionScoreCommand as ab, type SetConsentCommand as ac, type SetQuirkCommand as ad, type SetTestCommand as ae, type IdentifyCommand as af, type SetControlGroupCommand as ag, type SetPersonalizeVariantControlCommand as ah, type ServerToClientTransitionState as ai, SERVER_STATE_ID as aj, type TransitionDataStoreEvents as ak, type DecayOptions as al, type VisitorDataStoreOptions as am, type VisitorDataStoreEvents as an, VisitorDataStore as ao, type Quirks as ap, type Tests as aq, type EnrichmentData as ar, type PersonalizeControlVariant as as, type PersonalizeVariants as at, type EventData as au, emptyVisitorData as av, type ContextState as aw, type ContextStateUpdate as ax, type paths as ay, type TransitionDataStoreOptions as b, type CriteriaEvaluator as c, type StringMatch as d, type VariantMatchCriteria as e, type LogMessage as f, type DevToolsEvents as g, CONTEXTUAL_EDITING_TEST_NAME as h, CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID as i, type ContextOptions as j, type TestEvent as k, type ContextEvents as l, type ContextInstance as m, Context as n, type DevToolsUiVersion as o, type DevToolsState as p, type DevToolsActions as q, type DevToolsEvent as r, type DevToolsLogEvent as s, type DevToolsDataEvent as t, type DevToolsHelloEvent as u, type DevToolsUpdateEvent as v, type DevToolsRawCommandsEvent as w, type DevToolsForgetEvent as x, type LogMessages as y, type Severity as z };
|
@@ -17,6 +17,13 @@ type EnrichmentData = {
|
|
17
17
|
/** Strength value (amount of score added when viewing content) */
|
18
18
|
str: number;
|
19
19
|
};
|
20
|
+
type PersonalizeControlVariant = {
|
21
|
+
index: number;
|
22
|
+
control: boolean;
|
23
|
+
};
|
24
|
+
type PersonalizeVariants = {
|
25
|
+
[key: string]: PersonalizeControlVariant[];
|
26
|
+
};
|
20
27
|
/** An event that has occurred (i.e. an analytics track) which may trigger an Event signal */
|
21
28
|
type EventData = {
|
22
29
|
/** The event name that has been fired */
|
@@ -55,6 +62,10 @@ type VisitorData = {
|
|
55
62
|
* based on the control group size.
|
56
63
|
*/
|
57
64
|
controlGroup?: boolean;
|
65
|
+
/**
|
66
|
+
* Records of personalized variants that have been shown to the visitor and their control group status
|
67
|
+
*/
|
68
|
+
personalizeVariants?: PersonalizeVariants;
|
58
69
|
};
|
59
70
|
declare const emptyVisitorData: () => VisitorData;
|
60
71
|
/**
|
@@ -79,7 +90,7 @@ type StorageCommand<TID extends string = string, TData = unknown> = {
|
|
79
90
|
data: TData;
|
80
91
|
};
|
81
92
|
/** Commands that can be issued to alter the storage of Uniform Context data */
|
82
|
-
type StorageCommands = ModifyScoreCommand | ModifySessionScoreCommand | SetConsentCommand | SetQuirkCommand | SetTestCommand | IdentifyCommand | SetControlGroupCommand;
|
93
|
+
type StorageCommands = ModifyScoreCommand | ModifySessionScoreCommand | SetConsentCommand | SetQuirkCommand | SetTestCommand | IdentifyCommand | SetControlGroupCommand | SetPersonalizeVariantControlCommand;
|
83
94
|
/**
|
84
95
|
* Changes the visitor's permanent score for a given dimension
|
85
96
|
*/
|
@@ -125,11 +136,16 @@ type IdentifyCommand = StorageCommand<'identify', {
|
|
125
136
|
* this command is intended mostly for diagnostics and testing purposes.
|
126
137
|
*/
|
127
138
|
type SetControlGroupCommand = StorageCommand<'setcontrol', boolean>;
|
139
|
+
type SetPersonalizeVariantControlCommand = StorageCommand<'setpersonalizecontrol', {
|
140
|
+
personlizationName: string;
|
141
|
+
index: number;
|
142
|
+
control: boolean;
|
143
|
+
}>;
|
128
144
|
|
129
145
|
type TransitionDataStoreOptions = {
|
130
146
|
initialData?: Partial<VisitorData>;
|
131
147
|
};
|
132
|
-
type ServerToClientTransitionState = Pick<Partial<VisitorData>, 'quirks' | 'tests'> & {
|
148
|
+
type ServerToClientTransitionState = Pick<Partial<VisitorData>, 'quirks' | 'tests' | 'personalizeVariants'> & {
|
133
149
|
/**
|
134
150
|
* Server Score Vector - the resultant scores _on the server side_ after the server/edge render completes
|
135
151
|
* Note that the client side does not trust these scores; they are only used until it's done with initial
|
@@ -826,6 +842,10 @@ type VariantMatchCriteria = {
|
|
826
842
|
* Name of the variant for analytics tracking.
|
827
843
|
*/
|
828
844
|
name?: string;
|
845
|
+
/**
|
846
|
+
* Control group percentage for the variant.
|
847
|
+
*/
|
848
|
+
control?: number;
|
829
849
|
};
|
830
850
|
type DimensionMatch = {
|
831
851
|
/**
|
@@ -836,7 +856,8 @@ type DimensionMatch = {
|
|
836
856
|
/**
|
837
857
|
* Operator of the match expression
|
838
858
|
* Whole-vector (RHS only) operators - these do not require a `r` or `rDim` set:
|
839
|
-
* +: `l` is the strongest dimension in the score vector
|
859
|
+
* +: `l` is the strongest dimension in the score vector across all categories
|
860
|
+
* ^: `l` is the strongest dimension in the specified category
|
840
861
|
* -: `l` is the weakest dimension in the score vector. This does not match if the dimension has no score at all.
|
841
862
|
*
|
842
863
|
* Comparison operators:
|
@@ -847,7 +868,7 @@ type DimensionMatch = {
|
|
847
868
|
* =: `l` is equal to the right hand side expression
|
848
869
|
* !=: `l` is not equal to the right hand side expression
|
849
870
|
*/
|
850
|
-
op: '+' | '-' | '>' | '>=' | '<' | '<=' | '=' | '!=';
|
871
|
+
op: '+' | '-' | '>' | '>=' | '<' | '<=' | '=' | '!=' | '^';
|
851
872
|
/**
|
852
873
|
* Right hand side of the match expression (not required for op = + or - which have no right side)
|
853
874
|
* This value is treated as a constant value, if it is present. If it's a string, it is parsed to an integer.
|
@@ -881,7 +902,9 @@ type PersonalizedResult<TVariant> = {
|
|
881
902
|
/** Whether or not this result contains a personalized result */
|
882
903
|
personalized: boolean;
|
883
904
|
/** Matching variations */
|
884
|
-
variations: Array<TVariant
|
905
|
+
variations: Array<TVariant & {
|
906
|
+
control: boolean;
|
907
|
+
}>;
|
885
908
|
};
|
886
909
|
/** Defines the shape of a A/B test variant */
|
887
910
|
type TestVariant = {
|
@@ -957,7 +980,10 @@ type PersonalizationEvent = {
|
|
957
980
|
/** Name of the personalized placement */
|
958
981
|
name: string;
|
959
982
|
/** Selected variant ID(s) */
|
960
|
-
variantIds:
|
983
|
+
variantIds: {
|
984
|
+
id: string;
|
985
|
+
control: boolean;
|
986
|
+
}[];
|
961
987
|
/** Whether the user was part of the control group (and did not receive any personalization) */
|
962
988
|
control: boolean | undefined;
|
963
989
|
/**
|
@@ -1056,6 +1082,7 @@ declare class Context implements ContextInstance {
|
|
1056
1082
|
getTestVariantId(testName: string): string | null | undefined;
|
1057
1083
|
/** use test() instead */
|
1058
1084
|
setTestVariantId(testName: string, variantId: string): void;
|
1085
|
+
getPersonalizeVariantControl(name: string, index: number): boolean | undefined;
|
1059
1086
|
/**
|
1060
1087
|
* Writes a message to the Context log sink.
|
1061
1088
|
* Used by Uniform internal SDK; not intended for public use.
|
@@ -1146,4 +1173,4 @@ declare global {
|
|
1146
1173
|
}
|
1147
1174
|
}
|
1148
1175
|
|
1149
|
-
export { type TestOptions as $, type AggregateDimension as A, type MessageFunc as B, type ContextPlugin as C, type DecayFunction as D, type LogMessageSingle as E, type LogMessageGroup as F, ManifestInstance as G, GroupCriteriaEvaluator as H, type CriteriaEvaluatorResult as I, type CriteriaEvaluatorParameters as J, type SignalData as K, type LogDrain as L, type MessageCategory as M, type ManifestV2 as N, type OutputSeverity as O, type PersonalizationEvent as P, type PersonalizationManifest as Q, type Signal as R, type ScoreVector as S, TransitionDataStore as T, type SignalCriteriaGroup as U, type VisitorData as V, type SignalCriteria as W, type EnrichmentCategory as X, type NumberMatch as Y, type TestDefinition as Z, type AggregateDimensionInput as _, type StorageCommands as a, testVariations as a0, type DimensionMatch as a1, type PersonalizeOptions as a2, personalizeVariations as a3, type BehaviorTag as a4, type PersonalizedVariant as a5, type PersonalizedResult as a6, type TestVariant as a7, type TestResult as a8, type StorageCommand as a9, type ModifyScoreCommand as aa, type ModifySessionScoreCommand as ab, type SetConsentCommand as ac, type SetQuirkCommand as ad, type SetTestCommand as ae, type IdentifyCommand as af, type SetControlGroupCommand as ag, type
|
1176
|
+
export { type TestOptions as $, type AggregateDimension as A, type MessageFunc as B, type ContextPlugin as C, type DecayFunction as D, type LogMessageSingle as E, type LogMessageGroup as F, ManifestInstance as G, GroupCriteriaEvaluator as H, type CriteriaEvaluatorResult as I, type CriteriaEvaluatorParameters as J, type SignalData as K, type LogDrain as L, type MessageCategory as M, type ManifestV2 as N, type OutputSeverity as O, type PersonalizationEvent as P, type PersonalizationManifest as Q, type Signal as R, type ScoreVector as S, TransitionDataStore as T, type SignalCriteriaGroup as U, type VisitorData as V, type SignalCriteria as W, type EnrichmentCategory as X, type NumberMatch as Y, type TestDefinition as Z, type AggregateDimensionInput as _, type StorageCommands as a, testVariations as a0, type DimensionMatch as a1, type PersonalizeOptions as a2, personalizeVariations as a3, type BehaviorTag as a4, type PersonalizedVariant as a5, type PersonalizedResult as a6, type TestVariant as a7, type TestResult as a8, type StorageCommand as a9, type ModifyScoreCommand as aa, type ModifySessionScoreCommand as ab, type SetConsentCommand as ac, type SetQuirkCommand as ad, type SetTestCommand as ae, type IdentifyCommand as af, type SetControlGroupCommand as ag, type SetPersonalizeVariantControlCommand as ah, type ServerToClientTransitionState as ai, SERVER_STATE_ID as aj, type TransitionDataStoreEvents as ak, type DecayOptions as al, type VisitorDataStoreOptions as am, type VisitorDataStoreEvents as an, VisitorDataStore as ao, type Quirks as ap, type Tests as aq, type EnrichmentData as ar, type PersonalizeControlVariant as as, type PersonalizeVariants as at, type EventData as au, emptyVisitorData as av, type ContextState as aw, type ContextStateUpdate as ax, type paths as ay, type TransitionDataStoreOptions as b, type CriteriaEvaluator as c, type StringMatch as d, type VariantMatchCriteria as e, type LogMessage as f, type DevToolsEvents as g, CONTEXTUAL_EDITING_TEST_NAME as h, CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID as i, type ContextOptions as j, type TestEvent as k, type ContextEvents as l, type ContextInstance as m, Context as n, type DevToolsUiVersion as o, type DevToolsState as p, type DevToolsActions as q, type DevToolsEvent as r, type DevToolsLogEvent as s, type DevToolsDataEvent as t, type DevToolsHelloEvent as u, type DevToolsUpdateEvent as v, type DevToolsRawCommandsEvent as w, type DevToolsForgetEvent as x, type LogMessages as y, type Severity as z };
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@uniformdev/context",
|
3
|
-
"version": "19.
|
3
|
+
"version": "19.133.0",
|
4
4
|
"description": "Uniform Context core package",
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
6
6
|
"main": "./dist/index.js",
|
@@ -66,5 +66,5 @@
|
|
66
66
|
"publishConfig": {
|
67
67
|
"access": "public"
|
68
68
|
},
|
69
|
-
"gitHead": "
|
69
|
+
"gitHead": "405a628b0f592ca13bf65006ef5c92261468c144"
|
70
70
|
}
|