@uniformdev/context 20.3.1-alpha.0 → 20.3.1-alpha.7
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 +49 -14
- package/dist/index.js +49 -14
- package/dist/index.mjs +49 -14
- package/dist/{types-EJl31yuP.d.mts → types-gu4PVkDD.d.mts} +33 -2
- package/dist/{types-EJl31yuP.d.ts → types-gu4PVkDD.d.ts} +33 -2
- 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-gu4PVkDD.mjs';
|
2
|
+
export { $ as AggregateDimensionInput, a6 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, aA as ContextState, aB as ContextStateUpdate, J as CriteriaEvaluatorParameters, I as CriteriaEvaluatorResult, ap 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, av as EnrichmentData, ay as EventData, aC as GoalStateUpdate, au as Goals, H as GroupCriteriaEvaluator, ai as IdentifyCommand, F as LogMessageGroup, E as LogMessageSingle, y as LogMessages, G as ManifestInstance, N as ManifestV2, M as MessageCategory, B as MessageFunc, ad as ModifyScoreCommand, ae as ModifySessionScoreCommand, Z as NumberMatch, P as PersonalizationEvent, R as PersonalizationManifest, aw as PersonalizeControlVariant, a4 as PersonalizeOptions, ax as PersonalizeVariants, a8 as PersonalizedResult, a7 as PersonalizedVariant, a3 as QuirkMatch, an as SERVER_STATE_ID, am as ServerToClientTransitionState, af as SetConsentCommand, aj as SetControlGroupCommand, ac as SetGoalCommand, ak as SetPersonalizeVariantControlCommand, ag as SetQuirkCommand, ah as SetTestCommand, z as Severity, U as Signal, X as SignalCriteria, W as SignalCriteriaGroup, K as SignalData, ab as StorageCommand, _ as TestDefinition, k as TestEvent, a0 as TestOptions, aa as TestResult, a9 as TestVariant, at as Tests, ao as TransitionDataStoreEvents, as as VisitorDataStore, ar as VisitorDataStoreEvents, aq as VisitorDataStoreOptions, al as areCommandsEqual, az as emptyVisitorData, a5 as personalizeVariations, a1 as testVariations } from './types-gu4PVkDD.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): boolean;
|
161
|
+
declare function evaluateVariantMatch(variantId: string, match: VariantMatchCriteria | undefined | null, vec: ScoreVector, onLogMessage?: (message: LogMessage) => void, quirks?: Quirks): 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-gu4PVkDD.js';
|
2
|
+
export { $ as AggregateDimensionInput, a6 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, aA as ContextState, aB as ContextStateUpdate, J as CriteriaEvaluatorParameters, I as CriteriaEvaluatorResult, ap 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, av as EnrichmentData, ay as EventData, aC as GoalStateUpdate, au as Goals, H as GroupCriteriaEvaluator, ai as IdentifyCommand, F as LogMessageGroup, E as LogMessageSingle, y as LogMessages, G as ManifestInstance, N as ManifestV2, M as MessageCategory, B as MessageFunc, ad as ModifyScoreCommand, ae as ModifySessionScoreCommand, Z as NumberMatch, P as PersonalizationEvent, R as PersonalizationManifest, aw as PersonalizeControlVariant, a4 as PersonalizeOptions, ax as PersonalizeVariants, a8 as PersonalizedResult, a7 as PersonalizedVariant, a3 as QuirkMatch, an as SERVER_STATE_ID, am as ServerToClientTransitionState, af as SetConsentCommand, aj as SetControlGroupCommand, ac as SetGoalCommand, ak as SetPersonalizeVariantControlCommand, ag as SetQuirkCommand, ah as SetTestCommand, z as Severity, U as Signal, X as SignalCriteria, W as SignalCriteriaGroup, K as SignalData, ab as StorageCommand, _ as TestDefinition, k as TestEvent, a0 as TestOptions, aa as TestResult, a9 as TestVariant, at as Tests, ao as TransitionDataStoreEvents, as as VisitorDataStore, ar as VisitorDataStoreEvents, aq as VisitorDataStoreOptions, al as areCommandsEqual, az as emptyVisitorData, a5 as personalizeVariations, a1 as testVariations } from './types-gu4PVkDD.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): boolean;
|
161
|
+
declare function evaluateVariantMatch(variantId: string, match: VariantMatchCriteria | undefined | null, vec: ScoreVector, onLogMessage?: (message: LogMessage) => void, quirks?: Quirks): 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, quirks) {
|
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) {
|
|
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) => evaluateMatch(c, vec, quirks != null ? quirks : {}, onLogMessage));
|
528
528
|
} else {
|
529
|
-
result = match.crit.some((c) =>
|
529
|
+
result = match.crit.some((c) => evaluateMatch(c, vec, quirks != null ? quirks : {}, onLogMessage));
|
530
530
|
}
|
531
531
|
onLogMessage == null ? void 0 : onLogMessage(["info", 303, result]);
|
532
532
|
} finally {
|
@@ -534,9 +534,16 @@ function evaluateVariantMatch(variantId, match, vec, onLogMessage) {
|
|
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
|
+
}
|
537
544
|
function evaluateDimensionMatch(crit, vec, onLogMessage) {
|
538
545
|
var _a, _b;
|
539
|
-
const {
|
546
|
+
const { l: lhs, op } = crit;
|
540
547
|
const lhsScore = (_a = vec[lhs]) != null ? _a : 0;
|
541
548
|
if (op === "^") {
|
542
549
|
const [cat] = lhs.split(ENR_SEPARATOR);
|
@@ -603,33 +610,49 @@ function evaluateDimensionMatch(crit, vec, onLogMessage) {
|
|
603
610
|
}
|
604
611
|
if (op === ">") {
|
605
612
|
const result = lhsScore > rhsScore;
|
606
|
-
|
613
|
+
explainScore(onLogMessage, result, crit, lhsScore, rhsScore);
|
607
614
|
return result;
|
608
615
|
} else if (op === ">=") {
|
609
616
|
const result = lhsScore >= rhsScore;
|
610
|
-
|
617
|
+
explainScore(onLogMessage, result, crit, lhsScore, rhsScore);
|
611
618
|
return result;
|
612
619
|
} else if (op === "<") {
|
613
620
|
const result = lhsScore < rhsScore;
|
614
|
-
|
621
|
+
explainScore(onLogMessage, result, crit, lhsScore, rhsScore);
|
615
622
|
return result;
|
616
623
|
} else if (op === "<=") {
|
617
624
|
const result = lhsScore <= rhsScore;
|
618
|
-
|
625
|
+
explainScore(onLogMessage, result, crit, lhsScore, rhsScore);
|
619
626
|
return result;
|
620
627
|
} else if (op === "=") {
|
621
628
|
const result = lhsScore === rhsScore;
|
622
|
-
|
629
|
+
explainScore(onLogMessage, result, crit, lhsScore, rhsScore);
|
623
630
|
return result;
|
624
631
|
} else if (op === "!=") {
|
625
632
|
const result = lhsScore !== rhsScore;
|
626
|
-
|
633
|
+
explainScore(onLogMessage, result, crit, lhsScore, rhsScore);
|
627
634
|
return result;
|
628
635
|
} else {
|
629
636
|
throw new Error(`Unknown op: ${op}`);
|
630
637
|
}
|
631
638
|
}
|
632
|
-
function
|
639
|
+
function evaluateQuirkMatch(crit, quirks, onLogMessage) {
|
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) {
|
633
656
|
onLogMessage == null ? void 0 : onLogMessage([
|
634
657
|
"info",
|
635
658
|
302,
|
@@ -639,8 +662,18 @@ function explain(onLogMessage, result, crit, lhsScore, rhsScore) {
|
|
639
662
|
}
|
640
663
|
]);
|
641
664
|
}
|
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
|
+
}
|
642
675
|
|
643
|
-
// src/placement/
|
676
|
+
// src/placement/personalizeVariations.ts
|
644
677
|
function personalizeVariations({
|
645
678
|
name,
|
646
679
|
context,
|
@@ -657,7 +690,7 @@ function personalizeVariations({
|
|
657
690
|
const canEvaluate = !needsConsent || context.storage.data.consent;
|
658
691
|
for (const variant of variations) {
|
659
692
|
if ((_a = variant.pz) == null ? void 0 : _a.crit.length) {
|
660
|
-
if (canEvaluate && variantMatches.length !== take && evaluateVariantMatch(variant.id, variant.pz, context.scores, onLogMessage)) {
|
693
|
+
if (canEvaluate && variantMatches.length !== take && evaluateVariantMatch(variant.id, variant.pz, context.scores, onLogMessage, context.quirks)) {
|
661
694
|
variantMatches.push(variant);
|
662
695
|
}
|
663
696
|
} else {
|
@@ -716,7 +749,7 @@ function personalizeVariations({
|
|
716
749
|
}
|
717
750
|
}
|
718
751
|
|
719
|
-
// src/placement/
|
752
|
+
// src/placement/normalizeVariationDistributions.ts
|
720
753
|
var normalizeVariationDistributions = (variations) => {
|
721
754
|
const { values, total, missingDistribution } = variations.reduce(
|
722
755
|
(previous, current) => {
|
@@ -747,6 +780,8 @@ var normalizeVariationDistributions = (variations) => {
|
|
747
780
|
}
|
748
781
|
return values;
|
749
782
|
};
|
783
|
+
|
784
|
+
// src/placement/testVariations.ts
|
750
785
|
var testVariations = ({
|
751
786
|
name,
|
752
787
|
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, quirks) {
|
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) {
|
|
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) => evaluateMatch(c, vec, quirks != null ? quirks : {}, onLogMessage));
|
617
617
|
} else {
|
618
|
-
result = match.crit.some((c) =>
|
618
|
+
result = match.crit.some((c) => evaluateMatch(c, vec, quirks != null ? quirks : {}, onLogMessage));
|
619
619
|
}
|
620
620
|
onLogMessage == null ? void 0 : onLogMessage(["info", 303, result]);
|
621
621
|
} finally {
|
@@ -623,9 +623,16 @@ function evaluateVariantMatch(variantId, match, vec, onLogMessage) {
|
|
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
|
+
}
|
626
633
|
function evaluateDimensionMatch(crit, vec, onLogMessage) {
|
627
634
|
var _a, _b;
|
628
|
-
const {
|
635
|
+
const { l: lhs, op } = crit;
|
629
636
|
const lhsScore = (_a = vec[lhs]) != null ? _a : 0;
|
630
637
|
if (op === "^") {
|
631
638
|
const [cat] = lhs.split(ENR_SEPARATOR);
|
@@ -692,33 +699,49 @@ function evaluateDimensionMatch(crit, vec, onLogMessage) {
|
|
692
699
|
}
|
693
700
|
if (op === ">") {
|
694
701
|
const result = lhsScore > rhsScore;
|
695
|
-
|
702
|
+
explainScore(onLogMessage, result, crit, lhsScore, rhsScore);
|
696
703
|
return result;
|
697
704
|
} else if (op === ">=") {
|
698
705
|
const result = lhsScore >= rhsScore;
|
699
|
-
|
706
|
+
explainScore(onLogMessage, result, crit, lhsScore, rhsScore);
|
700
707
|
return result;
|
701
708
|
} else if (op === "<") {
|
702
709
|
const result = lhsScore < rhsScore;
|
703
|
-
|
710
|
+
explainScore(onLogMessage, result, crit, lhsScore, rhsScore);
|
704
711
|
return result;
|
705
712
|
} else if (op === "<=") {
|
706
713
|
const result = lhsScore <= rhsScore;
|
707
|
-
|
714
|
+
explainScore(onLogMessage, result, crit, lhsScore, rhsScore);
|
708
715
|
return result;
|
709
716
|
} else if (op === "=") {
|
710
717
|
const result = lhsScore === rhsScore;
|
711
|
-
|
718
|
+
explainScore(onLogMessage, result, crit, lhsScore, rhsScore);
|
712
719
|
return result;
|
713
720
|
} else if (op === "!=") {
|
714
721
|
const result = lhsScore !== rhsScore;
|
715
|
-
|
722
|
+
explainScore(onLogMessage, result, crit, lhsScore, rhsScore);
|
716
723
|
return result;
|
717
724
|
} else {
|
718
725
|
throw new Error(`Unknown op: ${op}`);
|
719
726
|
}
|
720
727
|
}
|
721
|
-
function
|
728
|
+
function evaluateQuirkMatch(crit, quirks, onLogMessage) {
|
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) {
|
722
745
|
onLogMessage == null ? void 0 : onLogMessage([
|
723
746
|
"info",
|
724
747
|
302,
|
@@ -728,8 +751,18 @@ function explain(onLogMessage, result, crit, lhsScore, rhsScore) {
|
|
728
751
|
}
|
729
752
|
]);
|
730
753
|
}
|
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
|
+
}
|
731
764
|
|
732
|
-
// src/placement/
|
765
|
+
// src/placement/personalizeVariations.ts
|
733
766
|
function personalizeVariations({
|
734
767
|
name,
|
735
768
|
context,
|
@@ -746,7 +779,7 @@ function personalizeVariations({
|
|
746
779
|
const canEvaluate = !needsConsent || context.storage.data.consent;
|
747
780
|
for (const variant of variations) {
|
748
781
|
if ((_a = variant.pz) == null ? void 0 : _a.crit.length) {
|
749
|
-
if (canEvaluate && variantMatches.length !== take && evaluateVariantMatch(variant.id, variant.pz, context.scores, onLogMessage)) {
|
782
|
+
if (canEvaluate && variantMatches.length !== take && evaluateVariantMatch(variant.id, variant.pz, context.scores, onLogMessage, context.quirks)) {
|
750
783
|
variantMatches.push(variant);
|
751
784
|
}
|
752
785
|
} else {
|
@@ -805,7 +838,7 @@ function personalizeVariations({
|
|
805
838
|
}
|
806
839
|
}
|
807
840
|
|
808
|
-
// src/placement/
|
841
|
+
// src/placement/normalizeVariationDistributions.ts
|
809
842
|
var normalizeVariationDistributions = (variations) => {
|
810
843
|
const { values, total, missingDistribution } = variations.reduce(
|
811
844
|
(previous, current) => {
|
@@ -836,6 +869,8 @@ var normalizeVariationDistributions = (variations) => {
|
|
836
869
|
}
|
837
870
|
return values;
|
838
871
|
};
|
872
|
+
|
873
|
+
// src/placement/testVariations.ts
|
839
874
|
var testVariations = ({
|
840
875
|
name,
|
841
876
|
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, quirks) {
|
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) {
|
|
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) => evaluateMatch(c, vec, quirks != null ? quirks : {}, onLogMessage));
|
528
528
|
} else {
|
529
|
-
result = match.crit.some((c) =>
|
529
|
+
result = match.crit.some((c) => evaluateMatch(c, vec, quirks != null ? quirks : {}, onLogMessage));
|
530
530
|
}
|
531
531
|
onLogMessage == null ? void 0 : onLogMessage(["info", 303, result]);
|
532
532
|
} finally {
|
@@ -534,9 +534,16 @@ function evaluateVariantMatch(variantId, match, vec, onLogMessage) {
|
|
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
|
+
}
|
537
544
|
function evaluateDimensionMatch(crit, vec, onLogMessage) {
|
538
545
|
var _a, _b;
|
539
|
-
const {
|
546
|
+
const { l: lhs, op } = crit;
|
540
547
|
const lhsScore = (_a = vec[lhs]) != null ? _a : 0;
|
541
548
|
if (op === "^") {
|
542
549
|
const [cat] = lhs.split(ENR_SEPARATOR);
|
@@ -603,33 +610,49 @@ function evaluateDimensionMatch(crit, vec, onLogMessage) {
|
|
603
610
|
}
|
604
611
|
if (op === ">") {
|
605
612
|
const result = lhsScore > rhsScore;
|
606
|
-
|
613
|
+
explainScore(onLogMessage, result, crit, lhsScore, rhsScore);
|
607
614
|
return result;
|
608
615
|
} else if (op === ">=") {
|
609
616
|
const result = lhsScore >= rhsScore;
|
610
|
-
|
617
|
+
explainScore(onLogMessage, result, crit, lhsScore, rhsScore);
|
611
618
|
return result;
|
612
619
|
} else if (op === "<") {
|
613
620
|
const result = lhsScore < rhsScore;
|
614
|
-
|
621
|
+
explainScore(onLogMessage, result, crit, lhsScore, rhsScore);
|
615
622
|
return result;
|
616
623
|
} else if (op === "<=") {
|
617
624
|
const result = lhsScore <= rhsScore;
|
618
|
-
|
625
|
+
explainScore(onLogMessage, result, crit, lhsScore, rhsScore);
|
619
626
|
return result;
|
620
627
|
} else if (op === "=") {
|
621
628
|
const result = lhsScore === rhsScore;
|
622
|
-
|
629
|
+
explainScore(onLogMessage, result, crit, lhsScore, rhsScore);
|
623
630
|
return result;
|
624
631
|
} else if (op === "!=") {
|
625
632
|
const result = lhsScore !== rhsScore;
|
626
|
-
|
633
|
+
explainScore(onLogMessage, result, crit, lhsScore, rhsScore);
|
627
634
|
return result;
|
628
635
|
} else {
|
629
636
|
throw new Error(`Unknown op: ${op}`);
|
630
637
|
}
|
631
638
|
}
|
632
|
-
function
|
639
|
+
function evaluateQuirkMatch(crit, quirks, onLogMessage) {
|
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) {
|
633
656
|
onLogMessage == null ? void 0 : onLogMessage([
|
634
657
|
"info",
|
635
658
|
302,
|
@@ -639,8 +662,18 @@ function explain(onLogMessage, result, crit, lhsScore, rhsScore) {
|
|
639
662
|
}
|
640
663
|
]);
|
641
664
|
}
|
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
|
+
}
|
642
675
|
|
643
|
-
// src/placement/
|
676
|
+
// src/placement/personalizeVariations.ts
|
644
677
|
function personalizeVariations({
|
645
678
|
name,
|
646
679
|
context,
|
@@ -657,7 +690,7 @@ function personalizeVariations({
|
|
657
690
|
const canEvaluate = !needsConsent || context.storage.data.consent;
|
658
691
|
for (const variant of variations) {
|
659
692
|
if ((_a = variant.pz) == null ? void 0 : _a.crit.length) {
|
660
|
-
if (canEvaluate && variantMatches.length !== take && evaluateVariantMatch(variant.id, variant.pz, context.scores, onLogMessage)) {
|
693
|
+
if (canEvaluate && variantMatches.length !== take && evaluateVariantMatch(variant.id, variant.pz, context.scores, onLogMessage, context.quirks)) {
|
661
694
|
variantMatches.push(variant);
|
662
695
|
}
|
663
696
|
} else {
|
@@ -716,7 +749,7 @@ function personalizeVariations({
|
|
716
749
|
}
|
717
750
|
}
|
718
751
|
|
719
|
-
// src/placement/
|
752
|
+
// src/placement/normalizeVariationDistributions.ts
|
720
753
|
var normalizeVariationDistributions = (variations) => {
|
721
754
|
const { values, total, missingDistribution } = variations.reduce(
|
722
755
|
(previous, current) => {
|
@@ -747,6 +780,8 @@ var normalizeVariationDistributions = (variations) => {
|
|
747
780
|
}
|
748
781
|
return values;
|
749
782
|
};
|
783
|
+
|
784
|
+
// src/placement/testVariations.ts
|
750
785
|
var testVariations = ({
|
751
786
|
name,
|
752
787
|
context,
|
@@ -905,7 +905,7 @@ type VariantMatchCriteria = {
|
|
905
905
|
* @defaultValue `&`
|
906
906
|
*/
|
907
907
|
op?: '&' | '|';
|
908
|
-
crit: DimensionMatch
|
908
|
+
crit: Array<DimensionMatch | QuirkMatch>;
|
909
909
|
/**
|
910
910
|
* Name of the variant for analytics tracking.
|
911
911
|
*/
|
@@ -953,6 +953,37 @@ 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
|
+
};
|
956
987
|
|
957
988
|
/** Content that is tagged for adding enrichment score when triggered by behavior (i.e. being shown that content) */
|
958
989
|
type BehaviorTag = {
|
@@ -1265,4 +1296,4 @@ declare global {
|
|
1265
1296
|
}
|
1266
1297
|
}
|
1267
1298
|
|
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
|
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 QuirkMatch as a3, type PersonalizeOptions as a4, personalizeVariations as a5, type BehaviorTag as a6, type PersonalizedVariant as a7, type PersonalizedResult as a8, type TestVariant as a9, type ContextState as aA, type ContextStateUpdate as aB, type GoalStateUpdate as aC, type paths as aD, type TestResult as aa, type StorageCommand as ab, type SetGoalCommand as ac, type ModifyScoreCommand as ad, type ModifySessionScoreCommand as ae, type SetConsentCommand as af, type SetQuirkCommand as ag, type SetTestCommand as ah, type IdentifyCommand as ai, type SetControlGroupCommand as aj, type SetPersonalizeVariantControlCommand as ak, areCommandsEqual as al, type ServerToClientTransitionState as am, SERVER_STATE_ID as an, type TransitionDataStoreEvents as ao, type DecayOptions as ap, type VisitorDataStoreOptions as aq, type VisitorDataStoreEvents as ar, VisitorDataStore as as, type Tests as at, type Goals as au, type EnrichmentData as av, type PersonalizeControlVariant as aw, type PersonalizeVariants as ax, type EventData as ay, emptyVisitorData 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: DimensionMatch
|
908
|
+
crit: Array<DimensionMatch | QuirkMatch>;
|
909
909
|
/**
|
910
910
|
* Name of the variant for analytics tracking.
|
911
911
|
*/
|
@@ -953,6 +953,37 @@ 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
|
+
};
|
956
987
|
|
957
988
|
/** Content that is tagged for adding enrichment score when triggered by behavior (i.e. being shown that content) */
|
958
989
|
type BehaviorTag = {
|
@@ -1265,4 +1296,4 @@ declare global {
|
|
1265
1296
|
}
|
1266
1297
|
}
|
1267
1298
|
|
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
|
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 QuirkMatch as a3, type PersonalizeOptions as a4, personalizeVariations as a5, type BehaviorTag as a6, type PersonalizedVariant as a7, type PersonalizedResult as a8, type TestVariant as a9, type ContextState as aA, type ContextStateUpdate as aB, type GoalStateUpdate as aC, type paths as aD, type TestResult as aa, type StorageCommand as ab, type SetGoalCommand as ac, type ModifyScoreCommand as ad, type ModifySessionScoreCommand as ae, type SetConsentCommand as af, type SetQuirkCommand as ag, type SetTestCommand as ah, type IdentifyCommand as ai, type SetControlGroupCommand as aj, type SetPersonalizeVariantControlCommand as ak, areCommandsEqual as al, type ServerToClientTransitionState as am, SERVER_STATE_ID as an, type TransitionDataStoreEvents as ao, type DecayOptions as ap, type VisitorDataStoreOptions as aq, type VisitorDataStoreEvents as ar, VisitorDataStore as as, type Tests as at, type Goals as au, type EnrichmentData as av, type PersonalizeControlVariant as aw, type PersonalizeVariants as ax, type EventData as ay, emptyVisitorData 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-alpha.
|
3
|
+
"version": "20.3.1-alpha.7+bede5bf489",
|
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": "bede5bf4893bf814af6aba78a558e28efd9f5682"
|
72
72
|
}
|