@uniformdev/context 20.3.1-alpha.7 → 20.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/api.d.mts +1 -1
- package/dist/api/api.d.ts +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.esm.js +14 -49
- package/dist/index.js +14 -49
- package/dist/index.mjs +14 -49
- package/dist/{types-gu4PVkDD.d.mts → types-EJl31yuP.d.mts} +2 -33
- package/dist/{types-gu4PVkDD.d.ts → types-EJl31yuP.d.ts} +2 -33
- 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, Q as Quirks, 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,
|
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, Q as Quirks, b as TransitionDataStoreOptions, D as DecayFunction, c as CriteriaEvaluator, d as StringMatch, e as VariantMatchCriteria, f as LogMessage, g as DevToolsEvents } from './types-EJl31yuP.mjs';
|
2
|
+
export { $ as AggregateDimensionInput, a5 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, az as ContextState, aA as ContextStateUpdate, J as CriteriaEvaluatorParameters, I as CriteriaEvaluatorResult, ao 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, a2 as DimensionMatch, Y as EnrichmentCategory, au as EnrichmentData, ax as EventData, aB as GoalStateUpdate, at as Goals, H as GroupCriteriaEvaluator, ah as IdentifyCommand, F as LogMessageGroup, E as LogMessageSingle, y as LogMessages, G as ManifestInstance, N as ManifestV2, M as MessageCategory, B as MessageFunc, ac as ModifyScoreCommand, ad as ModifySessionScoreCommand, Z as NumberMatch, P as PersonalizationEvent, R as PersonalizationManifest, av as PersonalizeControlVariant, a3 as PersonalizeOptions, aw as PersonalizeVariants, a7 as PersonalizedResult, a6 as PersonalizedVariant, am as SERVER_STATE_ID, al as ServerToClientTransitionState, ae as SetConsentCommand, ai as SetControlGroupCommand, ab as SetGoalCommand, aj as SetPersonalizeVariantControlCommand, af as SetQuirkCommand, ag as SetTestCommand, z as Severity, U as Signal, X as SignalCriteria, W as SignalCriteriaGroup, K as SignalData, aa as StorageCommand, _ as TestDefinition, k as TestEvent, a0 as TestOptions, a9 as TestResult, a8 as TestVariant, as as Tests, an as TransitionDataStoreEvents, ar as VisitorDataStore, aq as VisitorDataStoreEvents, ap as VisitorDataStoreOptions, ak as areCommandsEqual, ay as emptyVisitorData, a4 as personalizeVariations, a1 as testVariations } from './types-EJl31yuP.mjs';
|
3
3
|
import Cookies from 'js-cookie';
|
4
4
|
import 'mitt';
|
5
5
|
|
@@ -158,7 +158,7 @@ declare function createDebugConsoleLogDrain(level: OutputSeverity, options?: Con
|
|
158
158
|
*/
|
159
159
|
declare function enableDebugConsoleLogDrain(level: OutputSeverity, options?: ConsoleDebugLogDrainOptions): ContextPlugin;
|
160
160
|
|
161
|
-
declare function evaluateVariantMatch(variantId: string, match: VariantMatchCriteria | undefined | null, vec: ScoreVector, onLogMessage?: (message: LogMessage) => void
|
161
|
+
declare function evaluateVariantMatch(variantId: string, match: VariantMatchCriteria | undefined | null, vec: ScoreVector, onLogMessage?: (message: LogMessage) => void): boolean;
|
162
162
|
|
163
163
|
type ContextDevToolOptions = {
|
164
164
|
onAfterMessageReceived?: (message: DevToolsEvents) => void;
|
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, Q as Quirks, 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,
|
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, Q as Quirks, b as TransitionDataStoreOptions, D as DecayFunction, c as CriteriaEvaluator, d as StringMatch, e as VariantMatchCriteria, f as LogMessage, g as DevToolsEvents } from './types-EJl31yuP.js';
|
2
|
+
export { $ as AggregateDimensionInput, a5 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, az as ContextState, aA as ContextStateUpdate, J as CriteriaEvaluatorParameters, I as CriteriaEvaluatorResult, ao 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, a2 as DimensionMatch, Y as EnrichmentCategory, au as EnrichmentData, ax as EventData, aB as GoalStateUpdate, at as Goals, H as GroupCriteriaEvaluator, ah as IdentifyCommand, F as LogMessageGroup, E as LogMessageSingle, y as LogMessages, G as ManifestInstance, N as ManifestV2, M as MessageCategory, B as MessageFunc, ac as ModifyScoreCommand, ad as ModifySessionScoreCommand, Z as NumberMatch, P as PersonalizationEvent, R as PersonalizationManifest, av as PersonalizeControlVariant, a3 as PersonalizeOptions, aw as PersonalizeVariants, a7 as PersonalizedResult, a6 as PersonalizedVariant, am as SERVER_STATE_ID, al as ServerToClientTransitionState, ae as SetConsentCommand, ai as SetControlGroupCommand, ab as SetGoalCommand, aj as SetPersonalizeVariantControlCommand, af as SetQuirkCommand, ag as SetTestCommand, z as Severity, U as Signal, X as SignalCriteria, W as SignalCriteriaGroup, K as SignalData, aa as StorageCommand, _ as TestDefinition, k as TestEvent, a0 as TestOptions, a9 as TestResult, a8 as TestVariant, as as Tests, an as TransitionDataStoreEvents, ar as VisitorDataStore, aq as VisitorDataStoreEvents, ap as VisitorDataStoreOptions, ak as areCommandsEqual, ay as emptyVisitorData, a4 as personalizeVariations, a1 as testVariations } from './types-EJl31yuP.js';
|
3
3
|
import Cookies from 'js-cookie';
|
4
4
|
import 'mitt';
|
5
5
|
|
@@ -158,7 +158,7 @@ declare function createDebugConsoleLogDrain(level: OutputSeverity, options?: Con
|
|
158
158
|
*/
|
159
159
|
declare function enableDebugConsoleLogDrain(level: OutputSeverity, options?: ConsoleDebugLogDrainOptions): ContextPlugin;
|
160
160
|
|
161
|
-
declare function evaluateVariantMatch(variantId: string, match: VariantMatchCriteria | undefined | null, vec: ScoreVector, onLogMessage?: (message: LogMessage) => void
|
161
|
+
declare function evaluateVariantMatch(variantId: string, match: VariantMatchCriteria | undefined | null, vec: ScoreVector, onLogMessage?: (message: LogMessage) => void): boolean;
|
162
162
|
|
163
163
|
type ContextDevToolOptions = {
|
164
164
|
onAfterMessageReceived?: (message: DevToolsEvents) => void;
|
package/dist/index.esm.js
CHANGED
@@ -516,7 +516,7 @@ var GroupCriteriaEvaluator = class {
|
|
516
516
|
_evaluators = new WeakMap();
|
517
517
|
|
518
518
|
// src/placement/criteria/evaluateVariantMatch.ts
|
519
|
-
function evaluateVariantMatch(variantId, match, vec, onLogMessage
|
519
|
+
function evaluateVariantMatch(variantId, match, vec, onLogMessage) {
|
520
520
|
onLogMessage == null ? void 0 : onLogMessage(["info", 301, "GROUP", { id: variantId, op: match == null ? void 0 : match.op }]);
|
521
521
|
let result;
|
522
522
|
try {
|
@@ -524,9 +524,9 @@ function evaluateVariantMatch(variantId, match, vec, onLogMessage, quirks) {
|
|
524
524
|
onLogMessage == null ? void 0 : onLogMessage(["info", 302, { matched: true, description: "default variation" }]);
|
525
525
|
result = true;
|
526
526
|
} else if (!match.op || match.op === "&") {
|
527
|
-
result = match.crit.every((c) =>
|
527
|
+
result = match.crit.every((c) => evaluateDimensionMatch(c, vec, onLogMessage));
|
528
528
|
} else {
|
529
|
-
result = match.crit.some((c) =>
|
529
|
+
result = match.crit.some((c) => evaluateDimensionMatch(c, vec, onLogMessage));
|
530
530
|
}
|
531
531
|
onLogMessage == null ? void 0 : onLogMessage(["info", 303, result]);
|
532
532
|
} finally {
|
@@ -534,16 +534,9 @@ function evaluateVariantMatch(variantId, match, vec, onLogMessage, quirks) {
|
|
534
534
|
}
|
535
535
|
return result;
|
536
536
|
}
|
537
|
-
function evaluateMatch(crit, vec, quirks, onLogMessage) {
|
538
|
-
if ("t" in crit && crit.t === "q") {
|
539
|
-
return evaluateQuirkMatch(crit, quirks, onLogMessage);
|
540
|
-
} else {
|
541
|
-
return evaluateDimensionMatch(crit, vec, onLogMessage);
|
542
|
-
}
|
543
|
-
}
|
544
537
|
function evaluateDimensionMatch(crit, vec, onLogMessage) {
|
545
538
|
var _a, _b;
|
546
|
-
const { l: lhs
|
539
|
+
const { op, l: lhs } = crit;
|
547
540
|
const lhsScore = (_a = vec[lhs]) != null ? _a : 0;
|
548
541
|
if (op === "^") {
|
549
542
|
const [cat] = lhs.split(ENR_SEPARATOR);
|
@@ -610,49 +603,33 @@ function evaluateDimensionMatch(crit, vec, onLogMessage) {
|
|
610
603
|
}
|
611
604
|
if (op === ">") {
|
612
605
|
const result = lhsScore > rhsScore;
|
613
|
-
|
606
|
+
explain(onLogMessage, result, crit, lhsScore, rhsScore);
|
614
607
|
return result;
|
615
608
|
} else if (op === ">=") {
|
616
609
|
const result = lhsScore >= rhsScore;
|
617
|
-
|
610
|
+
explain(onLogMessage, result, crit, lhsScore, rhsScore);
|
618
611
|
return result;
|
619
612
|
} else if (op === "<") {
|
620
613
|
const result = lhsScore < rhsScore;
|
621
|
-
|
614
|
+
explain(onLogMessage, result, crit, lhsScore, rhsScore);
|
622
615
|
return result;
|
623
616
|
} else if (op === "<=") {
|
624
617
|
const result = lhsScore <= rhsScore;
|
625
|
-
|
618
|
+
explain(onLogMessage, result, crit, lhsScore, rhsScore);
|
626
619
|
return result;
|
627
620
|
} else if (op === "=") {
|
628
621
|
const result = lhsScore === rhsScore;
|
629
|
-
|
622
|
+
explain(onLogMessage, result, crit, lhsScore, rhsScore);
|
630
623
|
return result;
|
631
624
|
} else if (op === "!=") {
|
632
625
|
const result = lhsScore !== rhsScore;
|
633
|
-
|
626
|
+
explain(onLogMessage, result, crit, lhsScore, rhsScore);
|
634
627
|
return result;
|
635
628
|
} else {
|
636
629
|
throw new Error(`Unknown op: ${op}`);
|
637
630
|
}
|
638
631
|
}
|
639
|
-
function
|
640
|
-
var _a;
|
641
|
-
const { l: targetQuirk, op, r: targetValue } = crit;
|
642
|
-
const targetQuirkValue = (_a = quirks[targetQuirk]) != null ? _a : "";
|
643
|
-
if (op === "=") {
|
644
|
-
const result = targetQuirkValue === targetValue;
|
645
|
-
explainQuirk(onLogMessage, result, crit, targetQuirkValue);
|
646
|
-
return result;
|
647
|
-
} else if (op === "!=") {
|
648
|
-
const result = targetQuirkValue !== targetValue;
|
649
|
-
explainQuirk(onLogMessage, result, crit, targetQuirkValue);
|
650
|
-
return result;
|
651
|
-
} else {
|
652
|
-
throw new Error(`Unknown quirk op: ${op}`);
|
653
|
-
}
|
654
|
-
}
|
655
|
-
function explainScore(onLogMessage, result, crit, lhsScore, rhsScore) {
|
632
|
+
function explain(onLogMessage, result, crit, lhsScore, rhsScore) {
|
656
633
|
onLogMessage == null ? void 0 : onLogMessage([
|
657
634
|
"info",
|
658
635
|
302,
|
@@ -662,18 +639,8 @@ function explainScore(onLogMessage, result, crit, lhsScore, rhsScore) {
|
|
662
639
|
}
|
663
640
|
]);
|
664
641
|
}
|
665
|
-
function explainQuirk(onLogMessage, result, crit, lhs) {
|
666
|
-
onLogMessage == null ? void 0 : onLogMessage([
|
667
|
-
"info",
|
668
|
-
302,
|
669
|
-
{
|
670
|
-
matched: result,
|
671
|
-
description: `Quirk ${crit.l}[${lhs}] ${crit.op} ${crit.r}`
|
672
|
-
}
|
673
|
-
]);
|
674
|
-
}
|
675
642
|
|
676
|
-
// src/placement/
|
643
|
+
// src/placement/personalize.ts
|
677
644
|
function personalizeVariations({
|
678
645
|
name,
|
679
646
|
context,
|
@@ -690,7 +657,7 @@ function personalizeVariations({
|
|
690
657
|
const canEvaluate = !needsConsent || context.storage.data.consent;
|
691
658
|
for (const variant of variations) {
|
692
659
|
if ((_a = variant.pz) == null ? void 0 : _a.crit.length) {
|
693
|
-
if (canEvaluate && variantMatches.length !== take && evaluateVariantMatch(variant.id, variant.pz, context.scores, onLogMessage
|
660
|
+
if (canEvaluate && variantMatches.length !== take && evaluateVariantMatch(variant.id, variant.pz, context.scores, onLogMessage)) {
|
694
661
|
variantMatches.push(variant);
|
695
662
|
}
|
696
663
|
} else {
|
@@ -749,7 +716,7 @@ function personalizeVariations({
|
|
749
716
|
}
|
750
717
|
}
|
751
718
|
|
752
|
-
// src/placement/
|
719
|
+
// src/placement/test.ts
|
753
720
|
var normalizeVariationDistributions = (variations) => {
|
754
721
|
const { values, total, missingDistribution } = variations.reduce(
|
755
722
|
(previous, current) => {
|
@@ -780,8 +747,6 @@ var normalizeVariationDistributions = (variations) => {
|
|
780
747
|
}
|
781
748
|
return values;
|
782
749
|
};
|
783
|
-
|
784
|
-
// src/placement/testVariations.ts
|
785
750
|
var testVariations = ({
|
786
751
|
name,
|
787
752
|
context,
|
package/dist/index.js
CHANGED
@@ -605,7 +605,7 @@ var GroupCriteriaEvaluator = class {
|
|
605
605
|
_evaluators = new WeakMap();
|
606
606
|
|
607
607
|
// src/placement/criteria/evaluateVariantMatch.ts
|
608
|
-
function evaluateVariantMatch(variantId, match, vec, onLogMessage
|
608
|
+
function evaluateVariantMatch(variantId, match, vec, onLogMessage) {
|
609
609
|
onLogMessage == null ? void 0 : onLogMessage(["info", 301, "GROUP", { id: variantId, op: match == null ? void 0 : match.op }]);
|
610
610
|
let result;
|
611
611
|
try {
|
@@ -613,9 +613,9 @@ function evaluateVariantMatch(variantId, match, vec, onLogMessage, quirks) {
|
|
613
613
|
onLogMessage == null ? void 0 : onLogMessage(["info", 302, { matched: true, description: "default variation" }]);
|
614
614
|
result = true;
|
615
615
|
} else if (!match.op || match.op === "&") {
|
616
|
-
result = match.crit.every((c) =>
|
616
|
+
result = match.crit.every((c) => evaluateDimensionMatch(c, vec, onLogMessage));
|
617
617
|
} else {
|
618
|
-
result = match.crit.some((c) =>
|
618
|
+
result = match.crit.some((c) => evaluateDimensionMatch(c, vec, onLogMessage));
|
619
619
|
}
|
620
620
|
onLogMessage == null ? void 0 : onLogMessage(["info", 303, result]);
|
621
621
|
} finally {
|
@@ -623,16 +623,9 @@ function evaluateVariantMatch(variantId, match, vec, onLogMessage, quirks) {
|
|
623
623
|
}
|
624
624
|
return result;
|
625
625
|
}
|
626
|
-
function evaluateMatch(crit, vec, quirks, onLogMessage) {
|
627
|
-
if ("t" in crit && crit.t === "q") {
|
628
|
-
return evaluateQuirkMatch(crit, quirks, onLogMessage);
|
629
|
-
} else {
|
630
|
-
return evaluateDimensionMatch(crit, vec, onLogMessage);
|
631
|
-
}
|
632
|
-
}
|
633
626
|
function evaluateDimensionMatch(crit, vec, onLogMessage) {
|
634
627
|
var _a, _b;
|
635
|
-
const { l: lhs
|
628
|
+
const { op, l: lhs } = crit;
|
636
629
|
const lhsScore = (_a = vec[lhs]) != null ? _a : 0;
|
637
630
|
if (op === "^") {
|
638
631
|
const [cat] = lhs.split(ENR_SEPARATOR);
|
@@ -699,49 +692,33 @@ function evaluateDimensionMatch(crit, vec, onLogMessage) {
|
|
699
692
|
}
|
700
693
|
if (op === ">") {
|
701
694
|
const result = lhsScore > rhsScore;
|
702
|
-
|
695
|
+
explain(onLogMessage, result, crit, lhsScore, rhsScore);
|
703
696
|
return result;
|
704
697
|
} else if (op === ">=") {
|
705
698
|
const result = lhsScore >= rhsScore;
|
706
|
-
|
699
|
+
explain(onLogMessage, result, crit, lhsScore, rhsScore);
|
707
700
|
return result;
|
708
701
|
} else if (op === "<") {
|
709
702
|
const result = lhsScore < rhsScore;
|
710
|
-
|
703
|
+
explain(onLogMessage, result, crit, lhsScore, rhsScore);
|
711
704
|
return result;
|
712
705
|
} else if (op === "<=") {
|
713
706
|
const result = lhsScore <= rhsScore;
|
714
|
-
|
707
|
+
explain(onLogMessage, result, crit, lhsScore, rhsScore);
|
715
708
|
return result;
|
716
709
|
} else if (op === "=") {
|
717
710
|
const result = lhsScore === rhsScore;
|
718
|
-
|
711
|
+
explain(onLogMessage, result, crit, lhsScore, rhsScore);
|
719
712
|
return result;
|
720
713
|
} else if (op === "!=") {
|
721
714
|
const result = lhsScore !== rhsScore;
|
722
|
-
|
715
|
+
explain(onLogMessage, result, crit, lhsScore, rhsScore);
|
723
716
|
return result;
|
724
717
|
} else {
|
725
718
|
throw new Error(`Unknown op: ${op}`);
|
726
719
|
}
|
727
720
|
}
|
728
|
-
function
|
729
|
-
var _a;
|
730
|
-
const { l: targetQuirk, op, r: targetValue } = crit;
|
731
|
-
const targetQuirkValue = (_a = quirks[targetQuirk]) != null ? _a : "";
|
732
|
-
if (op === "=") {
|
733
|
-
const result = targetQuirkValue === targetValue;
|
734
|
-
explainQuirk(onLogMessage, result, crit, targetQuirkValue);
|
735
|
-
return result;
|
736
|
-
} else if (op === "!=") {
|
737
|
-
const result = targetQuirkValue !== targetValue;
|
738
|
-
explainQuirk(onLogMessage, result, crit, targetQuirkValue);
|
739
|
-
return result;
|
740
|
-
} else {
|
741
|
-
throw new Error(`Unknown quirk op: ${op}`);
|
742
|
-
}
|
743
|
-
}
|
744
|
-
function explainScore(onLogMessage, result, crit, lhsScore, rhsScore) {
|
721
|
+
function explain(onLogMessage, result, crit, lhsScore, rhsScore) {
|
745
722
|
onLogMessage == null ? void 0 : onLogMessage([
|
746
723
|
"info",
|
747
724
|
302,
|
@@ -751,18 +728,8 @@ function explainScore(onLogMessage, result, crit, lhsScore, rhsScore) {
|
|
751
728
|
}
|
752
729
|
]);
|
753
730
|
}
|
754
|
-
function explainQuirk(onLogMessage, result, crit, lhs) {
|
755
|
-
onLogMessage == null ? void 0 : onLogMessage([
|
756
|
-
"info",
|
757
|
-
302,
|
758
|
-
{
|
759
|
-
matched: result,
|
760
|
-
description: `Quirk ${crit.l}[${lhs}] ${crit.op} ${crit.r}`
|
761
|
-
}
|
762
|
-
]);
|
763
|
-
}
|
764
731
|
|
765
|
-
// src/placement/
|
732
|
+
// src/placement/personalize.ts
|
766
733
|
function personalizeVariations({
|
767
734
|
name,
|
768
735
|
context,
|
@@ -779,7 +746,7 @@ function personalizeVariations({
|
|
779
746
|
const canEvaluate = !needsConsent || context.storage.data.consent;
|
780
747
|
for (const variant of variations) {
|
781
748
|
if ((_a = variant.pz) == null ? void 0 : _a.crit.length) {
|
782
|
-
if (canEvaluate && variantMatches.length !== take && evaluateVariantMatch(variant.id, variant.pz, context.scores, onLogMessage
|
749
|
+
if (canEvaluate && variantMatches.length !== take && evaluateVariantMatch(variant.id, variant.pz, context.scores, onLogMessage)) {
|
783
750
|
variantMatches.push(variant);
|
784
751
|
}
|
785
752
|
} else {
|
@@ -838,7 +805,7 @@ function personalizeVariations({
|
|
838
805
|
}
|
839
806
|
}
|
840
807
|
|
841
|
-
// src/placement/
|
808
|
+
// src/placement/test.ts
|
842
809
|
var normalizeVariationDistributions = (variations) => {
|
843
810
|
const { values, total, missingDistribution } = variations.reduce(
|
844
811
|
(previous, current) => {
|
@@ -869,8 +836,6 @@ var normalizeVariationDistributions = (variations) => {
|
|
869
836
|
}
|
870
837
|
return values;
|
871
838
|
};
|
872
|
-
|
873
|
-
// src/placement/testVariations.ts
|
874
839
|
var testVariations = ({
|
875
840
|
name,
|
876
841
|
context,
|
package/dist/index.mjs
CHANGED
@@ -516,7 +516,7 @@ var GroupCriteriaEvaluator = class {
|
|
516
516
|
_evaluators = new WeakMap();
|
517
517
|
|
518
518
|
// src/placement/criteria/evaluateVariantMatch.ts
|
519
|
-
function evaluateVariantMatch(variantId, match, vec, onLogMessage
|
519
|
+
function evaluateVariantMatch(variantId, match, vec, onLogMessage) {
|
520
520
|
onLogMessage == null ? void 0 : onLogMessage(["info", 301, "GROUP", { id: variantId, op: match == null ? void 0 : match.op }]);
|
521
521
|
let result;
|
522
522
|
try {
|
@@ -524,9 +524,9 @@ function evaluateVariantMatch(variantId, match, vec, onLogMessage, quirks) {
|
|
524
524
|
onLogMessage == null ? void 0 : onLogMessage(["info", 302, { matched: true, description: "default variation" }]);
|
525
525
|
result = true;
|
526
526
|
} else if (!match.op || match.op === "&") {
|
527
|
-
result = match.crit.every((c) =>
|
527
|
+
result = match.crit.every((c) => evaluateDimensionMatch(c, vec, onLogMessage));
|
528
528
|
} else {
|
529
|
-
result = match.crit.some((c) =>
|
529
|
+
result = match.crit.some((c) => evaluateDimensionMatch(c, vec, onLogMessage));
|
530
530
|
}
|
531
531
|
onLogMessage == null ? void 0 : onLogMessage(["info", 303, result]);
|
532
532
|
} finally {
|
@@ -534,16 +534,9 @@ function evaluateVariantMatch(variantId, match, vec, onLogMessage, quirks) {
|
|
534
534
|
}
|
535
535
|
return result;
|
536
536
|
}
|
537
|
-
function evaluateMatch(crit, vec, quirks, onLogMessage) {
|
538
|
-
if ("t" in crit && crit.t === "q") {
|
539
|
-
return evaluateQuirkMatch(crit, quirks, onLogMessage);
|
540
|
-
} else {
|
541
|
-
return evaluateDimensionMatch(crit, vec, onLogMessage);
|
542
|
-
}
|
543
|
-
}
|
544
537
|
function evaluateDimensionMatch(crit, vec, onLogMessage) {
|
545
538
|
var _a, _b;
|
546
|
-
const { l: lhs
|
539
|
+
const { op, l: lhs } = crit;
|
547
540
|
const lhsScore = (_a = vec[lhs]) != null ? _a : 0;
|
548
541
|
if (op === "^") {
|
549
542
|
const [cat] = lhs.split(ENR_SEPARATOR);
|
@@ -610,49 +603,33 @@ function evaluateDimensionMatch(crit, vec, onLogMessage) {
|
|
610
603
|
}
|
611
604
|
if (op === ">") {
|
612
605
|
const result = lhsScore > rhsScore;
|
613
|
-
|
606
|
+
explain(onLogMessage, result, crit, lhsScore, rhsScore);
|
614
607
|
return result;
|
615
608
|
} else if (op === ">=") {
|
616
609
|
const result = lhsScore >= rhsScore;
|
617
|
-
|
610
|
+
explain(onLogMessage, result, crit, lhsScore, rhsScore);
|
618
611
|
return result;
|
619
612
|
} else if (op === "<") {
|
620
613
|
const result = lhsScore < rhsScore;
|
621
|
-
|
614
|
+
explain(onLogMessage, result, crit, lhsScore, rhsScore);
|
622
615
|
return result;
|
623
616
|
} else if (op === "<=") {
|
624
617
|
const result = lhsScore <= rhsScore;
|
625
|
-
|
618
|
+
explain(onLogMessage, result, crit, lhsScore, rhsScore);
|
626
619
|
return result;
|
627
620
|
} else if (op === "=") {
|
628
621
|
const result = lhsScore === rhsScore;
|
629
|
-
|
622
|
+
explain(onLogMessage, result, crit, lhsScore, rhsScore);
|
630
623
|
return result;
|
631
624
|
} else if (op === "!=") {
|
632
625
|
const result = lhsScore !== rhsScore;
|
633
|
-
|
626
|
+
explain(onLogMessage, result, crit, lhsScore, rhsScore);
|
634
627
|
return result;
|
635
628
|
} else {
|
636
629
|
throw new Error(`Unknown op: ${op}`);
|
637
630
|
}
|
638
631
|
}
|
639
|
-
function
|
640
|
-
var _a;
|
641
|
-
const { l: targetQuirk, op, r: targetValue } = crit;
|
642
|
-
const targetQuirkValue = (_a = quirks[targetQuirk]) != null ? _a : "";
|
643
|
-
if (op === "=") {
|
644
|
-
const result = targetQuirkValue === targetValue;
|
645
|
-
explainQuirk(onLogMessage, result, crit, targetQuirkValue);
|
646
|
-
return result;
|
647
|
-
} else if (op === "!=") {
|
648
|
-
const result = targetQuirkValue !== targetValue;
|
649
|
-
explainQuirk(onLogMessage, result, crit, targetQuirkValue);
|
650
|
-
return result;
|
651
|
-
} else {
|
652
|
-
throw new Error(`Unknown quirk op: ${op}`);
|
653
|
-
}
|
654
|
-
}
|
655
|
-
function explainScore(onLogMessage, result, crit, lhsScore, rhsScore) {
|
632
|
+
function explain(onLogMessage, result, crit, lhsScore, rhsScore) {
|
656
633
|
onLogMessage == null ? void 0 : onLogMessage([
|
657
634
|
"info",
|
658
635
|
302,
|
@@ -662,18 +639,8 @@ function explainScore(onLogMessage, result, crit, lhsScore, rhsScore) {
|
|
662
639
|
}
|
663
640
|
]);
|
664
641
|
}
|
665
|
-
function explainQuirk(onLogMessage, result, crit, lhs) {
|
666
|
-
onLogMessage == null ? void 0 : onLogMessage([
|
667
|
-
"info",
|
668
|
-
302,
|
669
|
-
{
|
670
|
-
matched: result,
|
671
|
-
description: `Quirk ${crit.l}[${lhs}] ${crit.op} ${crit.r}`
|
672
|
-
}
|
673
|
-
]);
|
674
|
-
}
|
675
642
|
|
676
|
-
// src/placement/
|
643
|
+
// src/placement/personalize.ts
|
677
644
|
function personalizeVariations({
|
678
645
|
name,
|
679
646
|
context,
|
@@ -690,7 +657,7 @@ function personalizeVariations({
|
|
690
657
|
const canEvaluate = !needsConsent || context.storage.data.consent;
|
691
658
|
for (const variant of variations) {
|
692
659
|
if ((_a = variant.pz) == null ? void 0 : _a.crit.length) {
|
693
|
-
if (canEvaluate && variantMatches.length !== take && evaluateVariantMatch(variant.id, variant.pz, context.scores, onLogMessage
|
660
|
+
if (canEvaluate && variantMatches.length !== take && evaluateVariantMatch(variant.id, variant.pz, context.scores, onLogMessage)) {
|
694
661
|
variantMatches.push(variant);
|
695
662
|
}
|
696
663
|
} else {
|
@@ -749,7 +716,7 @@ function personalizeVariations({
|
|
749
716
|
}
|
750
717
|
}
|
751
718
|
|
752
|
-
// src/placement/
|
719
|
+
// src/placement/test.ts
|
753
720
|
var normalizeVariationDistributions = (variations) => {
|
754
721
|
const { values, total, missingDistribution } = variations.reduce(
|
755
722
|
(previous, current) => {
|
@@ -780,8 +747,6 @@ var normalizeVariationDistributions = (variations) => {
|
|
780
747
|
}
|
781
748
|
return values;
|
782
749
|
};
|
783
|
-
|
784
|
-
// src/placement/testVariations.ts
|
785
750
|
var testVariations = ({
|
786
751
|
name,
|
787
752
|
context,
|
@@ -905,7 +905,7 @@ type VariantMatchCriteria = {
|
|
905
905
|
* @defaultValue `&`
|
906
906
|
*/
|
907
907
|
op?: '&' | '|';
|
908
|
-
crit:
|
908
|
+
crit: DimensionMatch[];
|
909
909
|
/**
|
910
910
|
* Name of the variant for analytics tracking.
|
911
911
|
*/
|
@@ -953,37 +953,6 @@ type DimensionMatch = {
|
|
953
953
|
*/
|
954
954
|
rDim?: string;
|
955
955
|
};
|
956
|
-
type QuirkMatch = {
|
957
|
-
/**
|
958
|
-
* Type of match expression; 'q' discriminates quirk matches from dimension matches
|
959
|
-
*/
|
960
|
-
t: 'q';
|
961
|
-
/**
|
962
|
-
* Left hand side of the match expression (name of quirk)
|
963
|
-
* NOTE: if the quirk is not present
|
964
|
-
*/
|
965
|
-
l: string;
|
966
|
-
/**
|
967
|
-
* Operator of the match expression
|
968
|
-
* Comparison operators:
|
969
|
-
* =: `l` is equal to the right hand side expression
|
970
|
-
* !=: `l` is not equal to the right hand side expression
|
971
|
-
*/
|
972
|
-
op: '=' | '!=';
|
973
|
-
/**
|
974
|
-
* Right hand side of the match expression
|
975
|
-
* This value is treated as a constant value, if it is present. If it's a string, it is parsed to an integer.
|
976
|
-
* To reference another score dimension as the RHS, use the `rDim` property instead.
|
977
|
-
* `r` and `rDim` are mutually exclusive; if both are specified, then `rDim` wins.
|
978
|
-
*/
|
979
|
-
r: string;
|
980
|
-
/**
|
981
|
-
* Only here to maintain object compatibility with DimensionMatch.
|
982
|
-
* Completely ignored.
|
983
|
-
* @deprecated this is not used with QuirkMatch.
|
984
|
-
*/
|
985
|
-
rDim?: string;
|
986
|
-
};
|
987
956
|
|
988
957
|
/** Content that is tagged for adding enrichment score when triggered by behavior (i.e. being shown that content) */
|
989
958
|
type BehaviorTag = {
|
@@ -1296,4 +1265,4 @@ declare global {
|
|
1296
1265
|
}
|
1297
1266
|
}
|
1298
1267
|
|
1299
|
-
export { type AggregateDimensionInput 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 Quirks as Q, type PersonalizationManifest as R, type ScoreVector as S, TransitionDataStore as T, type Signal as U, type VisitorData as V, type SignalCriteriaGroup as W, type SignalCriteria as X, type EnrichmentCategory as Y, type NumberMatch as Z, type TestDefinition as _, type StorageCommands as a, type TestOptions as a0, testVariations as a1, type DimensionMatch as a2, type
|
1268
|
+
export { type AggregateDimensionInput 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 Quirks as Q, type PersonalizationManifest as R, type ScoreVector as S, TransitionDataStore as T, type Signal as U, type VisitorData as V, type SignalCriteriaGroup as W, type SignalCriteria as X, type EnrichmentCategory as Y, type NumberMatch as Z, type TestDefinition as _, type StorageCommands as a, type TestOptions as a0, testVariations as a1, type DimensionMatch as a2, type PersonalizeOptions as a3, personalizeVariations as a4, type BehaviorTag as a5, type PersonalizedVariant as a6, type PersonalizedResult as a7, type TestVariant as a8, type TestResult as a9, type ContextStateUpdate as aA, type GoalStateUpdate as aB, type paths as aC, type StorageCommand as aa, type SetGoalCommand as ab, type ModifyScoreCommand as ac, type ModifySessionScoreCommand as ad, type SetConsentCommand as ae, type SetQuirkCommand as af, type SetTestCommand as ag, type IdentifyCommand as ah, type SetControlGroupCommand as ai, type SetPersonalizeVariantControlCommand as aj, areCommandsEqual as ak, type ServerToClientTransitionState as al, SERVER_STATE_ID as am, type TransitionDataStoreEvents as an, type DecayOptions as ao, type VisitorDataStoreOptions as ap, type VisitorDataStoreEvents as aq, VisitorDataStore as ar, type Tests as as, type Goals as at, type EnrichmentData as au, type PersonalizeControlVariant as av, type PersonalizeVariants as aw, type EventData as ax, emptyVisitorData as ay, type ContextState as az, 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 };
|
@@ -905,7 +905,7 @@ type VariantMatchCriteria = {
|
|
905
905
|
* @defaultValue `&`
|
906
906
|
*/
|
907
907
|
op?: '&' | '|';
|
908
|
-
crit:
|
908
|
+
crit: DimensionMatch[];
|
909
909
|
/**
|
910
910
|
* Name of the variant for analytics tracking.
|
911
911
|
*/
|
@@ -953,37 +953,6 @@ type DimensionMatch = {
|
|
953
953
|
*/
|
954
954
|
rDim?: string;
|
955
955
|
};
|
956
|
-
type QuirkMatch = {
|
957
|
-
/**
|
958
|
-
* Type of match expression; 'q' discriminates quirk matches from dimension matches
|
959
|
-
*/
|
960
|
-
t: 'q';
|
961
|
-
/**
|
962
|
-
* Left hand side of the match expression (name of quirk)
|
963
|
-
* NOTE: if the quirk is not present
|
964
|
-
*/
|
965
|
-
l: string;
|
966
|
-
/**
|
967
|
-
* Operator of the match expression
|
968
|
-
* Comparison operators:
|
969
|
-
* =: `l` is equal to the right hand side expression
|
970
|
-
* !=: `l` is not equal to the right hand side expression
|
971
|
-
*/
|
972
|
-
op: '=' | '!=';
|
973
|
-
/**
|
974
|
-
* Right hand side of the match expression
|
975
|
-
* This value is treated as a constant value, if it is present. If it's a string, it is parsed to an integer.
|
976
|
-
* To reference another score dimension as the RHS, use the `rDim` property instead.
|
977
|
-
* `r` and `rDim` are mutually exclusive; if both are specified, then `rDim` wins.
|
978
|
-
*/
|
979
|
-
r: string;
|
980
|
-
/**
|
981
|
-
* Only here to maintain object compatibility with DimensionMatch.
|
982
|
-
* Completely ignored.
|
983
|
-
* @deprecated this is not used with QuirkMatch.
|
984
|
-
*/
|
985
|
-
rDim?: string;
|
986
|
-
};
|
987
956
|
|
988
957
|
/** Content that is tagged for adding enrichment score when triggered by behavior (i.e. being shown that content) */
|
989
958
|
type BehaviorTag = {
|
@@ -1296,4 +1265,4 @@ declare global {
|
|
1296
1265
|
}
|
1297
1266
|
}
|
1298
1267
|
|
1299
|
-
export { type AggregateDimensionInput 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 Quirks as Q, type PersonalizationManifest as R, type ScoreVector as S, TransitionDataStore as T, type Signal as U, type VisitorData as V, type SignalCriteriaGroup as W, type SignalCriteria as X, type EnrichmentCategory as Y, type NumberMatch as Z, type TestDefinition as _, type StorageCommands as a, type TestOptions as a0, testVariations as a1, type DimensionMatch as a2, type
|
1268
|
+
export { type AggregateDimensionInput 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 Quirks as Q, type PersonalizationManifest as R, type ScoreVector as S, TransitionDataStore as T, type Signal as U, type VisitorData as V, type SignalCriteriaGroup as W, type SignalCriteria as X, type EnrichmentCategory as Y, type NumberMatch as Z, type TestDefinition as _, type StorageCommands as a, type TestOptions as a0, testVariations as a1, type DimensionMatch as a2, type PersonalizeOptions as a3, personalizeVariations as a4, type BehaviorTag as a5, type PersonalizedVariant as a6, type PersonalizedResult as a7, type TestVariant as a8, type TestResult as a9, type ContextStateUpdate as aA, type GoalStateUpdate as aB, type paths as aC, type StorageCommand as aa, type SetGoalCommand as ab, type ModifyScoreCommand as ac, type ModifySessionScoreCommand as ad, type SetConsentCommand as ae, type SetQuirkCommand as af, type SetTestCommand as ag, type IdentifyCommand as ah, type SetControlGroupCommand as ai, type SetPersonalizeVariantControlCommand as aj, areCommandsEqual as ak, type ServerToClientTransitionState as al, SERVER_STATE_ID as am, type TransitionDataStoreEvents as an, type DecayOptions as ao, type VisitorDataStoreOptions as ap, type VisitorDataStoreEvents as aq, VisitorDataStore as ar, type Tests as as, type Goals as at, type EnrichmentData as au, type PersonalizeControlVariant as av, type PersonalizeVariants as aw, type EventData as ax, emptyVisitorData as ay, type ContextState as az, 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": "20.3.1
|
3
|
+
"version": "20.3.1",
|
4
4
|
"description": "Uniform Context core package",
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
6
6
|
"main": "./dist/index.js",
|
@@ -68,5 +68,5 @@
|
|
68
68
|
"publishConfig": {
|
69
69
|
"access": "public"
|
70
70
|
},
|
71
|
-
"gitHead": "
|
71
|
+
"gitHead": "4f5ad4dc937cd01f9f288d1d292bd4c7c226240b"
|
72
72
|
}
|