@uniformdev/context 20.6.2-alpha.11 → 20.7.1-alpha.14
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 +8 -1
- package/dist/api/api.d.ts +8 -1
- package/dist/api/api.js +8 -2
- package/dist/api/api.mjs +8 -2
- package/dist/index.d.mts +4 -33
- package/dist/index.d.ts +4 -33
- package/dist/index.esm.js +39 -216
- package/dist/index.js +40 -221
- package/dist/index.mjs +39 -216
- package/dist/{types-CzIkFCDD.d.mts → types-EJl31yuP.d.mts} +24 -96
- package/dist/{types-CzIkFCDD.d.ts → types-EJl31yuP.d.ts} +24 -96
- package/package.json +2 -2
@@ -859,10 +859,6 @@ type LogMessages = {
|
|
859
859
|
}>;
|
860
860
|
/** Final result for a personalized variation */
|
861
861
|
303: MessageFunc<boolean>;
|
862
|
-
/** Personalization algorithm not found */
|
863
|
-
304: MessageFunc<{
|
864
|
-
algorithm: string;
|
865
|
-
}>;
|
866
862
|
/** A/B test placement executing */
|
867
863
|
400: MessageFunc<string>;
|
868
864
|
/** A/B Test definition did not exist */
|
@@ -902,34 +898,23 @@ type LogMessageSingle<TID extends keyof LogMessages = keyof LogMessages> = [
|
|
902
898
|
type LogMessageGroup<TID extends keyof LogMessages = keyof LogMessages> = [severity: Severity, id: TID, group: 'GROUP', ...args: Parameters<LogMessages[TID]>] | [severity: Severity, id: TID, group: 'ENDGROUP'];
|
903
899
|
type LogDrain = (message: LogMessage) => void;
|
904
900
|
|
905
|
-
|
906
|
-
interface VariantMatchCriteria extends VariationMatchMetadata {
|
901
|
+
type VariantMatchCriteria = {
|
907
902
|
/**
|
908
903
|
* Operation for match criteria
|
909
904
|
*
|
910
905
|
* @defaultValue `&`
|
911
906
|
*/
|
912
907
|
op?: '&' | '|';
|
913
|
-
crit:
|
908
|
+
crit: DimensionMatch[];
|
914
909
|
/**
|
915
|
-
*
|
910
|
+
* Name of the variant for analytics tracking.
|
916
911
|
*/
|
917
|
-
|
918
|
-
}
|
919
|
-
/** Data for a personalization variation using the TODO selection algorithm */
|
920
|
-
interface VariationMatchDimensionCriteria extends VariationMatchMetadata {
|
921
|
-
/** The dimension this content is relevant to */
|
922
|
-
dim: string | undefined;
|
923
|
-
}
|
924
|
-
/** Data that must exist on a personalization variation regardless of selection algorithm */
|
925
|
-
interface VariationMatchMetadata {
|
912
|
+
name?: string;
|
926
913
|
/**
|
927
|
-
*
|
928
|
-
* NOTE: name is optional for backwards compatibility, but it is HIGHLY recommended to specify a name
|
929
|
-
* as the default fallback is not helpfully named and is reliant on the order of the variations array.
|
914
|
+
* Control group percentage for the variant.
|
930
915
|
*/
|
931
|
-
|
932
|
-
}
|
916
|
+
control?: number;
|
917
|
+
};
|
933
918
|
type DimensionMatch = {
|
934
919
|
/**
|
935
920
|
* Left hand side of the match expression (name of dimension in score vector)
|
@@ -968,48 +953,17 @@ type DimensionMatch = {
|
|
968
953
|
*/
|
969
954
|
rDim?: string;
|
970
955
|
};
|
971
|
-
type QuirkMatch = {
|
972
|
-
/**
|
973
|
-
* Type of match expression; 'q' discriminates quirk matches from dimension matches
|
974
|
-
*/
|
975
|
-
t: 'q';
|
976
|
-
/**
|
977
|
-
* Left hand side of the match expression (name of quirk)
|
978
|
-
* NOTE: if the quirk is not present
|
979
|
-
*/
|
980
|
-
l: string;
|
981
|
-
/**
|
982
|
-
* Operator of the match expression
|
983
|
-
* Comparison operators:
|
984
|
-
* =: `l` is equal to the right hand side expression
|
985
|
-
* !=: `l` is not equal to the right hand side expression
|
986
|
-
*/
|
987
|
-
op: '=' | '!=';
|
988
|
-
/**
|
989
|
-
* Right hand side of the match expression
|
990
|
-
* This value is treated as a constant value, if it is present. If it's a string, it is parsed to an integer.
|
991
|
-
* To reference another score dimension as the RHS, use the `rDim` property instead.
|
992
|
-
* `r` and `rDim` are mutually exclusive; if both are specified, then `rDim` wins.
|
993
|
-
*/
|
994
|
-
r: string;
|
995
|
-
/**
|
996
|
-
* Only here to maintain object compatibility with DimensionMatch.
|
997
|
-
* Completely ignored.
|
998
|
-
* @deprecated this is not used with QuirkMatch.
|
999
|
-
*/
|
1000
|
-
rDim?: string;
|
1001
|
-
};
|
1002
956
|
|
1003
957
|
/** Content that is tagged for adding enrichment score when triggered by behavior (i.e. being shown that content) */
|
1004
958
|
type BehaviorTag = {
|
1005
959
|
beh?: EnrichmentData[];
|
1006
960
|
};
|
1007
961
|
/** Defines the shape of a personalized content variant */
|
1008
|
-
type PersonalizedVariant
|
962
|
+
type PersonalizedVariant = {
|
1009
963
|
/** A unique identifier for this variation */
|
1010
964
|
id: string;
|
1011
965
|
/** Match criteria for this variation */
|
1012
|
-
pz?:
|
966
|
+
pz?: VariantMatchCriteria;
|
1013
967
|
};
|
1014
968
|
/** The result of computing personalized content from variations */
|
1015
969
|
type PersonalizedResult<TVariant> = {
|
@@ -1017,7 +971,6 @@ type PersonalizedResult<TVariant> = {
|
|
1017
971
|
personalized: boolean;
|
1018
972
|
/** Matching variations */
|
1019
973
|
variations: Array<TVariant & {
|
1020
|
-
/** Whether the visitor is part of this variation's local control group (also true if part of global control group) */
|
1021
974
|
control: boolean;
|
1022
975
|
}>;
|
1023
976
|
};
|
@@ -1042,28 +995,19 @@ type TestResult<TVariant> = {
|
|
1042
995
|
*/
|
1043
996
|
variantAssigned: boolean;
|
1044
997
|
};
|
1045
|
-
|
1046
|
-
|
1047
|
-
name: string;
|
1048
|
-
/** Possible variations to place */
|
1049
|
-
variations: Iterable<TVariant>;
|
1050
|
-
/** Maximum number of variants to place (default: 1) */
|
1051
|
-
take?: number;
|
1052
|
-
/** Name of the personalization selection algorithm to use. Defaults to top-down criteria when not specified. */
|
1053
|
-
algorithm?: string;
|
1054
|
-
}
|
1055
|
-
interface PersonalizationSelectionAlgorithmOptions<TCriteria, TVariant extends PersonalizedVariant<TCriteria> = PersonalizedVariant<TCriteria>> {
|
998
|
+
|
999
|
+
type PersonalizeOptions<TVariant> = {
|
1056
1000
|
/** Name of placement (sent to analytics) */
|
1057
1001
|
name: string;
|
1058
|
-
/** Possible
|
1002
|
+
/** Possible variants to place */
|
1059
1003
|
variations: Iterable<TVariant>;
|
1060
1004
|
/** Maximum number of variants to place (default: 1) */
|
1061
1005
|
take?: number;
|
1062
|
-
/** Callback for logging messages */
|
1063
1006
|
onLogMessage?: (message: LogMessage) => void;
|
1064
|
-
|
1007
|
+
};
|
1008
|
+
declare function personalizeVariations<TVariant extends PersonalizedVariant>({ name, context, variations, take, onLogMessage, }: PersonalizeOptions<TVariant> & {
|
1065
1009
|
context: Context;
|
1066
|
-
}
|
1010
|
+
}): PersonalizedResult<TVariant>;
|
1067
1011
|
|
1068
1012
|
type TestOptions<TVariant extends TestVariant> = {
|
1069
1013
|
/** The name of the test that is being run, must be included in the manifest. */
|
@@ -1078,31 +1022,18 @@ declare const testVariations: <TVariant extends TestVariant>({ name, context, va
|
|
1078
1022
|
|
1079
1023
|
declare const CONTEXTUAL_EDITING_TEST_NAME = "contextual_editing_test";
|
1080
1024
|
declare const CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID = "contextual_editing_test_selected_variant";
|
1081
|
-
type PersonalizationSelectionAlgorithm<TCriteria = unknown> = (options: PersonalizationSelectionAlgorithmOptions<TCriteria>) => PersonalizedResult<PersonalizedVariant<TCriteria>>;
|
1082
|
-
type PersonalizationSelectionAlgorithms<TCriteria = unknown> = Record<string, PersonalizationSelectionAlgorithm<TCriteria>>;
|
1083
1025
|
/**
|
1084
1026
|
* Defines a plugin for Uniform Context.
|
1085
1027
|
* The plugin should attach event handlers in its creation function.
|
1086
1028
|
* @returns A function that detaches any event handlers when called
|
1087
1029
|
*/
|
1088
1030
|
type ContextPlugin = {
|
1089
|
-
/** Defines a log drain for the plugin, which all log messages are sent to */
|
1090
1031
|
logDrain?: LogDrain;
|
1091
|
-
/** Initializes the plugin (attach event handlers here if needed) */
|
1092
1032
|
init?: (context: Context) => () => void;
|
1093
|
-
/** Plugin-specific actions to perform when a user is forgotten */
|
1094
1033
|
forget?: () => Promise<void> | void;
|
1095
|
-
/** Plugin-specific actions to perform when the visitor context is updated */
|
1096
1034
|
update?: (newData: Partial<ContextState>) => Promise<void> | void;
|
1097
|
-
/**
|
1098
|
-
* Allows the plugin to register named personalization selection algorithms
|
1099
|
-
*
|
1100
|
-
* Important: the `default` and `strongestMatch` algorithms are automatically registered.
|
1101
|
-
* We strongly advise against replacing these.
|
1102
|
-
*/
|
1103
|
-
personalizationSelectionAlgorithms?: PersonalizationSelectionAlgorithms<any>;
|
1104
1035
|
};
|
1105
|
-
|
1036
|
+
type ContextOptions = {
|
1106
1037
|
/** The Context Manifest to load (from the Context API) */
|
1107
1038
|
manifest: ManifestV2;
|
1108
1039
|
/**
|
@@ -1119,19 +1050,16 @@ interface ContextOptions extends Omit<VisitorDataStoreOptions, 'manifest' | 'onS
|
|
1119
1050
|
* `true`: personalization is not run at all unless storage consent is given
|
1120
1051
|
*/
|
1121
1052
|
requireConsentForPersonalization?: boolean;
|
1122
|
-
}
|
1123
|
-
type PersonalizationEventVariantId = {
|
1124
|
-
/** The variant ID that was selected */
|
1125
|
-
id: string;
|
1126
|
-
/** Whether the visitor is part of this variant's local control group (also true if part of global control group) */
|
1127
|
-
control: boolean;
|
1128
|
-
};
|
1053
|
+
} & Omit<VisitorDataStoreOptions, 'manifest' | 'onServerTransitionScoresReceived'>;
|
1129
1054
|
/** Emitted when a personalization runs */
|
1130
1055
|
type PersonalizationEvent = {
|
1131
1056
|
/** Name of the personalized placement */
|
1132
1057
|
name: string;
|
1133
1058
|
/** Selected variant ID(s) */
|
1134
|
-
variantIds:
|
1059
|
+
variantIds: {
|
1060
|
+
id: string;
|
1061
|
+
control: boolean;
|
1062
|
+
}[];
|
1135
1063
|
/** Whether the user was part of the control group (and did not receive any personalization) */
|
1136
1064
|
control: boolean | undefined;
|
1137
1065
|
/**
|
@@ -1185,7 +1113,7 @@ interface ContextInstance {
|
|
1185
1113
|
setTestVariantId(testName: string, variantId: string): void;
|
1186
1114
|
log(...message: LogMessage): void;
|
1187
1115
|
test<TVariant extends TestVariant>(options: TestOptions<TVariant>): TestResult<TVariant>;
|
1188
|
-
personalize<TVariant extends PersonalizedVariant
|
1116
|
+
personalize<TVariant extends PersonalizedVariant>(options: PersonalizeOptions<TVariant>): PersonalizedResult<TVariant>;
|
1189
1117
|
forget(fromAllDevices: boolean): Promise<void>;
|
1190
1118
|
getServerToClientTransitionState(): ServerToClientTransitionState;
|
1191
1119
|
readonly manifest: ManifestInstance;
|
@@ -1250,7 +1178,7 @@ declare class Context implements ContextInstance {
|
|
1250
1178
|
/** Executes an A/B test with a given set of variants, showing the visitor's assigned variant (or selecting one to assign, if none is set yet) */
|
1251
1179
|
test<TVariant extends TestVariant>(options: TestOptions<TVariant>): TestResult<TVariant>;
|
1252
1180
|
/** Executes a personalized placement with a given set of variants */
|
1253
|
-
personalize<TVariant extends PersonalizedVariant
|
1181
|
+
personalize<TVariant extends PersonalizedVariant>(options: PersonalizeOptions<TVariant>): PersonalizedResult<TVariant>;
|
1254
1182
|
/**
|
1255
1183
|
* Forgets the visitor's data and resets the Context to its initial state.
|
1256
1184
|
* @param fromAllDevices for an identified user, whether to delete all their data (for the entire account) - true, or data for this device (sign out) - false
|
@@ -1337,4 +1265,4 @@ declare global {
|
|
1337
1265
|
}
|
1338
1266
|
}
|
1339
1267
|
|
1340
|
-
export { type
|
1268
|
+
export { type AggregateDimensionInput as $, type AggregateDimension as A, type MessageFunc as B, type ContextPlugin as C, type DecayFunction as D, type LogMessageSingle as E, type LogMessageGroup as F, ManifestInstance as G, GroupCriteriaEvaluator as H, type CriteriaEvaluatorResult as I, type CriteriaEvaluatorParameters as J, type SignalData as K, type LogDrain as L, type MessageCategory as M, type ManifestV2 as N, type OutputSeverity as O, type PersonalizationEvent as P, type Quirks as Q, type PersonalizationManifest as R, type ScoreVector as S, TransitionDataStore as T, type Signal as U, type VisitorData as V, type SignalCriteriaGroup as W, type SignalCriteria as X, type EnrichmentCategory as Y, type NumberMatch as Z, type TestDefinition as _, type StorageCommands as a, type TestOptions as a0, testVariations as a1, type DimensionMatch as a2, type PersonalizeOptions as a3, personalizeVariations as a4, type BehaviorTag as a5, type PersonalizedVariant as a6, type PersonalizedResult as a7, type TestVariant as a8, type TestResult as a9, type ContextStateUpdate as aA, type GoalStateUpdate as aB, type paths as aC, type StorageCommand as aa, type SetGoalCommand as ab, type ModifyScoreCommand as ac, type ModifySessionScoreCommand as ad, type SetConsentCommand as ae, type SetQuirkCommand as af, type SetTestCommand as ag, type IdentifyCommand as ah, type SetControlGroupCommand as ai, type SetPersonalizeVariantControlCommand as aj, areCommandsEqual as ak, type ServerToClientTransitionState as al, SERVER_STATE_ID as am, type TransitionDataStoreEvents as an, type DecayOptions as ao, type VisitorDataStoreOptions as ap, type VisitorDataStoreEvents as aq, VisitorDataStore as ar, type Tests as as, type Goals as at, type EnrichmentData as au, type PersonalizeControlVariant as av, type PersonalizeVariants as aw, type EventData as ax, emptyVisitorData as ay, type ContextState as az, type TransitionDataStoreOptions as b, type CriteriaEvaluator as c, type StringMatch as d, type VariantMatchCriteria as e, type LogMessage as f, type DevToolsEvents as g, CONTEXTUAL_EDITING_TEST_NAME as h, CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID as i, type ContextOptions as j, type TestEvent as k, type ContextEvents as l, type ContextInstance as m, Context as n, type DevToolsUiVersion as o, type DevToolsState as p, type DevToolsActions as q, type DevToolsEvent as r, type DevToolsLogEvent as s, type DevToolsDataEvent as t, type DevToolsHelloEvent as u, type DevToolsUpdateEvent as v, type DevToolsRawCommandsEvent as w, type DevToolsForgetEvent as x, type LogMessages as y, type Severity as z };
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@uniformdev/context",
|
3
|
-
"version": "20.
|
3
|
+
"version": "20.7.1-alpha.14+60f5dc825c",
|
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": "60f5dc825c94de66d7593877448296c598c3c10d"
|
72
72
|
}
|