@uniformdev/context 19.173.1-alpha.17 → 19.173.2-alpha.258
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 +15 -3
- package/dist/index.d.ts +15 -3
- package/dist/index.esm.js +91 -90
- package/dist/index.js +103 -90
- package/dist/index.mjs +91 -90
- package/dist/{types-4YSyIXmc.d.mts → types-o4ZU_qKY.d.mts} +9 -4
- package/dist/{types-4YSyIXmc.d.ts → types-o4ZU_qKY.d.ts} +9 -4
- package/package.json +3 -3
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, az as ContextState, aA as ContextStateUpdate, J as CriteriaEvaluatorParameters, I as CriteriaEvaluatorResult, an 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, au as EnrichmentData, ax as EventData, aB as GoalStateUpdate, at as Goals, H as GroupCriteriaEvaluator, ag as IdentifyCommand, F as LogMessageGroup, E as LogMessageSingle, y as LogMessages, G as ManifestInstance, N as ManifestV2, M as MessageCategory, B as MessageFunc, ab as ModifyScoreCommand, ac as ModifySessionScoreCommand, Y as NumberMatch, P as PersonalizationEvent, Q as PersonalizationManifest, av as PersonalizeControlVariant, a2 as PersonalizeOptions, aw as PersonalizeVariants, a6 as PersonalizedResult, a5 as PersonalizedVariant, ar as Quirks, al as SERVER_STATE_ID, ak as ServerToClientTransitionState, ad as SetConsentCommand, ah as SetControlGroupCommand, aa as SetGoalCommand, ai as SetPersonalizeVariantControlCommand, ae as SetQuirkCommand, af 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, as as Tests, am as TransitionDataStoreEvents, aq as VisitorDataStore, ap as VisitorDataStoreEvents, ao as VisitorDataStoreOptions, aj as areCommandsEqual, ay as emptyVisitorData, a3 as personalizeVariations, a0 as testVariations } from './types-
|
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-o4ZU_qKY.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, az as ContextState, aA as ContextStateUpdate, J as CriteriaEvaluatorParameters, I as CriteriaEvaluatorResult, an 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, au as EnrichmentData, ax as EventData, aB as GoalStateUpdate, at as Goals, H as GroupCriteriaEvaluator, ag as IdentifyCommand, F as LogMessageGroup, E as LogMessageSingle, y as LogMessages, G as ManifestInstance, N as ManifestV2, M as MessageCategory, B as MessageFunc, ab as ModifyScoreCommand, ac as ModifySessionScoreCommand, Y as NumberMatch, P as PersonalizationEvent, Q as PersonalizationManifest, av as PersonalizeControlVariant, a2 as PersonalizeOptions, aw as PersonalizeVariants, a6 as PersonalizedResult, a5 as PersonalizedVariant, ar as Quirks, al as SERVER_STATE_ID, ak as ServerToClientTransitionState, ad as SetConsentCommand, ah as SetControlGroupCommand, aa as SetGoalCommand, ai as SetPersonalizeVariantControlCommand, ae as SetQuirkCommand, af 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, as as Tests, am as TransitionDataStoreEvents, aq as VisitorDataStore, ap as VisitorDataStoreEvents, ao as VisitorDataStoreOptions, aj as areCommandsEqual, ay as emptyVisitorData, a3 as personalizeVariations, a0 as testVariations } from './types-o4ZU_qKY.mjs';
|
3
3
|
import Cookies from 'js-cookie';
|
4
4
|
import 'mitt';
|
5
5
|
|
@@ -50,6 +50,18 @@ declare class CookieTransitionDataStore extends TransitionDataStore {
|
|
50
50
|
handleDelete(): Promise<void>;
|
51
51
|
handleUpdateData(_: StorageCommands[], computedValue: VisitorData): Promise<void>;
|
52
52
|
}
|
53
|
+
declare const TYPE_SEP = "~";
|
54
|
+
declare const PAIR_SEP = "!";
|
55
|
+
declare const KV_SEP = "-";
|
56
|
+
declare function parseScoreCookie(cookieValue: string | undefined): Partial<VisitorData> | undefined;
|
57
|
+
declare function parseCookieScores(type: string | undefined): Record<string, string>;
|
58
|
+
declare function parseCookieType(type: string | undefined): Record<string, string>;
|
59
|
+
declare function decodeCookieType(type: Record<string, string>): Record<string, number>;
|
60
|
+
declare function serializeCookie(data: VisitorData): string;
|
61
|
+
declare function serializePersonalizeVariants({ personalizeVariants, }: Pick<VisitorData, 'personalizeVariants'>): string;
|
62
|
+
declare function decodePersonalizeVariants(data: string | undefined): VisitorData['personalizeVariants'];
|
63
|
+
declare function encodeCookieType(type: Record<string, number>): Record<string, string>;
|
64
|
+
declare function serializeCookieType(type: Record<string, string>): string;
|
53
65
|
|
54
66
|
type EdgeTransitionDataStoreOptions = TransitionDataStoreOptions & {
|
55
67
|
serverCookieValue?: string;
|
@@ -177,4 +189,4 @@ type QuickConnectConfig = {
|
|
177
189
|
declare function serializeQuickConnect(config: QuickConnectConfig): string;
|
178
190
|
declare function parseQuickConnect(serialized: string): Required<QuickConnectConfig>;
|
179
191
|
|
180
|
-
export { AggregateDimension, type ConsoleDebugLogDrainOptions, type ContextDevToolOptions, ContextPlugin, CookieTransitionDataStore, type CookieTransitionDataStoreOptions, CriteriaEvaluator, DecayFunction, DevToolsEvents, EdgeNodeTagName, type EdgePersonalizeComponentOptions, type EdgeTestComponentOptions, EdgeTransitionDataStore, type EdgeTransitionDataStoreOptions, type EnableUniformInsightsOptions, type LinearDecayOptions, LogDrain, LogMessage, OutputSeverity, type QuickConnectConfig, ScoreVector, ScriptType, StorageCommands, StringMatch, TransitionDataStore, TransitionDataStoreOptions, UNIFORM_DEFAULT_COOKIE_NAME, VariantMatchCriteria, VisitorData, computeAggregateDimensions, cookieEvaluator, createConsoleLogDrain, createDebugConsoleLogDrain, createLinearDecay, currentPageEvaluator, enableConsoleLogDrain, enableContextDevTools, enableDebugConsoleLogDrain, enableUniformInsights, evaluateVariantMatch, eventEvaluator, explainStringMatch, explainStringMatchCriteria, getEnrichmentVectorKey, isStringMatch, pageViewCountDimension, pageViewCountEvaluator, parseQuickConnect, queryStringEvaluator, quirkEvaluator, serializeQuickConnect };
|
192
|
+
export { AggregateDimension, type ConsoleDebugLogDrainOptions, type ContextDevToolOptions, ContextPlugin, CookieTransitionDataStore, type CookieTransitionDataStoreOptions, CriteriaEvaluator, DecayFunction, DevToolsEvents, EdgeNodeTagName, type EdgePersonalizeComponentOptions, type EdgeTestComponentOptions, EdgeTransitionDataStore, type EdgeTransitionDataStoreOptions, type EnableUniformInsightsOptions, KV_SEP, type LinearDecayOptions, LogDrain, LogMessage, OutputSeverity, PAIR_SEP, type QuickConnectConfig, ScoreVector, ScriptType, StorageCommands, StringMatch, TYPE_SEP, TransitionDataStore, TransitionDataStoreOptions, UNIFORM_DEFAULT_COOKIE_NAME, VariantMatchCriteria, VisitorData, computeAggregateDimensions, cookieEvaluator, createConsoleLogDrain, createDebugConsoleLogDrain, createLinearDecay, currentPageEvaluator, decodeCookieType, decodePersonalizeVariants, enableConsoleLogDrain, enableContextDevTools, enableDebugConsoleLogDrain, enableUniformInsights, encodeCookieType, evaluateVariantMatch, eventEvaluator, explainStringMatch, explainStringMatchCriteria, getEnrichmentVectorKey, isStringMatch, pageViewCountDimension, pageViewCountEvaluator, parseCookieScores, parseCookieType, parseQuickConnect, parseScoreCookie, queryStringEvaluator, quirkEvaluator, serializeCookie, serializeCookieType, serializePersonalizeVariants, serializeQuickConnect };
|
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, az as ContextState, aA as ContextStateUpdate, J as CriteriaEvaluatorParameters, I as CriteriaEvaluatorResult, an 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, au as EnrichmentData, ax as EventData, aB as GoalStateUpdate, at as Goals, H as GroupCriteriaEvaluator, ag as IdentifyCommand, F as LogMessageGroup, E as LogMessageSingle, y as LogMessages, G as ManifestInstance, N as ManifestV2, M as MessageCategory, B as MessageFunc, ab as ModifyScoreCommand, ac as ModifySessionScoreCommand, Y as NumberMatch, P as PersonalizationEvent, Q as PersonalizationManifest, av as PersonalizeControlVariant, a2 as PersonalizeOptions, aw as PersonalizeVariants, a6 as PersonalizedResult, a5 as PersonalizedVariant, ar as Quirks, al as SERVER_STATE_ID, ak as ServerToClientTransitionState, ad as SetConsentCommand, ah as SetControlGroupCommand, aa as SetGoalCommand, ai as SetPersonalizeVariantControlCommand, ae as SetQuirkCommand, af 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, as as Tests, am as TransitionDataStoreEvents, aq as VisitorDataStore, ap as VisitorDataStoreEvents, ao as VisitorDataStoreOptions, aj as areCommandsEqual, ay as emptyVisitorData, a3 as personalizeVariations, a0 as testVariations } from './types-
|
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-o4ZU_qKY.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, az as ContextState, aA as ContextStateUpdate, J as CriteriaEvaluatorParameters, I as CriteriaEvaluatorResult, an 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, au as EnrichmentData, ax as EventData, aB as GoalStateUpdate, at as Goals, H as GroupCriteriaEvaluator, ag as IdentifyCommand, F as LogMessageGroup, E as LogMessageSingle, y as LogMessages, G as ManifestInstance, N as ManifestV2, M as MessageCategory, B as MessageFunc, ab as ModifyScoreCommand, ac as ModifySessionScoreCommand, Y as NumberMatch, P as PersonalizationEvent, Q as PersonalizationManifest, av as PersonalizeControlVariant, a2 as PersonalizeOptions, aw as PersonalizeVariants, a6 as PersonalizedResult, a5 as PersonalizedVariant, ar as Quirks, al as SERVER_STATE_ID, ak as ServerToClientTransitionState, ad as SetConsentCommand, ah as SetControlGroupCommand, aa as SetGoalCommand, ai as SetPersonalizeVariantControlCommand, ae as SetQuirkCommand, af 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, as as Tests, am as TransitionDataStoreEvents, aq as VisitorDataStore, ap as VisitorDataStoreEvents, ao as VisitorDataStoreOptions, aj as areCommandsEqual, ay as emptyVisitorData, a3 as personalizeVariations, a0 as testVariations } from './types-o4ZU_qKY.js';
|
3
3
|
import Cookies from 'js-cookie';
|
4
4
|
import 'mitt';
|
5
5
|
|
@@ -50,6 +50,18 @@ declare class CookieTransitionDataStore extends TransitionDataStore {
|
|
50
50
|
handleDelete(): Promise<void>;
|
51
51
|
handleUpdateData(_: StorageCommands[], computedValue: VisitorData): Promise<void>;
|
52
52
|
}
|
53
|
+
declare const TYPE_SEP = "~";
|
54
|
+
declare const PAIR_SEP = "!";
|
55
|
+
declare const KV_SEP = "-";
|
56
|
+
declare function parseScoreCookie(cookieValue: string | undefined): Partial<VisitorData> | undefined;
|
57
|
+
declare function parseCookieScores(type: string | undefined): Record<string, string>;
|
58
|
+
declare function parseCookieType(type: string | undefined): Record<string, string>;
|
59
|
+
declare function decodeCookieType(type: Record<string, string>): Record<string, number>;
|
60
|
+
declare function serializeCookie(data: VisitorData): string;
|
61
|
+
declare function serializePersonalizeVariants({ personalizeVariants, }: Pick<VisitorData, 'personalizeVariants'>): string;
|
62
|
+
declare function decodePersonalizeVariants(data: string | undefined): VisitorData['personalizeVariants'];
|
63
|
+
declare function encodeCookieType(type: Record<string, number>): Record<string, string>;
|
64
|
+
declare function serializeCookieType(type: Record<string, string>): string;
|
53
65
|
|
54
66
|
type EdgeTransitionDataStoreOptions = TransitionDataStoreOptions & {
|
55
67
|
serverCookieValue?: string;
|
@@ -177,4 +189,4 @@ type QuickConnectConfig = {
|
|
177
189
|
declare function serializeQuickConnect(config: QuickConnectConfig): string;
|
178
190
|
declare function parseQuickConnect(serialized: string): Required<QuickConnectConfig>;
|
179
191
|
|
180
|
-
export { AggregateDimension, type ConsoleDebugLogDrainOptions, type ContextDevToolOptions, ContextPlugin, CookieTransitionDataStore, type CookieTransitionDataStoreOptions, CriteriaEvaluator, DecayFunction, DevToolsEvents, EdgeNodeTagName, type EdgePersonalizeComponentOptions, type EdgeTestComponentOptions, EdgeTransitionDataStore, type EdgeTransitionDataStoreOptions, type EnableUniformInsightsOptions, type LinearDecayOptions, LogDrain, LogMessage, OutputSeverity, type QuickConnectConfig, ScoreVector, ScriptType, StorageCommands, StringMatch, TransitionDataStore, TransitionDataStoreOptions, UNIFORM_DEFAULT_COOKIE_NAME, VariantMatchCriteria, VisitorData, computeAggregateDimensions, cookieEvaluator, createConsoleLogDrain, createDebugConsoleLogDrain, createLinearDecay, currentPageEvaluator, enableConsoleLogDrain, enableContextDevTools, enableDebugConsoleLogDrain, enableUniformInsights, evaluateVariantMatch, eventEvaluator, explainStringMatch, explainStringMatchCriteria, getEnrichmentVectorKey, isStringMatch, pageViewCountDimension, pageViewCountEvaluator, parseQuickConnect, queryStringEvaluator, quirkEvaluator, serializeQuickConnect };
|
192
|
+
export { AggregateDimension, type ConsoleDebugLogDrainOptions, type ContextDevToolOptions, ContextPlugin, CookieTransitionDataStore, type CookieTransitionDataStoreOptions, CriteriaEvaluator, DecayFunction, DevToolsEvents, EdgeNodeTagName, type EdgePersonalizeComponentOptions, type EdgeTestComponentOptions, EdgeTransitionDataStore, type EdgeTransitionDataStoreOptions, type EnableUniformInsightsOptions, KV_SEP, type LinearDecayOptions, LogDrain, LogMessage, OutputSeverity, PAIR_SEP, type QuickConnectConfig, ScoreVector, ScriptType, StorageCommands, StringMatch, TYPE_SEP, TransitionDataStore, TransitionDataStoreOptions, UNIFORM_DEFAULT_COOKIE_NAME, VariantMatchCriteria, VisitorData, computeAggregateDimensions, cookieEvaluator, createConsoleLogDrain, createDebugConsoleLogDrain, createLinearDecay, currentPageEvaluator, decodeCookieType, decodePersonalizeVariants, enableConsoleLogDrain, enableContextDevTools, enableDebugConsoleLogDrain, enableUniformInsights, encodeCookieType, evaluateVariantMatch, eventEvaluator, explainStringMatch, explainStringMatchCriteria, getEnrichmentVectorKey, isStringMatch, pageViewCountDimension, pageViewCountEvaluator, parseCookieScores, parseCookieType, parseQuickConnect, parseScoreCookie, queryStringEvaluator, quirkEvaluator, serializeCookie, serializeCookieType, serializePersonalizeVariants, serializeQuickConnect };
|
package/dist/index.esm.js
CHANGED
@@ -60,13 +60,11 @@ function computeAggregateDimension(primitiveScores, aggregateDimension, allAggre
|
|
60
60
|
var ENR_SEPARATOR = "_";
|
61
61
|
|
62
62
|
// src/manifest/goals/evaluators/SignalGoalEvaluator.ts
|
63
|
-
var
|
63
|
+
var _id;
|
64
64
|
var SignalGoalEvaluator = class {
|
65
65
|
constructor(options) {
|
66
|
-
__privateAdd(this, _signal);
|
67
66
|
__privateAdd(this, _id);
|
68
67
|
__privateSet(this, _id, options.id);
|
69
|
-
__privateSet(this, _signal, options.signal);
|
70
68
|
}
|
71
69
|
get id() {
|
72
70
|
return __privateGet(this, _id);
|
@@ -81,7 +79,6 @@ var SignalGoalEvaluator = class {
|
|
81
79
|
};
|
82
80
|
}
|
83
81
|
};
|
84
|
-
_signal = new WeakMap();
|
85
82
|
_id = new WeakMap();
|
86
83
|
|
87
84
|
// src/manifest/signals/SignalInstance.ts
|
@@ -651,75 +648,66 @@ function personalizeVariations({
|
|
651
648
|
take = 1,
|
652
649
|
onLogMessage
|
653
650
|
}) {
|
654
|
-
var _a, _b, _c
|
651
|
+
var _a, _b, _c;
|
655
652
|
onLogMessage == null ? void 0 : onLogMessage(["info", 300, "GROUP", { name, take }]);
|
656
653
|
try {
|
657
|
-
const
|
658
|
-
const results = [];
|
659
|
-
let personalized = false;
|
660
|
-
const scores = context.scores;
|
661
|
-
let index = 0;
|
654
|
+
const variantMatches = [];
|
662
655
|
const defaultVariants = [];
|
663
656
|
for (const variant of variations) {
|
664
|
-
if (
|
657
|
+
if ((_a = variant.pz) == null ? void 0 : _a.crit.length) {
|
658
|
+
if (variantMatches.length !== take && evaluateVariantMatch(variant.id, variant.pz, context.scores, onLogMessage)) {
|
659
|
+
variantMatches.push(variant);
|
660
|
+
}
|
661
|
+
} else {
|
665
662
|
defaultVariants.push(variant);
|
666
663
|
}
|
667
664
|
}
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
}
|
684
|
-
if (control) {
|
685
|
-
continue;
|
686
|
-
}
|
687
|
-
if (evaluateVariantMatch(variant.id, variant.pz, scores, onLogMessage)) {
|
688
|
-
let variantToAdd = variant;
|
689
|
-
let isControl = false;
|
690
|
-
const isDefault = defaultVariants.find((v) => v.id === variant.id);
|
691
|
-
if (take === 1 && !isDefault && defaultVariants.length && typeof variant.pz.control === "number") {
|
692
|
-
isControl = context.getPersonalizeVariantControl(name, currentIndex);
|
693
|
-
if (typeof isControl === "undefined") {
|
694
|
-
isControl = rollForControlGroup(variant.pz.control);
|
695
|
-
context.storage.updateData([
|
696
|
-
{
|
697
|
-
type: "setpersonalizecontrol",
|
698
|
-
data: {
|
699
|
-
personlizationName: name,
|
700
|
-
index: currentIndex,
|
701
|
-
control: isControl
|
702
|
-
}
|
665
|
+
const result = [];
|
666
|
+
for (let i = 0; i < variantMatches.length; i++) {
|
667
|
+
let isControl = (_b = context.storage.data.controlGroup) != null ? _b : false;
|
668
|
+
const variant = variantMatches[i];
|
669
|
+
if (!isControl && typeof ((_c = variant.pz) == null ? void 0 : _c.control) === "number") {
|
670
|
+
isControl = context.getPersonalizeVariantControl(name, i);
|
671
|
+
if (typeof isControl === "undefined") {
|
672
|
+
isControl = rollForControlGroup(variant.pz.control);
|
673
|
+
context.storage.updateData([
|
674
|
+
{
|
675
|
+
type: "setpersonalizecontrol",
|
676
|
+
data: {
|
677
|
+
personlizationName: name,
|
678
|
+
index: i,
|
679
|
+
control: isControl
|
703
680
|
}
|
704
|
-
|
705
|
-
|
706
|
-
if (isControl) {
|
707
|
-
variantToAdd = {
|
708
|
-
...defaultVariants[0],
|
709
|
-
id: variant.id
|
710
|
-
};
|
711
|
-
}
|
681
|
+
}
|
682
|
+
]);
|
712
683
|
}
|
713
|
-
personalized = personalized || typeof variantToAdd.pz !== "undefined";
|
714
|
-
results.push({
|
715
|
-
...variantToAdd,
|
716
|
-
control: isControl
|
717
|
-
});
|
718
684
|
}
|
685
|
+
let variantToAdd = variant;
|
686
|
+
if (isControl) {
|
687
|
+
const defaultReplacement = defaultVariants.shift();
|
688
|
+
if (defaultReplacement) {
|
689
|
+
variantToAdd = {
|
690
|
+
...defaultReplacement,
|
691
|
+
id: variant.id
|
692
|
+
};
|
693
|
+
} else {
|
694
|
+
variantToAdd = void 0;
|
695
|
+
}
|
696
|
+
}
|
697
|
+
if (variantToAdd) {
|
698
|
+
result.push({ ...variantToAdd, control: isControl });
|
699
|
+
}
|
700
|
+
}
|
701
|
+
while (result.length < take && defaultVariants.length) {
|
702
|
+
result.push({ ...defaultVariants.shift(), control: false });
|
719
703
|
}
|
704
|
+
const personalized = result.some((v) => {
|
705
|
+
var _a2;
|
706
|
+
return (_a2 = v.pz) == null ? void 0 : _a2.crit.length;
|
707
|
+
});
|
720
708
|
return {
|
721
709
|
personalized,
|
722
|
-
variations:
|
710
|
+
variations: result
|
723
711
|
};
|
724
712
|
} finally {
|
725
713
|
onLogMessage == null ? void 0 : onLogMessage(["info", 300, "ENDGROUP"]);
|
@@ -787,7 +775,7 @@ var testVariations = ({
|
|
787
775
|
let distributionOffset = 0;
|
788
776
|
selectedVariant = variations.find((variant, index) => {
|
789
777
|
const distribution = distributions[index];
|
790
|
-
if (random > distributionOffset && random <= distributionOffset + distribution) {
|
778
|
+
if ((random > distributionOffset || random === 0) && random <= distributionOffset + distribution) {
|
791
779
|
return variant;
|
792
780
|
}
|
793
781
|
distributionOffset += distribution;
|
@@ -971,14 +959,26 @@ function parseScoreCookie(cookieValue) {
|
|
971
959
|
const data = {
|
972
960
|
// this is true since we're reading a cookie, which wouldn't exist if consent wasn't given
|
973
961
|
consent: true,
|
974
|
-
sessionScores: decodeCookieType(
|
975
|
-
scores: decodeCookieType(
|
962
|
+
sessionScores: decodeCookieType(parseCookieScores(sessionScores)),
|
963
|
+
scores: decodeCookieType(parseCookieScores(visitorScores)),
|
976
964
|
tests: parseCookieType(abTestData),
|
977
965
|
controlGroup: controlGroup === "1",
|
978
966
|
personalizeVariants: decodePersonalizeVariants(personalizeVariants)
|
979
967
|
};
|
980
968
|
return data;
|
981
969
|
}
|
970
|
+
function parseCookieScores(type) {
|
971
|
+
if (!type) {
|
972
|
+
return {};
|
973
|
+
}
|
974
|
+
const pairs = type.split(PAIR_SEP).map((pair) => pair.split(KV_SEP));
|
975
|
+
return pairs.reduce((acc, cur) => {
|
976
|
+
if (cur.length < 2) return acc;
|
977
|
+
const key = cur.slice(0, -1).join(KV_SEP);
|
978
|
+
acc[key] = cur[cur.length - 1];
|
979
|
+
return acc;
|
980
|
+
}, {});
|
981
|
+
}
|
982
982
|
function parseCookieType(type) {
|
983
983
|
if (!type) {
|
984
984
|
return {};
|
@@ -1141,7 +1141,7 @@ import mitt2 from "mitt";
|
|
1141
1141
|
// src/storage/util/applyCommandsToData.ts
|
1142
1142
|
import rfdc from "rfdc";
|
1143
1143
|
var clone = rfdc();
|
1144
|
-
function applyCommandsToData(commands, state
|
1144
|
+
function applyCommandsToData(commands, state) {
|
1145
1145
|
const newData = state ? clone(state) : emptyVisitorData();
|
1146
1146
|
commands.forEach((command) => {
|
1147
1147
|
var _a, _b, _c;
|
@@ -1156,7 +1156,6 @@ function applyCommandsToData(commands, state, inControlGroup) {
|
|
1156
1156
|
newData.tests[command.data.test] = command.data.variant;
|
1157
1157
|
break;
|
1158
1158
|
case "modscore":
|
1159
|
-
if (inControlGroup) break;
|
1160
1159
|
const delta = Number(command.data.delta);
|
1161
1160
|
if (isNaN(delta)) {
|
1162
1161
|
throw new Error("Non-number delta received");
|
@@ -1165,7 +1164,6 @@ function applyCommandsToData(commands, state, inControlGroup) {
|
|
1165
1164
|
newData.scores[command.data.dimension] = existing + delta;
|
1166
1165
|
break;
|
1167
1166
|
case "modscoreS":
|
1168
|
-
if (inControlGroup) break;
|
1169
1167
|
const deltaS = Number(command.data.delta);
|
1170
1168
|
if (isNaN(deltaS)) {
|
1171
1169
|
throw new Error("Non-number delta received");
|
@@ -1304,12 +1302,12 @@ var VisitorDataStore = class {
|
|
1304
1302
|
}
|
1305
1303
|
/** Gets the current visitor data. This property is always up to date. */
|
1306
1304
|
get data() {
|
1307
|
-
var _a, _b;
|
1308
|
-
const data = __privateGet(this, _VisitorDataStore_instances, currentData_get);
|
1305
|
+
var _a, _b, _c;
|
1306
|
+
const data = (_a = __privateGet(this, _VisitorDataStore_instances, currentData_get)) != null ? _a : { visitorData: __privateMethod(this, _VisitorDataStore_instances, defaultData_fn).call(this), updated: (/* @__PURE__ */ new Date()).getTime() };
|
1309
1307
|
if (__privateMethod(this, _VisitorDataStore_instances, isExpired_fn).call(this, data)) {
|
1310
1308
|
const { sessionScores, ...newData } = data.visitorData;
|
1311
1309
|
__privateMethod(this, _VisitorDataStore_instances, replaceData_fn).call(this, { ...newData, sessionScores: {} });
|
1312
|
-
(
|
1310
|
+
(_c = (_b = __privateGet(this, _options)).onLogMessage) == null ? void 0 : _c.call(_b, ["info", 120]);
|
1313
1311
|
return __privateGet(this, _VisitorDataStore_instances, currentData_get).visitorData;
|
1314
1312
|
}
|
1315
1313
|
return data.visitorData;
|
@@ -1322,17 +1320,17 @@ var VisitorDataStore = class {
|
|
1322
1320
|
}
|
1323
1321
|
/** Push data update command(s) into the visitor data */
|
1324
1322
|
async updateData(commands) {
|
1325
|
-
var _a, _b, _c
|
1323
|
+
var _a, _b, _c;
|
1326
1324
|
if (commands.length === 0) {
|
1327
1325
|
return;
|
1328
1326
|
}
|
1329
1327
|
(_b = (_a = __privateGet(this, _options)).onLogMessage) == null ? void 0 : _b.call(_a, ["debug", 101, commands]);
|
1330
|
-
const newData = applyCommandsToData(commands, this.data
|
1328
|
+
const newData = applyCommandsToData(commands, this.data);
|
1331
1329
|
if (commands.some((c) => c.type === "consent" && !c.data)) {
|
1332
1330
|
__privateGet(this, _persist).delete(STORAGE_KEY, true);
|
1333
1331
|
}
|
1334
1332
|
__privateMethod(this, _VisitorDataStore_instances, replaceData_fn).call(this, newData);
|
1335
|
-
await ((
|
1333
|
+
await ((_c = __privateGet(this, _options).transitionStore) == null ? void 0 : _c.updateData(commands, __privateGet(this, _VisitorDataStore_instances, currentData_get).visitorData));
|
1336
1334
|
__privateGet(this, _mitt2).emit("commandsExecuted", commands);
|
1337
1335
|
}
|
1338
1336
|
/**
|
@@ -1369,20 +1367,15 @@ replaceData_fn = function(data, quiet = false) {
|
|
1369
1367
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
1370
1368
|
const oldData = __privateGet(this, _VisitorDataStore_instances, currentData_get);
|
1371
1369
|
const now = Date.now();
|
1372
|
-
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1376
|
-
|
1377
|
-
|
1378
|
-
|
1379
|
-
|
1380
|
-
|
1381
|
-
scores: data.scores,
|
1382
|
-
sessionScores: data.sessionScores,
|
1383
|
-
onLogMessage: __privateGet(this, _options).onLogMessage
|
1384
|
-
});
|
1385
|
-
}
|
1370
|
+
__privateMethod(this, _VisitorDataStore_instances, handleCaps_fn).call(this, data.scores);
|
1371
|
+
__privateMethod(this, _VisitorDataStore_instances, handleCaps_fn).call(this, data.sessionScores);
|
1372
|
+
(_b = (_a = __privateGet(this, _options)).decay) == null ? void 0 : _b.call(_a, {
|
1373
|
+
now,
|
1374
|
+
lastUpd: oldData == null ? void 0 : oldData.updated,
|
1375
|
+
scores: data.scores,
|
1376
|
+
sessionScores: data.sessionScores,
|
1377
|
+
onLogMessage: __privateGet(this, _options).onLogMessage
|
1378
|
+
});
|
1386
1379
|
const haveScoresChanged = !dequal4(oldData == null ? void 0 : oldData.visitorData.scores, data.scores);
|
1387
1380
|
const haveSessionScoresChanged = !dequal4(oldData == null ? void 0 : oldData.visitorData.sessionScores, data.sessionScores);
|
1388
1381
|
const haveQuirksChanged = !dequal4(oldData == null ? void 0 : oldData.visitorData.quirks, data.quirks);
|
@@ -2235,7 +2228,6 @@ var createInsights = ({
|
|
2235
2228
|
},
|
2236
2229
|
pageHit: () => {
|
2237
2230
|
if (!storageData) {
|
2238
|
-
console.error("Insights not initialized");
|
2239
2231
|
return;
|
2240
2232
|
}
|
2241
2233
|
if (previousUrl === window.location.href) {
|
@@ -2263,7 +2255,6 @@ var createInsights = ({
|
|
2263
2255
|
},
|
2264
2256
|
personalizationResult: (result) => {
|
2265
2257
|
if (!storageData) {
|
2266
|
-
console.error("Insights not initialized");
|
2267
2258
|
return;
|
2268
2259
|
}
|
2269
2260
|
client.personalizationResult({
|
@@ -2275,7 +2266,6 @@ var createInsights = ({
|
|
2275
2266
|
},
|
2276
2267
|
goalConvert: (goalId) => {
|
2277
2268
|
if (!storageData) {
|
2278
|
-
console.error("Insights not initialized");
|
2279
2269
|
return;
|
2280
2270
|
}
|
2281
2271
|
client.goalConvert({
|
@@ -2287,7 +2277,6 @@ var createInsights = ({
|
|
2287
2277
|
},
|
2288
2278
|
scoresChange: (scores) => {
|
2289
2279
|
if (!storageData) {
|
2290
|
-
console.error("Insights not initialized");
|
2291
2280
|
return;
|
2292
2281
|
}
|
2293
2282
|
client.scoresChange({
|
@@ -2555,9 +2544,12 @@ export {
|
|
2555
2544
|
EdgeNodeTagName,
|
2556
2545
|
EdgeTransitionDataStore,
|
2557
2546
|
GroupCriteriaEvaluator,
|
2547
|
+
KV_SEP,
|
2558
2548
|
ManifestInstance,
|
2549
|
+
PAIR_SEP,
|
2559
2550
|
SERVER_STATE_ID,
|
2560
2551
|
ScriptType,
|
2552
|
+
TYPE_SEP,
|
2561
2553
|
TransitionDataStore,
|
2562
2554
|
UNIFORM_DEFAULT_COOKIE_NAME,
|
2563
2555
|
VisitorDataStore,
|
@@ -2568,11 +2560,14 @@ export {
|
|
2568
2560
|
createDebugConsoleLogDrain,
|
2569
2561
|
createLinearDecay,
|
2570
2562
|
currentPageEvaluator,
|
2563
|
+
decodeCookieType,
|
2564
|
+
decodePersonalizeVariants,
|
2571
2565
|
emptyVisitorData,
|
2572
2566
|
enableConsoleLogDrain,
|
2573
2567
|
enableContextDevTools,
|
2574
2568
|
enableDebugConsoleLogDrain,
|
2575
2569
|
enableUniformInsights,
|
2570
|
+
encodeCookieType,
|
2576
2571
|
evaluateVariantMatch,
|
2577
2572
|
eventEvaluator,
|
2578
2573
|
explainStringMatch,
|
@@ -2581,10 +2576,16 @@ export {
|
|
2581
2576
|
isStringMatch,
|
2582
2577
|
pageViewCountDimension,
|
2583
2578
|
pageViewCountEvaluator,
|
2579
|
+
parseCookieScores,
|
2580
|
+
parseCookieType,
|
2584
2581
|
parseQuickConnect,
|
2582
|
+
parseScoreCookie,
|
2585
2583
|
personalizeVariations,
|
2586
2584
|
queryStringEvaluator,
|
2587
2585
|
quirkEvaluator,
|
2586
|
+
serializeCookie,
|
2587
|
+
serializeCookieType,
|
2588
|
+
serializePersonalizeVariants,
|
2588
2589
|
serializeQuickConnect,
|
2589
2590
|
testVariations
|
2590
2591
|
};
|
package/dist/index.js
CHANGED
@@ -47,9 +47,12 @@ __export(src_exports, {
|
|
47
47
|
EdgeNodeTagName: () => EdgeNodeTagName,
|
48
48
|
EdgeTransitionDataStore: () => EdgeTransitionDataStore,
|
49
49
|
GroupCriteriaEvaluator: () => GroupCriteriaEvaluator,
|
50
|
+
KV_SEP: () => KV_SEP,
|
50
51
|
ManifestInstance: () => ManifestInstance,
|
52
|
+
PAIR_SEP: () => PAIR_SEP,
|
51
53
|
SERVER_STATE_ID: () => SERVER_STATE_ID,
|
52
54
|
ScriptType: () => ScriptType,
|
55
|
+
TYPE_SEP: () => TYPE_SEP,
|
53
56
|
TransitionDataStore: () => TransitionDataStore,
|
54
57
|
UNIFORM_DEFAULT_COOKIE_NAME: () => UNIFORM_DEFAULT_COOKIE_NAME,
|
55
58
|
VisitorDataStore: () => VisitorDataStore,
|
@@ -60,11 +63,14 @@ __export(src_exports, {
|
|
60
63
|
createDebugConsoleLogDrain: () => createDebugConsoleLogDrain,
|
61
64
|
createLinearDecay: () => createLinearDecay,
|
62
65
|
currentPageEvaluator: () => currentPageEvaluator,
|
66
|
+
decodeCookieType: () => decodeCookieType,
|
67
|
+
decodePersonalizeVariants: () => decodePersonalizeVariants,
|
63
68
|
emptyVisitorData: () => emptyVisitorData,
|
64
69
|
enableConsoleLogDrain: () => enableConsoleLogDrain,
|
65
70
|
enableContextDevTools: () => enableContextDevTools,
|
66
71
|
enableDebugConsoleLogDrain: () => enableDebugConsoleLogDrain,
|
67
72
|
enableUniformInsights: () => enableUniformInsights,
|
73
|
+
encodeCookieType: () => encodeCookieType,
|
68
74
|
evaluateVariantMatch: () => evaluateVariantMatch,
|
69
75
|
eventEvaluator: () => eventEvaluator,
|
70
76
|
explainStringMatch: () => explainStringMatch,
|
@@ -73,10 +79,16 @@ __export(src_exports, {
|
|
73
79
|
isStringMatch: () => isStringMatch,
|
74
80
|
pageViewCountDimension: () => pageViewCountDimension,
|
75
81
|
pageViewCountEvaluator: () => pageViewCountEvaluator,
|
82
|
+
parseCookieScores: () => parseCookieScores,
|
83
|
+
parseCookieType: () => parseCookieType,
|
76
84
|
parseQuickConnect: () => parseQuickConnect,
|
85
|
+
parseScoreCookie: () => parseScoreCookie,
|
77
86
|
personalizeVariations: () => personalizeVariations,
|
78
87
|
queryStringEvaluator: () => queryStringEvaluator,
|
79
88
|
quirkEvaluator: () => quirkEvaluator,
|
89
|
+
serializeCookie: () => serializeCookie,
|
90
|
+
serializeCookieType: () => serializeCookieType,
|
91
|
+
serializePersonalizeVariants: () => serializePersonalizeVariants,
|
80
92
|
serializeQuickConnect: () => serializeQuickConnect,
|
81
93
|
testVariations: () => testVariations
|
82
94
|
});
|
@@ -132,13 +144,11 @@ function computeAggregateDimension(primitiveScores, aggregateDimension, allAggre
|
|
132
144
|
var ENR_SEPARATOR = "_";
|
133
145
|
|
134
146
|
// src/manifest/goals/evaluators/SignalGoalEvaluator.ts
|
135
|
-
var
|
147
|
+
var _id;
|
136
148
|
var SignalGoalEvaluator = class {
|
137
149
|
constructor(options) {
|
138
|
-
__privateAdd(this, _signal);
|
139
150
|
__privateAdd(this, _id);
|
140
151
|
__privateSet(this, _id, options.id);
|
141
|
-
__privateSet(this, _signal, options.signal);
|
142
152
|
}
|
143
153
|
get id() {
|
144
154
|
return __privateGet(this, _id);
|
@@ -153,7 +163,6 @@ var SignalGoalEvaluator = class {
|
|
153
163
|
};
|
154
164
|
}
|
155
165
|
};
|
156
|
-
_signal = new WeakMap();
|
157
166
|
_id = new WeakMap();
|
158
167
|
|
159
168
|
// src/manifest/signals/SignalInstance.ts
|
@@ -723,75 +732,66 @@ function personalizeVariations({
|
|
723
732
|
take = 1,
|
724
733
|
onLogMessage
|
725
734
|
}) {
|
726
|
-
var _a, _b, _c
|
735
|
+
var _a, _b, _c;
|
727
736
|
onLogMessage == null ? void 0 : onLogMessage(["info", 300, "GROUP", { name, take }]);
|
728
737
|
try {
|
729
|
-
const
|
730
|
-
const results = [];
|
731
|
-
let personalized = false;
|
732
|
-
const scores = context.scores;
|
733
|
-
let index = 0;
|
738
|
+
const variantMatches = [];
|
734
739
|
const defaultVariants = [];
|
735
740
|
for (const variant of variations) {
|
736
|
-
if (
|
741
|
+
if ((_a = variant.pz) == null ? void 0 : _a.crit.length) {
|
742
|
+
if (variantMatches.length !== take && evaluateVariantMatch(variant.id, variant.pz, context.scores, onLogMessage)) {
|
743
|
+
variantMatches.push(variant);
|
744
|
+
}
|
745
|
+
} else {
|
737
746
|
defaultVariants.push(variant);
|
738
747
|
}
|
739
748
|
}
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
}
|
756
|
-
if (control) {
|
757
|
-
continue;
|
758
|
-
}
|
759
|
-
if (evaluateVariantMatch(variant.id, variant.pz, scores, onLogMessage)) {
|
760
|
-
let variantToAdd = variant;
|
761
|
-
let isControl = false;
|
762
|
-
const isDefault = defaultVariants.find((v) => v.id === variant.id);
|
763
|
-
if (take === 1 && !isDefault && defaultVariants.length && typeof variant.pz.control === "number") {
|
764
|
-
isControl = context.getPersonalizeVariantControl(name, currentIndex);
|
765
|
-
if (typeof isControl === "undefined") {
|
766
|
-
isControl = rollForControlGroup(variant.pz.control);
|
767
|
-
context.storage.updateData([
|
768
|
-
{
|
769
|
-
type: "setpersonalizecontrol",
|
770
|
-
data: {
|
771
|
-
personlizationName: name,
|
772
|
-
index: currentIndex,
|
773
|
-
control: isControl
|
774
|
-
}
|
749
|
+
const result = [];
|
750
|
+
for (let i = 0; i < variantMatches.length; i++) {
|
751
|
+
let isControl = (_b = context.storage.data.controlGroup) != null ? _b : false;
|
752
|
+
const variant = variantMatches[i];
|
753
|
+
if (!isControl && typeof ((_c = variant.pz) == null ? void 0 : _c.control) === "number") {
|
754
|
+
isControl = context.getPersonalizeVariantControl(name, i);
|
755
|
+
if (typeof isControl === "undefined") {
|
756
|
+
isControl = rollForControlGroup(variant.pz.control);
|
757
|
+
context.storage.updateData([
|
758
|
+
{
|
759
|
+
type: "setpersonalizecontrol",
|
760
|
+
data: {
|
761
|
+
personlizationName: name,
|
762
|
+
index: i,
|
763
|
+
control: isControl
|
775
764
|
}
|
776
|
-
|
777
|
-
|
778
|
-
if (isControl) {
|
779
|
-
variantToAdd = {
|
780
|
-
...defaultVariants[0],
|
781
|
-
id: variant.id
|
782
|
-
};
|
783
|
-
}
|
765
|
+
}
|
766
|
+
]);
|
784
767
|
}
|
785
|
-
personalized = personalized || typeof variantToAdd.pz !== "undefined";
|
786
|
-
results.push({
|
787
|
-
...variantToAdd,
|
788
|
-
control: isControl
|
789
|
-
});
|
790
768
|
}
|
769
|
+
let variantToAdd = variant;
|
770
|
+
if (isControl) {
|
771
|
+
const defaultReplacement = defaultVariants.shift();
|
772
|
+
if (defaultReplacement) {
|
773
|
+
variantToAdd = {
|
774
|
+
...defaultReplacement,
|
775
|
+
id: variant.id
|
776
|
+
};
|
777
|
+
} else {
|
778
|
+
variantToAdd = void 0;
|
779
|
+
}
|
780
|
+
}
|
781
|
+
if (variantToAdd) {
|
782
|
+
result.push({ ...variantToAdd, control: isControl });
|
783
|
+
}
|
784
|
+
}
|
785
|
+
while (result.length < take && defaultVariants.length) {
|
786
|
+
result.push({ ...defaultVariants.shift(), control: false });
|
791
787
|
}
|
788
|
+
const personalized = result.some((v) => {
|
789
|
+
var _a2;
|
790
|
+
return (_a2 = v.pz) == null ? void 0 : _a2.crit.length;
|
791
|
+
});
|
792
792
|
return {
|
793
793
|
personalized,
|
794
|
-
variations:
|
794
|
+
variations: result
|
795
795
|
};
|
796
796
|
} finally {
|
797
797
|
onLogMessage == null ? void 0 : onLogMessage(["info", 300, "ENDGROUP"]);
|
@@ -859,7 +859,7 @@ var testVariations = ({
|
|
859
859
|
let distributionOffset = 0;
|
860
860
|
selectedVariant = variations.find((variant, index) => {
|
861
861
|
const distribution = distributions[index];
|
862
|
-
if (random > distributionOffset && random <= distributionOffset + distribution) {
|
862
|
+
if ((random > distributionOffset || random === 0) && random <= distributionOffset + distribution) {
|
863
863
|
return variant;
|
864
864
|
}
|
865
865
|
distributionOffset += distribution;
|
@@ -1043,14 +1043,26 @@ function parseScoreCookie(cookieValue) {
|
|
1043
1043
|
const data = {
|
1044
1044
|
// this is true since we're reading a cookie, which wouldn't exist if consent wasn't given
|
1045
1045
|
consent: true,
|
1046
|
-
sessionScores: decodeCookieType(
|
1047
|
-
scores: decodeCookieType(
|
1046
|
+
sessionScores: decodeCookieType(parseCookieScores(sessionScores)),
|
1047
|
+
scores: decodeCookieType(parseCookieScores(visitorScores)),
|
1048
1048
|
tests: parseCookieType(abTestData),
|
1049
1049
|
controlGroup: controlGroup === "1",
|
1050
1050
|
personalizeVariants: decodePersonalizeVariants(personalizeVariants)
|
1051
1051
|
};
|
1052
1052
|
return data;
|
1053
1053
|
}
|
1054
|
+
function parseCookieScores(type) {
|
1055
|
+
if (!type) {
|
1056
|
+
return {};
|
1057
|
+
}
|
1058
|
+
const pairs = type.split(PAIR_SEP).map((pair) => pair.split(KV_SEP));
|
1059
|
+
return pairs.reduce((acc, cur) => {
|
1060
|
+
if (cur.length < 2) return acc;
|
1061
|
+
const key = cur.slice(0, -1).join(KV_SEP);
|
1062
|
+
acc[key] = cur[cur.length - 1];
|
1063
|
+
return acc;
|
1064
|
+
}, {});
|
1065
|
+
}
|
1054
1066
|
function parseCookieType(type) {
|
1055
1067
|
if (!type) {
|
1056
1068
|
return {};
|
@@ -1213,7 +1225,7 @@ var import_mitt2 = __toESM(require("mitt"));
|
|
1213
1225
|
// src/storage/util/applyCommandsToData.ts
|
1214
1226
|
var import_rfdc = __toESM(require("rfdc"));
|
1215
1227
|
var clone = (0, import_rfdc.default)();
|
1216
|
-
function applyCommandsToData(commands, state
|
1228
|
+
function applyCommandsToData(commands, state) {
|
1217
1229
|
const newData = state ? clone(state) : emptyVisitorData();
|
1218
1230
|
commands.forEach((command) => {
|
1219
1231
|
var _a, _b, _c;
|
@@ -1228,7 +1240,6 @@ function applyCommandsToData(commands, state, inControlGroup) {
|
|
1228
1240
|
newData.tests[command.data.test] = command.data.variant;
|
1229
1241
|
break;
|
1230
1242
|
case "modscore":
|
1231
|
-
if (inControlGroup) break;
|
1232
1243
|
const delta = Number(command.data.delta);
|
1233
1244
|
if (isNaN(delta)) {
|
1234
1245
|
throw new Error("Non-number delta received");
|
@@ -1237,7 +1248,6 @@ function applyCommandsToData(commands, state, inControlGroup) {
|
|
1237
1248
|
newData.scores[command.data.dimension] = existing + delta;
|
1238
1249
|
break;
|
1239
1250
|
case "modscoreS":
|
1240
|
-
if (inControlGroup) break;
|
1241
1251
|
const deltaS = Number(command.data.delta);
|
1242
1252
|
if (isNaN(deltaS)) {
|
1243
1253
|
throw new Error("Non-number delta received");
|
@@ -1376,12 +1386,12 @@ var VisitorDataStore = class {
|
|
1376
1386
|
}
|
1377
1387
|
/** Gets the current visitor data. This property is always up to date. */
|
1378
1388
|
get data() {
|
1379
|
-
var _a, _b;
|
1380
|
-
const data = __privateGet(this, _VisitorDataStore_instances, currentData_get);
|
1389
|
+
var _a, _b, _c;
|
1390
|
+
const data = (_a = __privateGet(this, _VisitorDataStore_instances, currentData_get)) != null ? _a : { visitorData: __privateMethod(this, _VisitorDataStore_instances, defaultData_fn).call(this), updated: (/* @__PURE__ */ new Date()).getTime() };
|
1381
1391
|
if (__privateMethod(this, _VisitorDataStore_instances, isExpired_fn).call(this, data)) {
|
1382
1392
|
const { sessionScores, ...newData } = data.visitorData;
|
1383
1393
|
__privateMethod(this, _VisitorDataStore_instances, replaceData_fn).call(this, { ...newData, sessionScores: {} });
|
1384
|
-
(
|
1394
|
+
(_c = (_b = __privateGet(this, _options)).onLogMessage) == null ? void 0 : _c.call(_b, ["info", 120]);
|
1385
1395
|
return __privateGet(this, _VisitorDataStore_instances, currentData_get).visitorData;
|
1386
1396
|
}
|
1387
1397
|
return data.visitorData;
|
@@ -1394,17 +1404,17 @@ var VisitorDataStore = class {
|
|
1394
1404
|
}
|
1395
1405
|
/** Push data update command(s) into the visitor data */
|
1396
1406
|
async updateData(commands) {
|
1397
|
-
var _a, _b, _c
|
1407
|
+
var _a, _b, _c;
|
1398
1408
|
if (commands.length === 0) {
|
1399
1409
|
return;
|
1400
1410
|
}
|
1401
1411
|
(_b = (_a = __privateGet(this, _options)).onLogMessage) == null ? void 0 : _b.call(_a, ["debug", 101, commands]);
|
1402
|
-
const newData = applyCommandsToData(commands, this.data
|
1412
|
+
const newData = applyCommandsToData(commands, this.data);
|
1403
1413
|
if (commands.some((c) => c.type === "consent" && !c.data)) {
|
1404
1414
|
__privateGet(this, _persist).delete(STORAGE_KEY, true);
|
1405
1415
|
}
|
1406
1416
|
__privateMethod(this, _VisitorDataStore_instances, replaceData_fn).call(this, newData);
|
1407
|
-
await ((
|
1417
|
+
await ((_c = __privateGet(this, _options).transitionStore) == null ? void 0 : _c.updateData(commands, __privateGet(this, _VisitorDataStore_instances, currentData_get).visitorData));
|
1408
1418
|
__privateGet(this, _mitt2).emit("commandsExecuted", commands);
|
1409
1419
|
}
|
1410
1420
|
/**
|
@@ -1441,20 +1451,15 @@ replaceData_fn = function(data, quiet = false) {
|
|
1441
1451
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
1442
1452
|
const oldData = __privateGet(this, _VisitorDataStore_instances, currentData_get);
|
1443
1453
|
const now = Date.now();
|
1444
|
-
|
1445
|
-
|
1446
|
-
|
1447
|
-
|
1448
|
-
|
1449
|
-
|
1450
|
-
|
1451
|
-
|
1452
|
-
|
1453
|
-
scores: data.scores,
|
1454
|
-
sessionScores: data.sessionScores,
|
1455
|
-
onLogMessage: __privateGet(this, _options).onLogMessage
|
1456
|
-
});
|
1457
|
-
}
|
1454
|
+
__privateMethod(this, _VisitorDataStore_instances, handleCaps_fn).call(this, data.scores);
|
1455
|
+
__privateMethod(this, _VisitorDataStore_instances, handleCaps_fn).call(this, data.sessionScores);
|
1456
|
+
(_b = (_a = __privateGet(this, _options)).decay) == null ? void 0 : _b.call(_a, {
|
1457
|
+
now,
|
1458
|
+
lastUpd: oldData == null ? void 0 : oldData.updated,
|
1459
|
+
scores: data.scores,
|
1460
|
+
sessionScores: data.sessionScores,
|
1461
|
+
onLogMessage: __privateGet(this, _options).onLogMessage
|
1462
|
+
});
|
1458
1463
|
const haveScoresChanged = !(0, import_lite4.dequal)(oldData == null ? void 0 : oldData.visitorData.scores, data.scores);
|
1459
1464
|
const haveSessionScoresChanged = !(0, import_lite4.dequal)(oldData == null ? void 0 : oldData.visitorData.sessionScores, data.sessionScores);
|
1460
1465
|
const haveQuirksChanged = !(0, import_lite4.dequal)(oldData == null ? void 0 : oldData.visitorData.quirks, data.quirks);
|
@@ -2307,7 +2312,6 @@ var createInsights = ({
|
|
2307
2312
|
},
|
2308
2313
|
pageHit: () => {
|
2309
2314
|
if (!storageData) {
|
2310
|
-
console.error("Insights not initialized");
|
2311
2315
|
return;
|
2312
2316
|
}
|
2313
2317
|
if (previousUrl === window.location.href) {
|
@@ -2335,7 +2339,6 @@ var createInsights = ({
|
|
2335
2339
|
},
|
2336
2340
|
personalizationResult: (result) => {
|
2337
2341
|
if (!storageData) {
|
2338
|
-
console.error("Insights not initialized");
|
2339
2342
|
return;
|
2340
2343
|
}
|
2341
2344
|
client.personalizationResult({
|
@@ -2347,7 +2350,6 @@ var createInsights = ({
|
|
2347
2350
|
},
|
2348
2351
|
goalConvert: (goalId) => {
|
2349
2352
|
if (!storageData) {
|
2350
|
-
console.error("Insights not initialized");
|
2351
2353
|
return;
|
2352
2354
|
}
|
2353
2355
|
client.goalConvert({
|
@@ -2359,7 +2361,6 @@ var createInsights = ({
|
|
2359
2361
|
},
|
2360
2362
|
scoresChange: (scores) => {
|
2361
2363
|
if (!storageData) {
|
2362
|
-
console.error("Insights not initialized");
|
2363
2364
|
return;
|
2364
2365
|
}
|
2365
2366
|
client.scoresChange({
|
@@ -2628,9 +2629,12 @@ function parseQuickConnect(serialized) {
|
|
2628
2629
|
EdgeNodeTagName,
|
2629
2630
|
EdgeTransitionDataStore,
|
2630
2631
|
GroupCriteriaEvaluator,
|
2632
|
+
KV_SEP,
|
2631
2633
|
ManifestInstance,
|
2634
|
+
PAIR_SEP,
|
2632
2635
|
SERVER_STATE_ID,
|
2633
2636
|
ScriptType,
|
2637
|
+
TYPE_SEP,
|
2634
2638
|
TransitionDataStore,
|
2635
2639
|
UNIFORM_DEFAULT_COOKIE_NAME,
|
2636
2640
|
VisitorDataStore,
|
@@ -2641,11 +2645,14 @@ function parseQuickConnect(serialized) {
|
|
2641
2645
|
createDebugConsoleLogDrain,
|
2642
2646
|
createLinearDecay,
|
2643
2647
|
currentPageEvaluator,
|
2648
|
+
decodeCookieType,
|
2649
|
+
decodePersonalizeVariants,
|
2644
2650
|
emptyVisitorData,
|
2645
2651
|
enableConsoleLogDrain,
|
2646
2652
|
enableContextDevTools,
|
2647
2653
|
enableDebugConsoleLogDrain,
|
2648
2654
|
enableUniformInsights,
|
2655
|
+
encodeCookieType,
|
2649
2656
|
evaluateVariantMatch,
|
2650
2657
|
eventEvaluator,
|
2651
2658
|
explainStringMatch,
|
@@ -2654,10 +2661,16 @@ function parseQuickConnect(serialized) {
|
|
2654
2661
|
isStringMatch,
|
2655
2662
|
pageViewCountDimension,
|
2656
2663
|
pageViewCountEvaluator,
|
2664
|
+
parseCookieScores,
|
2665
|
+
parseCookieType,
|
2657
2666
|
parseQuickConnect,
|
2667
|
+
parseScoreCookie,
|
2658
2668
|
personalizeVariations,
|
2659
2669
|
queryStringEvaluator,
|
2660
2670
|
quirkEvaluator,
|
2671
|
+
serializeCookie,
|
2672
|
+
serializeCookieType,
|
2673
|
+
serializePersonalizeVariants,
|
2661
2674
|
serializeQuickConnect,
|
2662
2675
|
testVariations
|
2663
2676
|
});
|
package/dist/index.mjs
CHANGED
@@ -60,13 +60,11 @@ function computeAggregateDimension(primitiveScores, aggregateDimension, allAggre
|
|
60
60
|
var ENR_SEPARATOR = "_";
|
61
61
|
|
62
62
|
// src/manifest/goals/evaluators/SignalGoalEvaluator.ts
|
63
|
-
var
|
63
|
+
var _id;
|
64
64
|
var SignalGoalEvaluator = class {
|
65
65
|
constructor(options) {
|
66
|
-
__privateAdd(this, _signal);
|
67
66
|
__privateAdd(this, _id);
|
68
67
|
__privateSet(this, _id, options.id);
|
69
|
-
__privateSet(this, _signal, options.signal);
|
70
68
|
}
|
71
69
|
get id() {
|
72
70
|
return __privateGet(this, _id);
|
@@ -81,7 +79,6 @@ var SignalGoalEvaluator = class {
|
|
81
79
|
};
|
82
80
|
}
|
83
81
|
};
|
84
|
-
_signal = new WeakMap();
|
85
82
|
_id = new WeakMap();
|
86
83
|
|
87
84
|
// src/manifest/signals/SignalInstance.ts
|
@@ -651,75 +648,66 @@ function personalizeVariations({
|
|
651
648
|
take = 1,
|
652
649
|
onLogMessage
|
653
650
|
}) {
|
654
|
-
var _a, _b, _c
|
651
|
+
var _a, _b, _c;
|
655
652
|
onLogMessage == null ? void 0 : onLogMessage(["info", 300, "GROUP", { name, take }]);
|
656
653
|
try {
|
657
|
-
const
|
658
|
-
const results = [];
|
659
|
-
let personalized = false;
|
660
|
-
const scores = context.scores;
|
661
|
-
let index = 0;
|
654
|
+
const variantMatches = [];
|
662
655
|
const defaultVariants = [];
|
663
656
|
for (const variant of variations) {
|
664
|
-
if (
|
657
|
+
if ((_a = variant.pz) == null ? void 0 : _a.crit.length) {
|
658
|
+
if (variantMatches.length !== take && evaluateVariantMatch(variant.id, variant.pz, context.scores, onLogMessage)) {
|
659
|
+
variantMatches.push(variant);
|
660
|
+
}
|
661
|
+
} else {
|
665
662
|
defaultVariants.push(variant);
|
666
663
|
}
|
667
664
|
}
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
}
|
684
|
-
if (control) {
|
685
|
-
continue;
|
686
|
-
}
|
687
|
-
if (evaluateVariantMatch(variant.id, variant.pz, scores, onLogMessage)) {
|
688
|
-
let variantToAdd = variant;
|
689
|
-
let isControl = false;
|
690
|
-
const isDefault = defaultVariants.find((v) => v.id === variant.id);
|
691
|
-
if (take === 1 && !isDefault && defaultVariants.length && typeof variant.pz.control === "number") {
|
692
|
-
isControl = context.getPersonalizeVariantControl(name, currentIndex);
|
693
|
-
if (typeof isControl === "undefined") {
|
694
|
-
isControl = rollForControlGroup(variant.pz.control);
|
695
|
-
context.storage.updateData([
|
696
|
-
{
|
697
|
-
type: "setpersonalizecontrol",
|
698
|
-
data: {
|
699
|
-
personlizationName: name,
|
700
|
-
index: currentIndex,
|
701
|
-
control: isControl
|
702
|
-
}
|
665
|
+
const result = [];
|
666
|
+
for (let i = 0; i < variantMatches.length; i++) {
|
667
|
+
let isControl = (_b = context.storage.data.controlGroup) != null ? _b : false;
|
668
|
+
const variant = variantMatches[i];
|
669
|
+
if (!isControl && typeof ((_c = variant.pz) == null ? void 0 : _c.control) === "number") {
|
670
|
+
isControl = context.getPersonalizeVariantControl(name, i);
|
671
|
+
if (typeof isControl === "undefined") {
|
672
|
+
isControl = rollForControlGroup(variant.pz.control);
|
673
|
+
context.storage.updateData([
|
674
|
+
{
|
675
|
+
type: "setpersonalizecontrol",
|
676
|
+
data: {
|
677
|
+
personlizationName: name,
|
678
|
+
index: i,
|
679
|
+
control: isControl
|
703
680
|
}
|
704
|
-
|
705
|
-
|
706
|
-
if (isControl) {
|
707
|
-
variantToAdd = {
|
708
|
-
...defaultVariants[0],
|
709
|
-
id: variant.id
|
710
|
-
};
|
711
|
-
}
|
681
|
+
}
|
682
|
+
]);
|
712
683
|
}
|
713
|
-
personalized = personalized || typeof variantToAdd.pz !== "undefined";
|
714
|
-
results.push({
|
715
|
-
...variantToAdd,
|
716
|
-
control: isControl
|
717
|
-
});
|
718
684
|
}
|
685
|
+
let variantToAdd = variant;
|
686
|
+
if (isControl) {
|
687
|
+
const defaultReplacement = defaultVariants.shift();
|
688
|
+
if (defaultReplacement) {
|
689
|
+
variantToAdd = {
|
690
|
+
...defaultReplacement,
|
691
|
+
id: variant.id
|
692
|
+
};
|
693
|
+
} else {
|
694
|
+
variantToAdd = void 0;
|
695
|
+
}
|
696
|
+
}
|
697
|
+
if (variantToAdd) {
|
698
|
+
result.push({ ...variantToAdd, control: isControl });
|
699
|
+
}
|
700
|
+
}
|
701
|
+
while (result.length < take && defaultVariants.length) {
|
702
|
+
result.push({ ...defaultVariants.shift(), control: false });
|
719
703
|
}
|
704
|
+
const personalized = result.some((v) => {
|
705
|
+
var _a2;
|
706
|
+
return (_a2 = v.pz) == null ? void 0 : _a2.crit.length;
|
707
|
+
});
|
720
708
|
return {
|
721
709
|
personalized,
|
722
|
-
variations:
|
710
|
+
variations: result
|
723
711
|
};
|
724
712
|
} finally {
|
725
713
|
onLogMessage == null ? void 0 : onLogMessage(["info", 300, "ENDGROUP"]);
|
@@ -787,7 +775,7 @@ var testVariations = ({
|
|
787
775
|
let distributionOffset = 0;
|
788
776
|
selectedVariant = variations.find((variant, index) => {
|
789
777
|
const distribution = distributions[index];
|
790
|
-
if (random > distributionOffset && random <= distributionOffset + distribution) {
|
778
|
+
if ((random > distributionOffset || random === 0) && random <= distributionOffset + distribution) {
|
791
779
|
return variant;
|
792
780
|
}
|
793
781
|
distributionOffset += distribution;
|
@@ -971,14 +959,26 @@ function parseScoreCookie(cookieValue) {
|
|
971
959
|
const data = {
|
972
960
|
// this is true since we're reading a cookie, which wouldn't exist if consent wasn't given
|
973
961
|
consent: true,
|
974
|
-
sessionScores: decodeCookieType(
|
975
|
-
scores: decodeCookieType(
|
962
|
+
sessionScores: decodeCookieType(parseCookieScores(sessionScores)),
|
963
|
+
scores: decodeCookieType(parseCookieScores(visitorScores)),
|
976
964
|
tests: parseCookieType(abTestData),
|
977
965
|
controlGroup: controlGroup === "1",
|
978
966
|
personalizeVariants: decodePersonalizeVariants(personalizeVariants)
|
979
967
|
};
|
980
968
|
return data;
|
981
969
|
}
|
970
|
+
function parseCookieScores(type) {
|
971
|
+
if (!type) {
|
972
|
+
return {};
|
973
|
+
}
|
974
|
+
const pairs = type.split(PAIR_SEP).map((pair) => pair.split(KV_SEP));
|
975
|
+
return pairs.reduce((acc, cur) => {
|
976
|
+
if (cur.length < 2) return acc;
|
977
|
+
const key = cur.slice(0, -1).join(KV_SEP);
|
978
|
+
acc[key] = cur[cur.length - 1];
|
979
|
+
return acc;
|
980
|
+
}, {});
|
981
|
+
}
|
982
982
|
function parseCookieType(type) {
|
983
983
|
if (!type) {
|
984
984
|
return {};
|
@@ -1141,7 +1141,7 @@ import mitt2 from "mitt";
|
|
1141
1141
|
// src/storage/util/applyCommandsToData.ts
|
1142
1142
|
import rfdc from "rfdc";
|
1143
1143
|
var clone = rfdc();
|
1144
|
-
function applyCommandsToData(commands, state
|
1144
|
+
function applyCommandsToData(commands, state) {
|
1145
1145
|
const newData = state ? clone(state) : emptyVisitorData();
|
1146
1146
|
commands.forEach((command) => {
|
1147
1147
|
var _a, _b, _c;
|
@@ -1156,7 +1156,6 @@ function applyCommandsToData(commands, state, inControlGroup) {
|
|
1156
1156
|
newData.tests[command.data.test] = command.data.variant;
|
1157
1157
|
break;
|
1158
1158
|
case "modscore":
|
1159
|
-
if (inControlGroup) break;
|
1160
1159
|
const delta = Number(command.data.delta);
|
1161
1160
|
if (isNaN(delta)) {
|
1162
1161
|
throw new Error("Non-number delta received");
|
@@ -1165,7 +1164,6 @@ function applyCommandsToData(commands, state, inControlGroup) {
|
|
1165
1164
|
newData.scores[command.data.dimension] = existing + delta;
|
1166
1165
|
break;
|
1167
1166
|
case "modscoreS":
|
1168
|
-
if (inControlGroup) break;
|
1169
1167
|
const deltaS = Number(command.data.delta);
|
1170
1168
|
if (isNaN(deltaS)) {
|
1171
1169
|
throw new Error("Non-number delta received");
|
@@ -1304,12 +1302,12 @@ var VisitorDataStore = class {
|
|
1304
1302
|
}
|
1305
1303
|
/** Gets the current visitor data. This property is always up to date. */
|
1306
1304
|
get data() {
|
1307
|
-
var _a, _b;
|
1308
|
-
const data = __privateGet(this, _VisitorDataStore_instances, currentData_get);
|
1305
|
+
var _a, _b, _c;
|
1306
|
+
const data = (_a = __privateGet(this, _VisitorDataStore_instances, currentData_get)) != null ? _a : { visitorData: __privateMethod(this, _VisitorDataStore_instances, defaultData_fn).call(this), updated: (/* @__PURE__ */ new Date()).getTime() };
|
1309
1307
|
if (__privateMethod(this, _VisitorDataStore_instances, isExpired_fn).call(this, data)) {
|
1310
1308
|
const { sessionScores, ...newData } = data.visitorData;
|
1311
1309
|
__privateMethod(this, _VisitorDataStore_instances, replaceData_fn).call(this, { ...newData, sessionScores: {} });
|
1312
|
-
(
|
1310
|
+
(_c = (_b = __privateGet(this, _options)).onLogMessage) == null ? void 0 : _c.call(_b, ["info", 120]);
|
1313
1311
|
return __privateGet(this, _VisitorDataStore_instances, currentData_get).visitorData;
|
1314
1312
|
}
|
1315
1313
|
return data.visitorData;
|
@@ -1322,17 +1320,17 @@ var VisitorDataStore = class {
|
|
1322
1320
|
}
|
1323
1321
|
/** Push data update command(s) into the visitor data */
|
1324
1322
|
async updateData(commands) {
|
1325
|
-
var _a, _b, _c
|
1323
|
+
var _a, _b, _c;
|
1326
1324
|
if (commands.length === 0) {
|
1327
1325
|
return;
|
1328
1326
|
}
|
1329
1327
|
(_b = (_a = __privateGet(this, _options)).onLogMessage) == null ? void 0 : _b.call(_a, ["debug", 101, commands]);
|
1330
|
-
const newData = applyCommandsToData(commands, this.data
|
1328
|
+
const newData = applyCommandsToData(commands, this.data);
|
1331
1329
|
if (commands.some((c) => c.type === "consent" && !c.data)) {
|
1332
1330
|
__privateGet(this, _persist).delete(STORAGE_KEY, true);
|
1333
1331
|
}
|
1334
1332
|
__privateMethod(this, _VisitorDataStore_instances, replaceData_fn).call(this, newData);
|
1335
|
-
await ((
|
1333
|
+
await ((_c = __privateGet(this, _options).transitionStore) == null ? void 0 : _c.updateData(commands, __privateGet(this, _VisitorDataStore_instances, currentData_get).visitorData));
|
1336
1334
|
__privateGet(this, _mitt2).emit("commandsExecuted", commands);
|
1337
1335
|
}
|
1338
1336
|
/**
|
@@ -1369,20 +1367,15 @@ replaceData_fn = function(data, quiet = false) {
|
|
1369
1367
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
1370
1368
|
const oldData = __privateGet(this, _VisitorDataStore_instances, currentData_get);
|
1371
1369
|
const now = Date.now();
|
1372
|
-
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1376
|
-
|
1377
|
-
|
1378
|
-
|
1379
|
-
|
1380
|
-
|
1381
|
-
scores: data.scores,
|
1382
|
-
sessionScores: data.sessionScores,
|
1383
|
-
onLogMessage: __privateGet(this, _options).onLogMessage
|
1384
|
-
});
|
1385
|
-
}
|
1370
|
+
__privateMethod(this, _VisitorDataStore_instances, handleCaps_fn).call(this, data.scores);
|
1371
|
+
__privateMethod(this, _VisitorDataStore_instances, handleCaps_fn).call(this, data.sessionScores);
|
1372
|
+
(_b = (_a = __privateGet(this, _options)).decay) == null ? void 0 : _b.call(_a, {
|
1373
|
+
now,
|
1374
|
+
lastUpd: oldData == null ? void 0 : oldData.updated,
|
1375
|
+
scores: data.scores,
|
1376
|
+
sessionScores: data.sessionScores,
|
1377
|
+
onLogMessage: __privateGet(this, _options).onLogMessage
|
1378
|
+
});
|
1386
1379
|
const haveScoresChanged = !dequal4(oldData == null ? void 0 : oldData.visitorData.scores, data.scores);
|
1387
1380
|
const haveSessionScoresChanged = !dequal4(oldData == null ? void 0 : oldData.visitorData.sessionScores, data.sessionScores);
|
1388
1381
|
const haveQuirksChanged = !dequal4(oldData == null ? void 0 : oldData.visitorData.quirks, data.quirks);
|
@@ -2235,7 +2228,6 @@ var createInsights = ({
|
|
2235
2228
|
},
|
2236
2229
|
pageHit: () => {
|
2237
2230
|
if (!storageData) {
|
2238
|
-
console.error("Insights not initialized");
|
2239
2231
|
return;
|
2240
2232
|
}
|
2241
2233
|
if (previousUrl === window.location.href) {
|
@@ -2263,7 +2255,6 @@ var createInsights = ({
|
|
2263
2255
|
},
|
2264
2256
|
personalizationResult: (result) => {
|
2265
2257
|
if (!storageData) {
|
2266
|
-
console.error("Insights not initialized");
|
2267
2258
|
return;
|
2268
2259
|
}
|
2269
2260
|
client.personalizationResult({
|
@@ -2275,7 +2266,6 @@ var createInsights = ({
|
|
2275
2266
|
},
|
2276
2267
|
goalConvert: (goalId) => {
|
2277
2268
|
if (!storageData) {
|
2278
|
-
console.error("Insights not initialized");
|
2279
2269
|
return;
|
2280
2270
|
}
|
2281
2271
|
client.goalConvert({
|
@@ -2287,7 +2277,6 @@ var createInsights = ({
|
|
2287
2277
|
},
|
2288
2278
|
scoresChange: (scores) => {
|
2289
2279
|
if (!storageData) {
|
2290
|
-
console.error("Insights not initialized");
|
2291
2280
|
return;
|
2292
2281
|
}
|
2293
2282
|
client.scoresChange({
|
@@ -2555,9 +2544,12 @@ export {
|
|
2555
2544
|
EdgeNodeTagName,
|
2556
2545
|
EdgeTransitionDataStore,
|
2557
2546
|
GroupCriteriaEvaluator,
|
2547
|
+
KV_SEP,
|
2558
2548
|
ManifestInstance,
|
2549
|
+
PAIR_SEP,
|
2559
2550
|
SERVER_STATE_ID,
|
2560
2551
|
ScriptType,
|
2552
|
+
TYPE_SEP,
|
2561
2553
|
TransitionDataStore,
|
2562
2554
|
UNIFORM_DEFAULT_COOKIE_NAME,
|
2563
2555
|
VisitorDataStore,
|
@@ -2568,11 +2560,14 @@ export {
|
|
2568
2560
|
createDebugConsoleLogDrain,
|
2569
2561
|
createLinearDecay,
|
2570
2562
|
currentPageEvaluator,
|
2563
|
+
decodeCookieType,
|
2564
|
+
decodePersonalizeVariants,
|
2571
2565
|
emptyVisitorData,
|
2572
2566
|
enableConsoleLogDrain,
|
2573
2567
|
enableContextDevTools,
|
2574
2568
|
enableDebugConsoleLogDrain,
|
2575
2569
|
enableUniformInsights,
|
2570
|
+
encodeCookieType,
|
2576
2571
|
evaluateVariantMatch,
|
2577
2572
|
eventEvaluator,
|
2578
2573
|
explainStringMatch,
|
@@ -2581,10 +2576,16 @@ export {
|
|
2581
2576
|
isStringMatch,
|
2582
2577
|
pageViewCountDimension,
|
2583
2578
|
pageViewCountEvaluator,
|
2579
|
+
parseCookieScores,
|
2580
|
+
parseCookieType,
|
2584
2581
|
parseQuickConnect,
|
2582
|
+
parseScoreCookie,
|
2585
2583
|
personalizeVariations,
|
2586
2584
|
queryStringEvaluator,
|
2587
2585
|
quirkEvaluator,
|
2586
|
+
serializeCookie,
|
2587
|
+
serializeCookieType,
|
2588
|
+
serializePersonalizeVariants,
|
2588
2589
|
serializeQuickConnect,
|
2589
2590
|
testVariations
|
2590
2591
|
};
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import * as mitt from 'mitt';
|
2
|
+
import { Emitter } from 'mitt';
|
2
3
|
|
3
4
|
type Quirks = {
|
4
5
|
[key: string]: string;
|
@@ -200,7 +201,7 @@ declare abstract class TransitionDataStore {
|
|
200
201
|
(type: "*", handler: mitt.WildcardHandler<TransitionDataStoreEvents>): void;
|
201
202
|
};
|
202
203
|
off: {
|
203
|
-
<
|
204
|
+
<Key extends "dataUpdatedAsync">(type: Key, handler?: mitt.Handler<TransitionDataStoreEvents[Key]> | undefined): void;
|
204
205
|
(type: "*", handler: mitt.WildcardHandler<TransitionDataStoreEvents>): void;
|
205
206
|
};
|
206
207
|
};
|
@@ -338,7 +339,7 @@ declare class VisitorDataStore {
|
|
338
339
|
(type: "*", handler: mitt.WildcardHandler<VisitorDataStoreEvents>): void;
|
339
340
|
};
|
340
341
|
off: {
|
341
|
-
<
|
342
|
+
<Key extends keyof VisitorDataStoreEvents>(type: Key, handler?: mitt.Handler<VisitorDataStoreEvents[Key]> | undefined): void;
|
342
343
|
(type: "*", handler: mitt.WildcardHandler<VisitorDataStoreEvents>): void;
|
343
344
|
};
|
344
345
|
};
|
@@ -993,7 +994,7 @@ type TestOptions<TVariant extends TestVariant> = {
|
|
993
994
|
};
|
994
995
|
declare const testVariations: <TVariant extends TestVariant>({ name, context, variations, onLogMessage, }: TestOptions<TVariant> & {
|
995
996
|
context: Context;
|
996
|
-
onLogMessage?: (
|
997
|
+
onLogMessage?: (message: LogMessage) => void;
|
997
998
|
}) => TestResult<TVariant>;
|
998
999
|
|
999
1000
|
declare const CONTEXTUAL_EDITING_TEST_NAME = "contextual_editing_test";
|
@@ -1087,6 +1088,10 @@ interface ContextInstance {
|
|
1087
1088
|
forget(fromAllDevices: boolean): Promise<void>;
|
1088
1089
|
getServerToClientTransitionState(): ServerToClientTransitionState;
|
1089
1090
|
readonly manifest: ManifestInstance;
|
1091
|
+
events: {
|
1092
|
+
on: Emitter<ContextEvents>['on'];
|
1093
|
+
off: Emitter<ContextEvents>['off'];
|
1094
|
+
};
|
1090
1095
|
/** @deprecated */
|
1091
1096
|
internal_processTestEvent(event: TestEvent): void;
|
1092
1097
|
/** @deprecated */
|
@@ -1109,7 +1114,7 @@ declare class Context implements ContextInstance {
|
|
1109
1114
|
(type: "*", handler: mitt.WildcardHandler<ContextEvents>): void;
|
1110
1115
|
};
|
1111
1116
|
off: {
|
1112
|
-
<
|
1117
|
+
<Key extends keyof ContextEvents>(type: Key, handler?: mitt.Handler<ContextEvents[Key]> | undefined): void;
|
1113
1118
|
(type: "*", handler: mitt.WildcardHandler<ContextEvents>): void;
|
1114
1119
|
};
|
1115
1120
|
};
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import * as mitt from 'mitt';
|
2
|
+
import { Emitter } from 'mitt';
|
2
3
|
|
3
4
|
type Quirks = {
|
4
5
|
[key: string]: string;
|
@@ -200,7 +201,7 @@ declare abstract class TransitionDataStore {
|
|
200
201
|
(type: "*", handler: mitt.WildcardHandler<TransitionDataStoreEvents>): void;
|
201
202
|
};
|
202
203
|
off: {
|
203
|
-
<
|
204
|
+
<Key extends "dataUpdatedAsync">(type: Key, handler?: mitt.Handler<TransitionDataStoreEvents[Key]> | undefined): void;
|
204
205
|
(type: "*", handler: mitt.WildcardHandler<TransitionDataStoreEvents>): void;
|
205
206
|
};
|
206
207
|
};
|
@@ -338,7 +339,7 @@ declare class VisitorDataStore {
|
|
338
339
|
(type: "*", handler: mitt.WildcardHandler<VisitorDataStoreEvents>): void;
|
339
340
|
};
|
340
341
|
off: {
|
341
|
-
<
|
342
|
+
<Key extends keyof VisitorDataStoreEvents>(type: Key, handler?: mitt.Handler<VisitorDataStoreEvents[Key]> | undefined): void;
|
342
343
|
(type: "*", handler: mitt.WildcardHandler<VisitorDataStoreEvents>): void;
|
343
344
|
};
|
344
345
|
};
|
@@ -993,7 +994,7 @@ type TestOptions<TVariant extends TestVariant> = {
|
|
993
994
|
};
|
994
995
|
declare const testVariations: <TVariant extends TestVariant>({ name, context, variations, onLogMessage, }: TestOptions<TVariant> & {
|
995
996
|
context: Context;
|
996
|
-
onLogMessage?: (
|
997
|
+
onLogMessage?: (message: LogMessage) => void;
|
997
998
|
}) => TestResult<TVariant>;
|
998
999
|
|
999
1000
|
declare const CONTEXTUAL_EDITING_TEST_NAME = "contextual_editing_test";
|
@@ -1087,6 +1088,10 @@ interface ContextInstance {
|
|
1087
1088
|
forget(fromAllDevices: boolean): Promise<void>;
|
1088
1089
|
getServerToClientTransitionState(): ServerToClientTransitionState;
|
1089
1090
|
readonly manifest: ManifestInstance;
|
1091
|
+
events: {
|
1092
|
+
on: Emitter<ContextEvents>['on'];
|
1093
|
+
off: Emitter<ContextEvents>['off'];
|
1094
|
+
};
|
1090
1095
|
/** @deprecated */
|
1091
1096
|
internal_processTestEvent(event: TestEvent): void;
|
1092
1097
|
/** @deprecated */
|
@@ -1109,7 +1114,7 @@ declare class Context implements ContextInstance {
|
|
1109
1114
|
(type: "*", handler: mitt.WildcardHandler<ContextEvents>): void;
|
1110
1115
|
};
|
1111
1116
|
off: {
|
1112
|
-
<
|
1117
|
+
<Key extends keyof ContextEvents>(type: Key, handler?: mitt.Handler<ContextEvents[Key]> | undefined): void;
|
1113
1118
|
(type: "*", handler: mitt.WildcardHandler<ContextEvents>): void;
|
1114
1119
|
};
|
1115
1120
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@uniformdev/context",
|
3
|
-
"version": "19.173.
|
3
|
+
"version": "19.173.2-alpha.258+e8775b83de",
|
4
4
|
"description": "Uniform Context core package",
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
6
6
|
"main": "./dist/index.js",
|
@@ -57,7 +57,7 @@
|
|
57
57
|
"dependencies": {
|
58
58
|
"dequal": "^2.0.2",
|
59
59
|
"js-cookie": "3.0.5",
|
60
|
-
"mitt": "^3.0.
|
60
|
+
"mitt": "^3.0.1",
|
61
61
|
"p-limit": "^3.1.0",
|
62
62
|
"rfdc": "^1.3.0",
|
63
63
|
"uuid": "9.0.1"
|
@@ -68,5 +68,5 @@
|
|
68
68
|
"publishConfig": {
|
69
69
|
"access": "public"
|
70
70
|
},
|
71
|
-
"gitHead": "
|
71
|
+
"gitHead": "e8775b83dec606ce6e2198182152d8b386e15f94"
|
72
72
|
}
|