@uniformdev/context 19.128.1-alpha.8 → 19.130.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 +18 -147
- package/dist/index.js +18 -147
- package/dist/index.mjs +18 -147
- package/dist/{types-zhN7Sdp3.d.mts → types-R41eD1zH.d.mts} +4 -25
- package/dist/{types-zhN7Sdp3.d.ts → types-R41eD1zH.d.ts} +4 -25
- 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-R41eD1zH.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, at as ContextState, au as ContextStateUpdate, J as CriteriaEvaluatorParameters, I as CriteriaEvaluatorResult, ak 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, aq as EnrichmentData, ar 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, a2 as PersonalizeOptions, a6 as PersonalizedResult, a5 as PersonalizedVariant, ao as Quirks, ai as SERVER_STATE_ID, ah as ServerToClientTransitionState, ac as SetConsentCommand, ag as SetControlGroupCommand, 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, ap as Tests, aj as TransitionDataStoreEvents, an as VisitorDataStore, am as VisitorDataStoreEvents, al as VisitorDataStoreOptions, as as emptyVisitorData, a3 as personalizeVariations, a0 as testVariations } from './types-R41eD1zH.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-R41eD1zH.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, at as ContextState, au as ContextStateUpdate, J as CriteriaEvaluatorParameters, I as CriteriaEvaluatorResult, ak 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, aq as EnrichmentData, ar 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, a2 as PersonalizeOptions, a6 as PersonalizedResult, a5 as PersonalizedVariant, ao as Quirks, ai as SERVER_STATE_ID, ah as ServerToClientTransitionState, ac as SetConsentCommand, ag as SetControlGroupCommand, 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, ap as Tests, aj as TransitionDataStoreEvents, an as VisitorDataStore, am as VisitorDataStoreEvents, al as VisitorDataStoreOptions, as as emptyVisitorData, a3 as personalizeVariations, a0 as testVariations } from './types-R41eD1zH.js';
|
3
3
|
import Cookies from 'js-cookie';
|
4
4
|
import 'mitt';
|
5
5
|
|
package/dist/index.esm.js
CHANGED
@@ -123,15 +123,6 @@ 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
|
-
|
135
126
|
// src/manifest/ManifestInstance.ts
|
136
127
|
var _mf, _signalInstances, _onLogMessage2;
|
137
128
|
var ManifestInstance = class {
|
@@ -155,8 +146,12 @@ var ManifestInstance = class {
|
|
155
146
|
__privateSet(this, _onLogMessage2, onLogMessage);
|
156
147
|
}
|
157
148
|
rollForControlGroup() {
|
158
|
-
var _a;
|
159
|
-
|
149
|
+
var _a, _b;
|
150
|
+
let control = (_b = (_a = __privateGet(this, _mf).pz) == null ? void 0 : _a.control) != null ? _b : 0;
|
151
|
+
if (control >= 1) {
|
152
|
+
control = control / 100;
|
153
|
+
}
|
154
|
+
return Math.random() < control;
|
160
155
|
}
|
161
156
|
getTest(name) {
|
162
157
|
var _a;
|
@@ -504,30 +499,7 @@ function evaluateDimensionMatch(crit, vec, onLogMessage) {
|
|
504
499
|
var _a, _b;
|
505
500
|
const { op, l: lhs } = crit;
|
506
501
|
const lhsScore = (_a = vec[lhs]) != null ? _a : 0;
|
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 === "+") {
|
502
|
+
if (op === "+") {
|
531
503
|
const result = Math.max(...Object.values(vec)) === lhsScore && lhsScore > 0;
|
532
504
|
onLogMessage == null ? void 0 : onLogMessage([
|
533
505
|
"info",
|
@@ -614,27 +586,19 @@ function personalizeVariations({
|
|
614
586
|
take = 1,
|
615
587
|
onLogMessage
|
616
588
|
}) {
|
617
|
-
var _a, _b, _c
|
589
|
+
var _a, _b, _c;
|
618
590
|
onLogMessage == null ? void 0 : onLogMessage(["info", 300, "GROUP", { name, take }]);
|
619
591
|
try {
|
620
592
|
const control = (_a = context.storage.data.controlGroup) != null ? _a : false;
|
621
593
|
const results = [];
|
622
594
|
let personalized = false;
|
623
595
|
const scores = context.scores;
|
624
|
-
let index = 0;
|
625
|
-
const defaultVariants = [];
|
626
596
|
for (const variant of variations) {
|
627
|
-
if (!((_b = variant.pz) == null ? void 0 : _b.crit.length)) {
|
628
|
-
defaultVariants.push(variant);
|
629
|
-
}
|
630
|
-
}
|
631
|
-
for (const variant of variations) {
|
632
|
-
const currentIndex = index++;
|
633
597
|
if (results.length === take) {
|
634
598
|
break;
|
635
599
|
}
|
636
|
-
if (!((
|
637
|
-
onLogMessage == null ? void 0 : onLogMessage(["info", 301, "GROUP", { id: variant.id, op: (
|
600
|
+
if (!((_b = variant.pz) == null ? void 0 : _b.crit.length)) {
|
601
|
+
onLogMessage == null ? void 0 : onLogMessage(["info", 301, "GROUP", { id: variant.id, op: (_c = variant.pz) == null ? void 0 : _c.op }]);
|
638
602
|
onLogMessage == null ? void 0 : onLogMessage(["info", 302, { matched: true, description: "default variation" }]);
|
639
603
|
onLogMessage == null ? void 0 : onLogMessage(["info", 303, true]);
|
640
604
|
onLogMessage == null ? void 0 : onLogMessage(["info", 301, "ENDGROUP"]);
|
@@ -645,32 +609,8 @@ function personalizeVariations({
|
|
645
609
|
continue;
|
646
610
|
}
|
647
611
|
if (evaluateVariantMatch(variant.id, variant.pz, scores, onLogMessage)) {
|
648
|
-
|
649
|
-
|
650
|
-
const testVariants = (_e = context.storage.data.personalizeVariants) == null ? void 0 : _e[name];
|
651
|
-
const entry = testVariants == null ? void 0 : testVariants.find((v) => v.index === currentIndex);
|
652
|
-
let isControl = false;
|
653
|
-
if (typeof entry !== "undefined") {
|
654
|
-
isControl = entry.control;
|
655
|
-
} else {
|
656
|
-
isControl = rollForControlGroup(variant.pz.control);
|
657
|
-
context.storage.updateData([
|
658
|
-
{
|
659
|
-
type: "setpersonalizecontrol",
|
660
|
-
data: {
|
661
|
-
personlizationName: name,
|
662
|
-
index: currentIndex,
|
663
|
-
control: isControl
|
664
|
-
}
|
665
|
-
}
|
666
|
-
]);
|
667
|
-
}
|
668
|
-
if (isControl) {
|
669
|
-
variantToAdd = defaultVariants[0];
|
670
|
-
}
|
671
|
-
}
|
672
|
-
personalized = variant.id === variantToAdd.id;
|
673
|
-
results.push(variantToAdd);
|
612
|
+
personalized = true;
|
613
|
+
results.push(variant);
|
674
614
|
}
|
675
615
|
}
|
676
616
|
return {
|
@@ -917,19 +857,16 @@ function parseScoreCookie(cookieValue) {
|
|
917
857
|
if (!cookieValue)
|
918
858
|
return;
|
919
859
|
const types = cookieValue.split(TYPE_SEP);
|
920
|
-
if (types.length >
|
860
|
+
if (types.length > 3)
|
921
861
|
return;
|
922
|
-
const [abTestData, sessionScores, visitorScores
|
923
|
-
|
862
|
+
const [abTestData, sessionScores, visitorScores] = types;
|
863
|
+
return {
|
924
864
|
// this is true since we're reading a cookie, which wouldn't exist if consent wasn't given
|
925
865
|
consent: true,
|
926
866
|
sessionScores: decodeCookieType(parseCookieType(sessionScores)),
|
927
867
|
scores: decodeCookieType(parseCookieType(visitorScores)),
|
928
|
-
tests: parseCookieType(abTestData)
|
929
|
-
controlGroup: controlGroup === "1",
|
930
|
-
personalizeVariants: decodePersonalizeVariants(personalizeVariants)
|
868
|
+
tests: parseCookieType(abTestData)
|
931
869
|
};
|
932
|
-
return data;
|
933
870
|
}
|
934
871
|
function parseCookieType(type) {
|
935
872
|
if (!type) {
|
@@ -953,51 +890,9 @@ function serializeCookie(data) {
|
|
953
890
|
return [
|
954
891
|
serializeCookieType(data.tests),
|
955
892
|
serializeCookieType(encodeCookieType(data.sessionScores)),
|
956
|
-
serializeCookieType(encodeCookieType(data.scores))
|
957
|
-
data.controlGroup ? "1" : "0",
|
958
|
-
serializePersonalizeVariants(data)
|
893
|
+
serializeCookieType(encodeCookieType(data.scores))
|
959
894
|
].join(TYPE_SEP);
|
960
895
|
}
|
961
|
-
function serializePersonalizeVariants({
|
962
|
-
personalizeVariants
|
963
|
-
}) {
|
964
|
-
const data = {};
|
965
|
-
if (typeof personalizeVariants === "object") {
|
966
|
-
Object.keys(personalizeVariants).forEach((personalizationName) => {
|
967
|
-
let number = BigInt(0);
|
968
|
-
const variants = personalizeVariants[personalizationName];
|
969
|
-
variants.forEach((variant) => {
|
970
|
-
if (variant.control) {
|
971
|
-
number = flipNthBitTo1BigInt(number, variant.index);
|
972
|
-
}
|
973
|
-
});
|
974
|
-
data[personalizationName] = number.toString(10);
|
975
|
-
});
|
976
|
-
}
|
977
|
-
return serializeCookieType(data);
|
978
|
-
}
|
979
|
-
function decodePersonalizeVariants(data) {
|
980
|
-
const parsed = parseCookieType(data);
|
981
|
-
const keys = Object.keys(parsed);
|
982
|
-
if (!keys.length) {
|
983
|
-
return void 0;
|
984
|
-
}
|
985
|
-
const personalizeVariants = {};
|
986
|
-
keys.forEach((personalizationName) => {
|
987
|
-
personalizeVariants[personalizationName] = [];
|
988
|
-
const value = BigInt(parsed[personalizationName]);
|
989
|
-
const asBinary = value.toString(2);
|
990
|
-
for (let i = 0; i < asBinary.length; i++) {
|
991
|
-
if (asBinary[i] === "1") {
|
992
|
-
personalizeVariants[personalizationName].push({
|
993
|
-
index: asBinary.length - i,
|
994
|
-
control: true
|
995
|
-
});
|
996
|
-
}
|
997
|
-
}
|
998
|
-
});
|
999
|
-
return personalizeVariants;
|
1000
|
-
}
|
1001
896
|
function encodeCookieType(type) {
|
1002
897
|
return Object.entries(type).reduce((acc, [key, value]) => {
|
1003
898
|
acc[key] = ntob(value);
|
@@ -1007,9 +902,6 @@ function encodeCookieType(type) {
|
|
1007
902
|
function serializeCookieType(type) {
|
1008
903
|
return Object.entries(type).map((kv) => kv.join(KV_SEP)).join(PAIR_SEP);
|
1009
904
|
}
|
1010
|
-
function flipNthBitTo1BigInt(number, n) {
|
1011
|
-
return number | BigInt(1) << BigInt(n - 1);
|
1012
|
-
}
|
1013
905
|
|
1014
906
|
// src/storage/EdgeTransitionDataStore.ts
|
1015
907
|
var _fetchData, fetchData_fn;
|
@@ -1088,8 +980,7 @@ var emptyVisitorData = () => ({
|
|
1088
980
|
sessionScores: {},
|
1089
981
|
tests: {},
|
1090
982
|
consent: false,
|
1091
|
-
controlGroup: false
|
1092
|
-
personalizeVariants: {}
|
983
|
+
controlGroup: false
|
1093
984
|
});
|
1094
985
|
|
1095
986
|
// src/storage/VisitorDataStore.ts
|
@@ -1138,26 +1029,6 @@ function applyCommandsToData(commands, state, inControlGroup) {
|
|
1138
1029
|
case "setcontrol":
|
1139
1030
|
newData.controlGroup = command.data;
|
1140
1031
|
break;
|
1141
|
-
case "setpersonalizecontrol":
|
1142
|
-
if (!newData.personalizeVariants) {
|
1143
|
-
newData.personalizeVariants = {};
|
1144
|
-
}
|
1145
|
-
if (!newData.personalizeVariants[command.data.personlizationName]) {
|
1146
|
-
newData.personalizeVariants[command.data.personlizationName] = [];
|
1147
|
-
}
|
1148
|
-
const existingDef = newData.personalizeVariants[command.data.personlizationName].find(
|
1149
|
-
(i) => i.index === command.data.index
|
1150
|
-
);
|
1151
|
-
if (!existingDef) {
|
1152
|
-
const newDef = {
|
1153
|
-
index: command.data.index,
|
1154
|
-
control: command.data.control
|
1155
|
-
};
|
1156
|
-
newData.personalizeVariants[command.data.personlizationName].push(newDef);
|
1157
|
-
} else if (existingDef.control !== command.data.control) {
|
1158
|
-
existingDef.control = command.data.control;
|
1159
|
-
}
|
1160
|
-
break;
|
1161
1032
|
default:
|
1162
1033
|
throw new Error(`Unknown command`);
|
1163
1034
|
}
|
package/dist/index.js
CHANGED
@@ -193,15 +193,6 @@ 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
|
-
|
205
196
|
// src/manifest/ManifestInstance.ts
|
206
197
|
var _mf, _signalInstances, _onLogMessage2;
|
207
198
|
var ManifestInstance = class {
|
@@ -225,8 +216,12 @@ var ManifestInstance = class {
|
|
225
216
|
__privateSet(this, _onLogMessage2, onLogMessage);
|
226
217
|
}
|
227
218
|
rollForControlGroup() {
|
228
|
-
var _a;
|
229
|
-
|
219
|
+
var _a, _b;
|
220
|
+
let control = (_b = (_a = __privateGet(this, _mf).pz) == null ? void 0 : _a.control) != null ? _b : 0;
|
221
|
+
if (control >= 1) {
|
222
|
+
control = control / 100;
|
223
|
+
}
|
224
|
+
return Math.random() < control;
|
230
225
|
}
|
231
226
|
getTest(name) {
|
232
227
|
var _a;
|
@@ -574,30 +569,7 @@ function evaluateDimensionMatch(crit, vec, onLogMessage) {
|
|
574
569
|
var _a, _b;
|
575
570
|
const { op, l: lhs } = crit;
|
576
571
|
const lhsScore = (_a = vec[lhs]) != null ? _a : 0;
|
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 === "+") {
|
572
|
+
if (op === "+") {
|
601
573
|
const result = Math.max(...Object.values(vec)) === lhsScore && lhsScore > 0;
|
602
574
|
onLogMessage == null ? void 0 : onLogMessage([
|
603
575
|
"info",
|
@@ -684,27 +656,19 @@ function personalizeVariations({
|
|
684
656
|
take = 1,
|
685
657
|
onLogMessage
|
686
658
|
}) {
|
687
|
-
var _a, _b, _c
|
659
|
+
var _a, _b, _c;
|
688
660
|
onLogMessage == null ? void 0 : onLogMessage(["info", 300, "GROUP", { name, take }]);
|
689
661
|
try {
|
690
662
|
const control = (_a = context.storage.data.controlGroup) != null ? _a : false;
|
691
663
|
const results = [];
|
692
664
|
let personalized = false;
|
693
665
|
const scores = context.scores;
|
694
|
-
let index = 0;
|
695
|
-
const defaultVariants = [];
|
696
666
|
for (const variant of variations) {
|
697
|
-
if (!((_b = variant.pz) == null ? void 0 : _b.crit.length)) {
|
698
|
-
defaultVariants.push(variant);
|
699
|
-
}
|
700
|
-
}
|
701
|
-
for (const variant of variations) {
|
702
|
-
const currentIndex = index++;
|
703
667
|
if (results.length === take) {
|
704
668
|
break;
|
705
669
|
}
|
706
|
-
if (!((
|
707
|
-
onLogMessage == null ? void 0 : onLogMessage(["info", 301, "GROUP", { id: variant.id, op: (
|
670
|
+
if (!((_b = variant.pz) == null ? void 0 : _b.crit.length)) {
|
671
|
+
onLogMessage == null ? void 0 : onLogMessage(["info", 301, "GROUP", { id: variant.id, op: (_c = variant.pz) == null ? void 0 : _c.op }]);
|
708
672
|
onLogMessage == null ? void 0 : onLogMessage(["info", 302, { matched: true, description: "default variation" }]);
|
709
673
|
onLogMessage == null ? void 0 : onLogMessage(["info", 303, true]);
|
710
674
|
onLogMessage == null ? void 0 : onLogMessage(["info", 301, "ENDGROUP"]);
|
@@ -715,32 +679,8 @@ function personalizeVariations({
|
|
715
679
|
continue;
|
716
680
|
}
|
717
681
|
if (evaluateVariantMatch(variant.id, variant.pz, scores, onLogMessage)) {
|
718
|
-
|
719
|
-
|
720
|
-
const testVariants = (_e = context.storage.data.personalizeVariants) == null ? void 0 : _e[name];
|
721
|
-
const entry = testVariants == null ? void 0 : testVariants.find((v) => v.index === currentIndex);
|
722
|
-
let isControl = false;
|
723
|
-
if (typeof entry !== "undefined") {
|
724
|
-
isControl = entry.control;
|
725
|
-
} else {
|
726
|
-
isControl = rollForControlGroup(variant.pz.control);
|
727
|
-
context.storage.updateData([
|
728
|
-
{
|
729
|
-
type: "setpersonalizecontrol",
|
730
|
-
data: {
|
731
|
-
personlizationName: name,
|
732
|
-
index: currentIndex,
|
733
|
-
control: isControl
|
734
|
-
}
|
735
|
-
}
|
736
|
-
]);
|
737
|
-
}
|
738
|
-
if (isControl) {
|
739
|
-
variantToAdd = defaultVariants[0];
|
740
|
-
}
|
741
|
-
}
|
742
|
-
personalized = variant.id === variantToAdd.id;
|
743
|
-
results.push(variantToAdd);
|
682
|
+
personalized = true;
|
683
|
+
results.push(variant);
|
744
684
|
}
|
745
685
|
}
|
746
686
|
return {
|
@@ -987,19 +927,16 @@ function parseScoreCookie(cookieValue) {
|
|
987
927
|
if (!cookieValue)
|
988
928
|
return;
|
989
929
|
const types = cookieValue.split(TYPE_SEP);
|
990
|
-
if (types.length >
|
930
|
+
if (types.length > 3)
|
991
931
|
return;
|
992
|
-
const [abTestData, sessionScores, visitorScores
|
993
|
-
|
932
|
+
const [abTestData, sessionScores, visitorScores] = types;
|
933
|
+
return {
|
994
934
|
// this is true since we're reading a cookie, which wouldn't exist if consent wasn't given
|
995
935
|
consent: true,
|
996
936
|
sessionScores: decodeCookieType(parseCookieType(sessionScores)),
|
997
937
|
scores: decodeCookieType(parseCookieType(visitorScores)),
|
998
|
-
tests: parseCookieType(abTestData)
|
999
|
-
controlGroup: controlGroup === "1",
|
1000
|
-
personalizeVariants: decodePersonalizeVariants(personalizeVariants)
|
938
|
+
tests: parseCookieType(abTestData)
|
1001
939
|
};
|
1002
|
-
return data;
|
1003
940
|
}
|
1004
941
|
function parseCookieType(type) {
|
1005
942
|
if (!type) {
|
@@ -1023,51 +960,9 @@ function serializeCookie(data) {
|
|
1023
960
|
return [
|
1024
961
|
serializeCookieType(data.tests),
|
1025
962
|
serializeCookieType(encodeCookieType(data.sessionScores)),
|
1026
|
-
serializeCookieType(encodeCookieType(data.scores))
|
1027
|
-
data.controlGroup ? "1" : "0",
|
1028
|
-
serializePersonalizeVariants(data)
|
963
|
+
serializeCookieType(encodeCookieType(data.scores))
|
1029
964
|
].join(TYPE_SEP);
|
1030
965
|
}
|
1031
|
-
function serializePersonalizeVariants({
|
1032
|
-
personalizeVariants
|
1033
|
-
}) {
|
1034
|
-
const data = {};
|
1035
|
-
if (typeof personalizeVariants === "object") {
|
1036
|
-
Object.keys(personalizeVariants).forEach((personalizationName) => {
|
1037
|
-
let number = BigInt(0);
|
1038
|
-
const variants = personalizeVariants[personalizationName];
|
1039
|
-
variants.forEach((variant) => {
|
1040
|
-
if (variant.control) {
|
1041
|
-
number = flipNthBitTo1BigInt(number, variant.index);
|
1042
|
-
}
|
1043
|
-
});
|
1044
|
-
data[personalizationName] = number.toString(10);
|
1045
|
-
});
|
1046
|
-
}
|
1047
|
-
return serializeCookieType(data);
|
1048
|
-
}
|
1049
|
-
function decodePersonalizeVariants(data) {
|
1050
|
-
const parsed = parseCookieType(data);
|
1051
|
-
const keys = Object.keys(parsed);
|
1052
|
-
if (!keys.length) {
|
1053
|
-
return void 0;
|
1054
|
-
}
|
1055
|
-
const personalizeVariants = {};
|
1056
|
-
keys.forEach((personalizationName) => {
|
1057
|
-
personalizeVariants[personalizationName] = [];
|
1058
|
-
const value = BigInt(parsed[personalizationName]);
|
1059
|
-
const asBinary = value.toString(2);
|
1060
|
-
for (let i = 0; i < asBinary.length; i++) {
|
1061
|
-
if (asBinary[i] === "1") {
|
1062
|
-
personalizeVariants[personalizationName].push({
|
1063
|
-
index: asBinary.length - i,
|
1064
|
-
control: true
|
1065
|
-
});
|
1066
|
-
}
|
1067
|
-
}
|
1068
|
-
});
|
1069
|
-
return personalizeVariants;
|
1070
|
-
}
|
1071
966
|
function encodeCookieType(type) {
|
1072
967
|
return Object.entries(type).reduce((acc, [key, value]) => {
|
1073
968
|
acc[key] = ntob(value);
|
@@ -1077,9 +972,6 @@ function encodeCookieType(type) {
|
|
1077
972
|
function serializeCookieType(type) {
|
1078
973
|
return Object.entries(type).map((kv) => kv.join(KV_SEP)).join(PAIR_SEP);
|
1079
974
|
}
|
1080
|
-
function flipNthBitTo1BigInt(number, n) {
|
1081
|
-
return number | BigInt(1) << BigInt(n - 1);
|
1082
|
-
}
|
1083
975
|
|
1084
976
|
// src/storage/EdgeTransitionDataStore.ts
|
1085
977
|
var _fetchData, fetchData_fn;
|
@@ -1158,8 +1050,7 @@ var emptyVisitorData = () => ({
|
|
1158
1050
|
sessionScores: {},
|
1159
1051
|
tests: {},
|
1160
1052
|
consent: false,
|
1161
|
-
controlGroup: false
|
1162
|
-
personalizeVariants: {}
|
1053
|
+
controlGroup: false
|
1163
1054
|
});
|
1164
1055
|
|
1165
1056
|
// src/storage/VisitorDataStore.ts
|
@@ -1208,26 +1099,6 @@ function applyCommandsToData(commands, state, inControlGroup) {
|
|
1208
1099
|
case "setcontrol":
|
1209
1100
|
newData.controlGroup = command.data;
|
1210
1101
|
break;
|
1211
|
-
case "setpersonalizecontrol":
|
1212
|
-
if (!newData.personalizeVariants) {
|
1213
|
-
newData.personalizeVariants = {};
|
1214
|
-
}
|
1215
|
-
if (!newData.personalizeVariants[command.data.personlizationName]) {
|
1216
|
-
newData.personalizeVariants[command.data.personlizationName] = [];
|
1217
|
-
}
|
1218
|
-
const existingDef = newData.personalizeVariants[command.data.personlizationName].find(
|
1219
|
-
(i) => i.index === command.data.index
|
1220
|
-
);
|
1221
|
-
if (!existingDef) {
|
1222
|
-
const newDef = {
|
1223
|
-
index: command.data.index,
|
1224
|
-
control: command.data.control
|
1225
|
-
};
|
1226
|
-
newData.personalizeVariants[command.data.personlizationName].push(newDef);
|
1227
|
-
} else if (existingDef.control !== command.data.control) {
|
1228
|
-
existingDef.control = command.data.control;
|
1229
|
-
}
|
1230
|
-
break;
|
1231
1102
|
default:
|
1232
1103
|
throw new Error(`Unknown command`);
|
1233
1104
|
}
|
package/dist/index.mjs
CHANGED
@@ -123,15 +123,6 @@ 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
|
-
|
135
126
|
// src/manifest/ManifestInstance.ts
|
136
127
|
var _mf, _signalInstances, _onLogMessage2;
|
137
128
|
var ManifestInstance = class {
|
@@ -155,8 +146,12 @@ var ManifestInstance = class {
|
|
155
146
|
__privateSet(this, _onLogMessage2, onLogMessage);
|
156
147
|
}
|
157
148
|
rollForControlGroup() {
|
158
|
-
var _a;
|
159
|
-
|
149
|
+
var _a, _b;
|
150
|
+
let control = (_b = (_a = __privateGet(this, _mf).pz) == null ? void 0 : _a.control) != null ? _b : 0;
|
151
|
+
if (control >= 1) {
|
152
|
+
control = control / 100;
|
153
|
+
}
|
154
|
+
return Math.random() < control;
|
160
155
|
}
|
161
156
|
getTest(name) {
|
162
157
|
var _a;
|
@@ -504,30 +499,7 @@ function evaluateDimensionMatch(crit, vec, onLogMessage) {
|
|
504
499
|
var _a, _b;
|
505
500
|
const { op, l: lhs } = crit;
|
506
501
|
const lhsScore = (_a = vec[lhs]) != null ? _a : 0;
|
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 === "+") {
|
502
|
+
if (op === "+") {
|
531
503
|
const result = Math.max(...Object.values(vec)) === lhsScore && lhsScore > 0;
|
532
504
|
onLogMessage == null ? void 0 : onLogMessage([
|
533
505
|
"info",
|
@@ -614,27 +586,19 @@ function personalizeVariations({
|
|
614
586
|
take = 1,
|
615
587
|
onLogMessage
|
616
588
|
}) {
|
617
|
-
var _a, _b, _c
|
589
|
+
var _a, _b, _c;
|
618
590
|
onLogMessage == null ? void 0 : onLogMessage(["info", 300, "GROUP", { name, take }]);
|
619
591
|
try {
|
620
592
|
const control = (_a = context.storage.data.controlGroup) != null ? _a : false;
|
621
593
|
const results = [];
|
622
594
|
let personalized = false;
|
623
595
|
const scores = context.scores;
|
624
|
-
let index = 0;
|
625
|
-
const defaultVariants = [];
|
626
596
|
for (const variant of variations) {
|
627
|
-
if (!((_b = variant.pz) == null ? void 0 : _b.crit.length)) {
|
628
|
-
defaultVariants.push(variant);
|
629
|
-
}
|
630
|
-
}
|
631
|
-
for (const variant of variations) {
|
632
|
-
const currentIndex = index++;
|
633
597
|
if (results.length === take) {
|
634
598
|
break;
|
635
599
|
}
|
636
|
-
if (!((
|
637
|
-
onLogMessage == null ? void 0 : onLogMessage(["info", 301, "GROUP", { id: variant.id, op: (
|
600
|
+
if (!((_b = variant.pz) == null ? void 0 : _b.crit.length)) {
|
601
|
+
onLogMessage == null ? void 0 : onLogMessage(["info", 301, "GROUP", { id: variant.id, op: (_c = variant.pz) == null ? void 0 : _c.op }]);
|
638
602
|
onLogMessage == null ? void 0 : onLogMessage(["info", 302, { matched: true, description: "default variation" }]);
|
639
603
|
onLogMessage == null ? void 0 : onLogMessage(["info", 303, true]);
|
640
604
|
onLogMessage == null ? void 0 : onLogMessage(["info", 301, "ENDGROUP"]);
|
@@ -645,32 +609,8 @@ function personalizeVariations({
|
|
645
609
|
continue;
|
646
610
|
}
|
647
611
|
if (evaluateVariantMatch(variant.id, variant.pz, scores, onLogMessage)) {
|
648
|
-
|
649
|
-
|
650
|
-
const testVariants = (_e = context.storage.data.personalizeVariants) == null ? void 0 : _e[name];
|
651
|
-
const entry = testVariants == null ? void 0 : testVariants.find((v) => v.index === currentIndex);
|
652
|
-
let isControl = false;
|
653
|
-
if (typeof entry !== "undefined") {
|
654
|
-
isControl = entry.control;
|
655
|
-
} else {
|
656
|
-
isControl = rollForControlGroup(variant.pz.control);
|
657
|
-
context.storage.updateData([
|
658
|
-
{
|
659
|
-
type: "setpersonalizecontrol",
|
660
|
-
data: {
|
661
|
-
personlizationName: name,
|
662
|
-
index: currentIndex,
|
663
|
-
control: isControl
|
664
|
-
}
|
665
|
-
}
|
666
|
-
]);
|
667
|
-
}
|
668
|
-
if (isControl) {
|
669
|
-
variantToAdd = defaultVariants[0];
|
670
|
-
}
|
671
|
-
}
|
672
|
-
personalized = variant.id === variantToAdd.id;
|
673
|
-
results.push(variantToAdd);
|
612
|
+
personalized = true;
|
613
|
+
results.push(variant);
|
674
614
|
}
|
675
615
|
}
|
676
616
|
return {
|
@@ -917,19 +857,16 @@ function parseScoreCookie(cookieValue) {
|
|
917
857
|
if (!cookieValue)
|
918
858
|
return;
|
919
859
|
const types = cookieValue.split(TYPE_SEP);
|
920
|
-
if (types.length >
|
860
|
+
if (types.length > 3)
|
921
861
|
return;
|
922
|
-
const [abTestData, sessionScores, visitorScores
|
923
|
-
|
862
|
+
const [abTestData, sessionScores, visitorScores] = types;
|
863
|
+
return {
|
924
864
|
// this is true since we're reading a cookie, which wouldn't exist if consent wasn't given
|
925
865
|
consent: true,
|
926
866
|
sessionScores: decodeCookieType(parseCookieType(sessionScores)),
|
927
867
|
scores: decodeCookieType(parseCookieType(visitorScores)),
|
928
|
-
tests: parseCookieType(abTestData)
|
929
|
-
controlGroup: controlGroup === "1",
|
930
|
-
personalizeVariants: decodePersonalizeVariants(personalizeVariants)
|
868
|
+
tests: parseCookieType(abTestData)
|
931
869
|
};
|
932
|
-
return data;
|
933
870
|
}
|
934
871
|
function parseCookieType(type) {
|
935
872
|
if (!type) {
|
@@ -953,51 +890,9 @@ function serializeCookie(data) {
|
|
953
890
|
return [
|
954
891
|
serializeCookieType(data.tests),
|
955
892
|
serializeCookieType(encodeCookieType(data.sessionScores)),
|
956
|
-
serializeCookieType(encodeCookieType(data.scores))
|
957
|
-
data.controlGroup ? "1" : "0",
|
958
|
-
serializePersonalizeVariants(data)
|
893
|
+
serializeCookieType(encodeCookieType(data.scores))
|
959
894
|
].join(TYPE_SEP);
|
960
895
|
}
|
961
|
-
function serializePersonalizeVariants({
|
962
|
-
personalizeVariants
|
963
|
-
}) {
|
964
|
-
const data = {};
|
965
|
-
if (typeof personalizeVariants === "object") {
|
966
|
-
Object.keys(personalizeVariants).forEach((personalizationName) => {
|
967
|
-
let number = BigInt(0);
|
968
|
-
const variants = personalizeVariants[personalizationName];
|
969
|
-
variants.forEach((variant) => {
|
970
|
-
if (variant.control) {
|
971
|
-
number = flipNthBitTo1BigInt(number, variant.index);
|
972
|
-
}
|
973
|
-
});
|
974
|
-
data[personalizationName] = number.toString(10);
|
975
|
-
});
|
976
|
-
}
|
977
|
-
return serializeCookieType(data);
|
978
|
-
}
|
979
|
-
function decodePersonalizeVariants(data) {
|
980
|
-
const parsed = parseCookieType(data);
|
981
|
-
const keys = Object.keys(parsed);
|
982
|
-
if (!keys.length) {
|
983
|
-
return void 0;
|
984
|
-
}
|
985
|
-
const personalizeVariants = {};
|
986
|
-
keys.forEach((personalizationName) => {
|
987
|
-
personalizeVariants[personalizationName] = [];
|
988
|
-
const value = BigInt(parsed[personalizationName]);
|
989
|
-
const asBinary = value.toString(2);
|
990
|
-
for (let i = 0; i < asBinary.length; i++) {
|
991
|
-
if (asBinary[i] === "1") {
|
992
|
-
personalizeVariants[personalizationName].push({
|
993
|
-
index: asBinary.length - i,
|
994
|
-
control: true
|
995
|
-
});
|
996
|
-
}
|
997
|
-
}
|
998
|
-
});
|
999
|
-
return personalizeVariants;
|
1000
|
-
}
|
1001
896
|
function encodeCookieType(type) {
|
1002
897
|
return Object.entries(type).reduce((acc, [key, value]) => {
|
1003
898
|
acc[key] = ntob(value);
|
@@ -1007,9 +902,6 @@ function encodeCookieType(type) {
|
|
1007
902
|
function serializeCookieType(type) {
|
1008
903
|
return Object.entries(type).map((kv) => kv.join(KV_SEP)).join(PAIR_SEP);
|
1009
904
|
}
|
1010
|
-
function flipNthBitTo1BigInt(number, n) {
|
1011
|
-
return number | BigInt(1) << BigInt(n - 1);
|
1012
|
-
}
|
1013
905
|
|
1014
906
|
// src/storage/EdgeTransitionDataStore.ts
|
1015
907
|
var _fetchData, fetchData_fn;
|
@@ -1088,8 +980,7 @@ var emptyVisitorData = () => ({
|
|
1088
980
|
sessionScores: {},
|
1089
981
|
tests: {},
|
1090
982
|
consent: false,
|
1091
|
-
controlGroup: false
|
1092
|
-
personalizeVariants: {}
|
983
|
+
controlGroup: false
|
1093
984
|
});
|
1094
985
|
|
1095
986
|
// src/storage/VisitorDataStore.ts
|
@@ -1138,26 +1029,6 @@ function applyCommandsToData(commands, state, inControlGroup) {
|
|
1138
1029
|
case "setcontrol":
|
1139
1030
|
newData.controlGroup = command.data;
|
1140
1031
|
break;
|
1141
|
-
case "setpersonalizecontrol":
|
1142
|
-
if (!newData.personalizeVariants) {
|
1143
|
-
newData.personalizeVariants = {};
|
1144
|
-
}
|
1145
|
-
if (!newData.personalizeVariants[command.data.personlizationName]) {
|
1146
|
-
newData.personalizeVariants[command.data.personlizationName] = [];
|
1147
|
-
}
|
1148
|
-
const existingDef = newData.personalizeVariants[command.data.personlizationName].find(
|
1149
|
-
(i) => i.index === command.data.index
|
1150
|
-
);
|
1151
|
-
if (!existingDef) {
|
1152
|
-
const newDef = {
|
1153
|
-
index: command.data.index,
|
1154
|
-
control: command.data.control
|
1155
|
-
};
|
1156
|
-
newData.personalizeVariants[command.data.personlizationName].push(newDef);
|
1157
|
-
} else if (existingDef.control !== command.data.control) {
|
1158
|
-
existingDef.control = command.data.control;
|
1159
|
-
}
|
1160
|
-
break;
|
1161
1032
|
default:
|
1162
1033
|
throw new Error(`Unknown command`);
|
1163
1034
|
}
|
@@ -17,13 +17,6 @@ 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
|
-
};
|
27
20
|
/** An event that has occurred (i.e. an analytics track) which may trigger an Event signal */
|
28
21
|
type EventData = {
|
29
22
|
/** The event name that has been fired */
|
@@ -62,10 +55,6 @@ type VisitorData = {
|
|
62
55
|
* based on the control group size.
|
63
56
|
*/
|
64
57
|
controlGroup?: boolean;
|
65
|
-
/**
|
66
|
-
* Records of personalized variants that have been shown to the visitor and their control group status
|
67
|
-
*/
|
68
|
-
personalizeVariants?: PersonalizeVariants;
|
69
58
|
};
|
70
59
|
declare const emptyVisitorData: () => VisitorData;
|
71
60
|
/**
|
@@ -90,7 +79,7 @@ type StorageCommand<TID extends string = string, TData = unknown> = {
|
|
90
79
|
data: TData;
|
91
80
|
};
|
92
81
|
/** Commands that can be issued to alter the storage of Uniform Context data */
|
93
|
-
type StorageCommands = ModifyScoreCommand | ModifySessionScoreCommand | SetConsentCommand | SetQuirkCommand | SetTestCommand | IdentifyCommand | SetControlGroupCommand
|
82
|
+
type StorageCommands = ModifyScoreCommand | ModifySessionScoreCommand | SetConsentCommand | SetQuirkCommand | SetTestCommand | IdentifyCommand | SetControlGroupCommand;
|
94
83
|
/**
|
95
84
|
* Changes the visitor's permanent score for a given dimension
|
96
85
|
*/
|
@@ -136,11 +125,6 @@ type IdentifyCommand = StorageCommand<'identify', {
|
|
136
125
|
* this command is intended mostly for diagnostics and testing purposes.
|
137
126
|
*/
|
138
127
|
type SetControlGroupCommand = StorageCommand<'setcontrol', boolean>;
|
139
|
-
type SetPersonalizeVariantControlCommand = StorageCommand<'setpersonalizecontrol', {
|
140
|
-
personlizationName: string;
|
141
|
-
index: number;
|
142
|
-
control: boolean;
|
143
|
-
}>;
|
144
128
|
|
145
129
|
type TransitionDataStoreOptions = {
|
146
130
|
initialData?: Partial<VisitorData>;
|
@@ -842,10 +826,6 @@ type VariantMatchCriteria = {
|
|
842
826
|
* Name of the variant for analytics tracking.
|
843
827
|
*/
|
844
828
|
name?: string;
|
845
|
-
/**
|
846
|
-
* Control group percentage for the variant.
|
847
|
-
*/
|
848
|
-
control?: number;
|
849
829
|
};
|
850
830
|
type DimensionMatch = {
|
851
831
|
/**
|
@@ -856,8 +836,7 @@ type DimensionMatch = {
|
|
856
836
|
/**
|
857
837
|
* Operator of the match expression
|
858
838
|
* Whole-vector (RHS only) operators - these do not require a `r` or `rDim` set:
|
859
|
-
* +: `l` is the strongest dimension in the score vector
|
860
|
-
* ^: `l` is the strongest dimension in the specified category
|
839
|
+
* +: `l` is the strongest dimension in the score vector
|
861
840
|
* -: `l` is the weakest dimension in the score vector. This does not match if the dimension has no score at all.
|
862
841
|
*
|
863
842
|
* Comparison operators:
|
@@ -868,7 +847,7 @@ type DimensionMatch = {
|
|
868
847
|
* =: `l` is equal to the right hand side expression
|
869
848
|
* !=: `l` is not equal to the right hand side expression
|
870
849
|
*/
|
871
|
-
op: '+' | '-' | '>' | '>=' | '<' | '<=' | '=' | '!='
|
850
|
+
op: '+' | '-' | '>' | '>=' | '<' | '<=' | '=' | '!=';
|
872
851
|
/**
|
873
852
|
* Right hand side of the match expression (not required for op = + or - which have no right side)
|
874
853
|
* This value is treated as a constant value, if it is present. If it's a string, it is parsed to an integer.
|
@@ -1167,4 +1146,4 @@ declare global {
|
|
1167
1146
|
}
|
1168
1147
|
}
|
1169
1148
|
|
1170
|
-
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
|
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 ServerToClientTransitionState as ah, SERVER_STATE_ID as ai, type TransitionDataStoreEvents as aj, type DecayOptions as ak, type VisitorDataStoreOptions as al, type VisitorDataStoreEvents as am, VisitorDataStore as an, type Quirks as ao, type Tests as ap, type EnrichmentData as aq, type EventData as ar, emptyVisitorData as as, type ContextState as at, type ContextStateUpdate as au, type paths as av, 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,13 +17,6 @@ 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
|
-
};
|
27
20
|
/** An event that has occurred (i.e. an analytics track) which may trigger an Event signal */
|
28
21
|
type EventData = {
|
29
22
|
/** The event name that has been fired */
|
@@ -62,10 +55,6 @@ type VisitorData = {
|
|
62
55
|
* based on the control group size.
|
63
56
|
*/
|
64
57
|
controlGroup?: boolean;
|
65
|
-
/**
|
66
|
-
* Records of personalized variants that have been shown to the visitor and their control group status
|
67
|
-
*/
|
68
|
-
personalizeVariants?: PersonalizeVariants;
|
69
58
|
};
|
70
59
|
declare const emptyVisitorData: () => VisitorData;
|
71
60
|
/**
|
@@ -90,7 +79,7 @@ type StorageCommand<TID extends string = string, TData = unknown> = {
|
|
90
79
|
data: TData;
|
91
80
|
};
|
92
81
|
/** Commands that can be issued to alter the storage of Uniform Context data */
|
93
|
-
type StorageCommands = ModifyScoreCommand | ModifySessionScoreCommand | SetConsentCommand | SetQuirkCommand | SetTestCommand | IdentifyCommand | SetControlGroupCommand
|
82
|
+
type StorageCommands = ModifyScoreCommand | ModifySessionScoreCommand | SetConsentCommand | SetQuirkCommand | SetTestCommand | IdentifyCommand | SetControlGroupCommand;
|
94
83
|
/**
|
95
84
|
* Changes the visitor's permanent score for a given dimension
|
96
85
|
*/
|
@@ -136,11 +125,6 @@ type IdentifyCommand = StorageCommand<'identify', {
|
|
136
125
|
* this command is intended mostly for diagnostics and testing purposes.
|
137
126
|
*/
|
138
127
|
type SetControlGroupCommand = StorageCommand<'setcontrol', boolean>;
|
139
|
-
type SetPersonalizeVariantControlCommand = StorageCommand<'setpersonalizecontrol', {
|
140
|
-
personlizationName: string;
|
141
|
-
index: number;
|
142
|
-
control: boolean;
|
143
|
-
}>;
|
144
128
|
|
145
129
|
type TransitionDataStoreOptions = {
|
146
130
|
initialData?: Partial<VisitorData>;
|
@@ -842,10 +826,6 @@ type VariantMatchCriteria = {
|
|
842
826
|
* Name of the variant for analytics tracking.
|
843
827
|
*/
|
844
828
|
name?: string;
|
845
|
-
/**
|
846
|
-
* Control group percentage for the variant.
|
847
|
-
*/
|
848
|
-
control?: number;
|
849
829
|
};
|
850
830
|
type DimensionMatch = {
|
851
831
|
/**
|
@@ -856,8 +836,7 @@ type DimensionMatch = {
|
|
856
836
|
/**
|
857
837
|
* Operator of the match expression
|
858
838
|
* Whole-vector (RHS only) operators - these do not require a `r` or `rDim` set:
|
859
|
-
* +: `l` is the strongest dimension in the score vector
|
860
|
-
* ^: `l` is the strongest dimension in the specified category
|
839
|
+
* +: `l` is the strongest dimension in the score vector
|
861
840
|
* -: `l` is the weakest dimension in the score vector. This does not match if the dimension has no score at all.
|
862
841
|
*
|
863
842
|
* Comparison operators:
|
@@ -868,7 +847,7 @@ type DimensionMatch = {
|
|
868
847
|
* =: `l` is equal to the right hand side expression
|
869
848
|
* !=: `l` is not equal to the right hand side expression
|
870
849
|
*/
|
871
|
-
op: '+' | '-' | '>' | '>=' | '<' | '<=' | '=' | '!='
|
850
|
+
op: '+' | '-' | '>' | '>=' | '<' | '<=' | '=' | '!=';
|
872
851
|
/**
|
873
852
|
* Right hand side of the match expression (not required for op = + or - which have no right side)
|
874
853
|
* This value is treated as a constant value, if it is present. If it's a string, it is parsed to an integer.
|
@@ -1167,4 +1146,4 @@ declare global {
|
|
1167
1146
|
}
|
1168
1147
|
}
|
1169
1148
|
|
1170
|
-
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
|
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 ServerToClientTransitionState as ah, SERVER_STATE_ID as ai, type TransitionDataStoreEvents as aj, type DecayOptions as ak, type VisitorDataStoreOptions as al, type VisitorDataStoreEvents as am, VisitorDataStore as an, type Quirks as ao, type Tests as ap, type EnrichmentData as aq, type EventData as ar, emptyVisitorData as as, type ContextState as at, type ContextStateUpdate as au, type paths as av, 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.130.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": "49291a549c3e2c85acdf71d82328612df1dcafd1"
|
70
70
|
}
|