@uniformdev/context 20.6.2-alpha.11 → 20.7.1-alpha.102
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/LICENSE.txt +1 -1
- package/dist/api/api.d.mts +10 -1
- package/dist/api/api.d.ts +10 -1
- package/dist/api/api.js +8 -2
- package/dist/api/api.mjs +8 -2
- package/dist/index.d.mts +8 -3
- package/dist/index.d.ts +8 -3
- package/dist/index.esm.js +122 -55
- package/dist/index.js +123 -55
- package/dist/index.mjs +122 -55
- package/dist/{types-CzIkFCDD.d.mts → types-HcKr1VVF.d.mts} +66 -3
- package/dist/{types-CzIkFCDD.d.ts → types-HcKr1VVF.d.ts} +66 -3
- package/package.json +11 -7
|
@@ -76,6 +76,17 @@ type VisitorData = {
|
|
|
76
76
|
personalizeVariants?: PersonalizeVariants;
|
|
77
77
|
};
|
|
78
78
|
declare const emptyVisitorData: () => VisitorData;
|
|
79
|
+
/**
|
|
80
|
+
* Canvas-specific data that should be managed separately from regular context updates
|
|
81
|
+
*/
|
|
82
|
+
type CompositionMetadata = {
|
|
83
|
+
/** The composition ID always required, otherwise whole metadata should not be set */
|
|
84
|
+
compositionId: string;
|
|
85
|
+
/** The matched route from router endpoint. Same as matched project map node pathname */
|
|
86
|
+
matchedRoute?: string;
|
|
87
|
+
/** Dynamic inputs for the route */
|
|
88
|
+
dynamicInputs?: Record<string, string>;
|
|
89
|
+
};
|
|
79
90
|
/**
|
|
80
91
|
* Expresses a 'patch' to the Uniform Context state
|
|
81
92
|
*/
|
|
@@ -85,6 +96,11 @@ type ContextState = {
|
|
|
85
96
|
quirks: Quirks;
|
|
86
97
|
enrichments: EnrichmentData[];
|
|
87
98
|
events: EventData[];
|
|
99
|
+
/**
|
|
100
|
+
* Metadata about the composition that is being rendered right now.
|
|
101
|
+
* if you have multiple compositions on the page, please set this one manually.
|
|
102
|
+
*/
|
|
103
|
+
compositionMetadata?: CompositionMetadata;
|
|
88
104
|
};
|
|
89
105
|
type ContextStateUpdate = {
|
|
90
106
|
/** The new effective state of the visitor after this state update is applied */
|
|
@@ -179,6 +195,10 @@ type ServerToClientTransitionState = Pick<Partial<VisitorData>, 'quirks' | 'test
|
|
|
179
195
|
* Storage commands that the server
|
|
180
196
|
*/
|
|
181
197
|
commands?: StorageCommands[];
|
|
198
|
+
/**
|
|
199
|
+
* Composition metadata from the server side
|
|
200
|
+
*/
|
|
201
|
+
compositionMetadata?: CompositionMetadata;
|
|
182
202
|
};
|
|
183
203
|
declare const SERVER_STATE_ID = "__UNIFORM_DATA__";
|
|
184
204
|
type TransitionDataStoreEvents = {
|
|
@@ -374,6 +394,7 @@ declare class ManifestInstance {
|
|
|
374
394
|
*/
|
|
375
395
|
computeAggregateDimensions(primitiveScores: ScoreVector): ScoreVector;
|
|
376
396
|
getDimensionByKey(scoreKey: string): EnrichmentCategory | Signal | undefined;
|
|
397
|
+
getAggregateDimensionByKey(scoreKey: string): AggregateDimension | undefined;
|
|
377
398
|
}
|
|
378
399
|
|
|
379
400
|
interface paths {
|
|
@@ -1030,6 +1051,10 @@ type TestVariant = {
|
|
|
1030
1051
|
* If not provided, this variant will be selected in equal proportion to other variants without an explicit distribution.
|
|
1031
1052
|
*/
|
|
1032
1053
|
testDistribution?: number;
|
|
1054
|
+
/** Whether this variant is a control variant.
|
|
1055
|
+
* Can be undefined for backward compatibility with older versions of the SDK which were not explicitly setting the control flag.
|
|
1056
|
+
*/
|
|
1057
|
+
control?: boolean;
|
|
1033
1058
|
};
|
|
1034
1059
|
/** The result of computing an A/B test result */
|
|
1035
1060
|
type TestResult<TVariant> = {
|
|
@@ -1051,6 +1076,8 @@ interface PersonalizeOptions<TVariant> {
|
|
|
1051
1076
|
take?: number;
|
|
1052
1077
|
/** Name of the personalization selection algorithm to use. Defaults to top-down criteria when not specified. */
|
|
1053
1078
|
algorithm?: string;
|
|
1079
|
+
/** Composition metadata where the personalization is being rendered for analytics tracking */
|
|
1080
|
+
compositionMetadata?: CompositionMetadata;
|
|
1054
1081
|
}
|
|
1055
1082
|
interface PersonalizationSelectionAlgorithmOptions<TCriteria, TVariant extends PersonalizedVariant<TCriteria> = PersonalizedVariant<TCriteria>> {
|
|
1056
1083
|
/** Name of placement (sent to analytics) */
|
|
@@ -1070,6 +1097,8 @@ type TestOptions<TVariant extends TestVariant> = {
|
|
|
1070
1097
|
name: string;
|
|
1071
1098
|
/** Variations that are being tested. */
|
|
1072
1099
|
variations: TVariant[];
|
|
1100
|
+
/** Composition metadata where the personalization is being rendered for analytics tracking */
|
|
1101
|
+
compositionMetadata?: CompositionMetadata;
|
|
1073
1102
|
};
|
|
1074
1103
|
declare const testVariations: <TVariant extends TestVariant>({ name, context, variations, onLogMessage, }: TestOptions<TVariant> & {
|
|
1075
1104
|
context: Context;
|
|
@@ -1092,8 +1121,8 @@ type ContextPlugin = {
|
|
|
1092
1121
|
init?: (context: Context) => () => void;
|
|
1093
1122
|
/** Plugin-specific actions to perform when a user is forgotten */
|
|
1094
1123
|
forget?: () => Promise<void> | void;
|
|
1095
|
-
/** Plugin-specific actions to perform when the visitor context is updated */
|
|
1096
|
-
update?: (newData: Partial<ContextState
|
|
1124
|
+
/** Plugin-specific actions to perform when the visitor context is updated, second parameter is the recalculated scores after the update */
|
|
1125
|
+
update?: (newData: Partial<ContextState>, recalculatedScores: ScoreVector) => Promise<void> | void;
|
|
1097
1126
|
/**
|
|
1098
1127
|
* Allows the plugin to register named personalization selection algorithms
|
|
1099
1128
|
*
|
|
@@ -1140,6 +1169,12 @@ type PersonalizationEvent = {
|
|
|
1140
1169
|
* False: the variant(s) selected were the same as a previous evaluation of this placement.
|
|
1141
1170
|
*/
|
|
1142
1171
|
changed: boolean;
|
|
1172
|
+
/**
|
|
1173
|
+
* Contains information about the composition that contains personalization wrapper component,
|
|
1174
|
+
* which triggered the personalization event.
|
|
1175
|
+
* Only references top level root composition after pattern resolutions.
|
|
1176
|
+
*/
|
|
1177
|
+
compositionMetadata?: CompositionMetadata;
|
|
1143
1178
|
};
|
|
1144
1179
|
/** Emitted event when an A/B test runs */
|
|
1145
1180
|
type TestEvent = {
|
|
@@ -1147,12 +1182,22 @@ type TestEvent = {
|
|
|
1147
1182
|
name: string;
|
|
1148
1183
|
/** ID of the variant that was selected */
|
|
1149
1184
|
variantId: string | undefined;
|
|
1185
|
+
/**
|
|
1186
|
+
* Whether the variant is part of the control group.
|
|
1187
|
+
*/
|
|
1188
|
+
control: boolean;
|
|
1150
1189
|
/**
|
|
1151
1190
|
* Whether the test variant was newly assigned to the visitor.
|
|
1152
1191
|
* True: variant was assigned to the visitor for the first time.
|
|
1153
1192
|
* False: variant was already assigned to the visitor and is being reused.
|
|
1154
1193
|
*/
|
|
1155
1194
|
variantAssigned: boolean;
|
|
1195
|
+
/**
|
|
1196
|
+
* Contains information about the composition that contains A/B test wrapper component,
|
|
1197
|
+
* which triggered the A/B test event.
|
|
1198
|
+
* Only references top level root composition after pattern resolutions.
|
|
1199
|
+
*/
|
|
1200
|
+
compositionMetadata?: CompositionMetadata;
|
|
1156
1201
|
};
|
|
1157
1202
|
type ContextEvents = {
|
|
1158
1203
|
/**
|
|
@@ -1176,6 +1221,8 @@ type ContextEvents = {
|
|
|
1176
1221
|
testResult: TestEvent;
|
|
1177
1222
|
/** Personalization variants have been selected */
|
|
1178
1223
|
personalizationResult: PersonalizationEvent;
|
|
1224
|
+
/** Composition metadata has been set/updated, usually happens when new composition is being rendered during client-side navigation for example */
|
|
1225
|
+
canvasDataUpdated: CompositionMetadata;
|
|
1179
1226
|
};
|
|
1180
1227
|
interface ContextInstance {
|
|
1181
1228
|
get scores(): Readonly<ScoreVector>;
|
|
@@ -1197,6 +1244,14 @@ interface ContextInstance {
|
|
|
1197
1244
|
internal_processTestEvent(event: TestEvent): void;
|
|
1198
1245
|
/** @deprecated */
|
|
1199
1246
|
internal_processPersonalizationEvent(event: PersonalizationEvent): void;
|
|
1247
|
+
/**
|
|
1248
|
+
* Gets the current canvas data
|
|
1249
|
+
*/
|
|
1250
|
+
getCompositionMetadata(): Readonly<CompositionMetadata | undefined>;
|
|
1251
|
+
/**
|
|
1252
|
+
* Updates the canvas data and emits a canvasDataUpdated event
|
|
1253
|
+
*/
|
|
1254
|
+
updateCompositionMetadata(newData: CompositionMetadata): Promise<void>;
|
|
1200
1255
|
}
|
|
1201
1256
|
declare class Context implements ContextInstance {
|
|
1202
1257
|
#private;
|
|
@@ -1266,6 +1321,14 @@ declare class Context implements ContextInstance {
|
|
|
1266
1321
|
internal_processTestEvent(event: TestEvent): void;
|
|
1267
1322
|
/** @deprecated */
|
|
1268
1323
|
internal_processPersonalizationEvent(event: PersonalizationEvent): void;
|
|
1324
|
+
/**
|
|
1325
|
+
* Gets the current canvas data
|
|
1326
|
+
*/
|
|
1327
|
+
getCompositionMetadata(): Readonly<CompositionMetadata | undefined>;
|
|
1328
|
+
/**
|
|
1329
|
+
* Updates the canvas data and emits a canvasDataUpdated event
|
|
1330
|
+
*/
|
|
1331
|
+
updateCompositionMetadata(newData: CompositionMetadata): Promise<void>;
|
|
1269
1332
|
}
|
|
1270
1333
|
|
|
1271
1334
|
/**
|
|
@@ -1337,4 +1400,4 @@ declare global {
|
|
|
1337
1400
|
}
|
|
1338
1401
|
}
|
|
1339
1402
|
|
|
1340
|
-
export { type ManifestV2 as $, type AggregateDimension as A, type DevToolsLogEvent as B, type ContextPlugin as C, type DecayFunction as D, type DevToolsDataEvent as E, type DevToolsHelloEvent as F, type DevToolsUpdateEvent as G, type DevToolsRawCommandsEvent as H, type DevToolsForgetEvent as I, type LogMessages as J, type Severity as K, type LogDrain as L, type MessageCategory as M, type MessageFunc as N, type OutputSeverity as O, type PersonalizedVariant as P, type Quirks as Q, type LogMessageSingle as R, type ScoreVector as S, TransitionDataStore as T, type LogMessageGroup as U, type VisitorData as V, ManifestInstance as W, GroupCriteriaEvaluator as X, type CriteriaEvaluatorResult as Y, type CriteriaEvaluatorParameters as Z, type SignalData as _, type StorageCommands as a, type PersonalizationManifest as a0, type Signal as a1, type SignalCriteriaGroup as a2, type SignalCriteria as a3, type EnrichmentCategory as a4, type NumberMatch as a5, type TestDefinition as a6, type AggregateDimensionInput as a7, type TestOptions as a8, testVariations as a9, type EnrichmentData as aA, type PersonalizeControlVariant as aB, type PersonalizeVariants as aC, type EventData as aD, emptyVisitorData as aE, type
|
|
1403
|
+
export { type ManifestV2 as $, type AggregateDimension as A, type DevToolsLogEvent as B, type ContextPlugin as C, type DecayFunction as D, type DevToolsDataEvent as E, type DevToolsHelloEvent as F, type DevToolsUpdateEvent as G, type DevToolsRawCommandsEvent as H, type DevToolsForgetEvent as I, type LogMessages as J, type Severity as K, type LogDrain as L, type MessageCategory as M, type MessageFunc as N, type OutputSeverity as O, type PersonalizedVariant as P, type Quirks as Q, type LogMessageSingle as R, type ScoreVector as S, TransitionDataStore as T, type LogMessageGroup as U, type VisitorData as V, ManifestInstance as W, GroupCriteriaEvaluator as X, type CriteriaEvaluatorResult as Y, type CriteriaEvaluatorParameters as Z, type SignalData as _, type StorageCommands as a, type PersonalizationManifest as a0, type Signal as a1, type SignalCriteriaGroup as a2, type SignalCriteria as a3, type EnrichmentCategory as a4, type NumberMatch as a5, type TestDefinition as a6, type AggregateDimensionInput as a7, type TestOptions as a8, testVariations as a9, type EnrichmentData as aA, type PersonalizeControlVariant as aB, type PersonalizeVariants as aC, type EventData as aD, emptyVisitorData as aE, type CompositionMetadata as aF, type ContextState as aG, type ContextStateUpdate as aH, type GoalStateUpdate as aI, type paths as aJ, type VariationMatchMetadata as aa, type DimensionMatch as ab, type QuirkMatch as ac, type BehaviorTag as ad, type TestVariant as ae, type TestResult as af, type StorageCommand as ag, type SetGoalCommand as ah, type ModifyScoreCommand as ai, type ModifySessionScoreCommand as aj, type SetConsentCommand as ak, type SetQuirkCommand as al, type SetTestCommand as am, type IdentifyCommand as an, type SetControlGroupCommand as ao, type SetPersonalizeVariantControlCommand as ap, areCommandsEqual as aq, type ServerToClientTransitionState as ar, SERVER_STATE_ID as as, type TransitionDataStoreEvents as at, type DecayOptions as au, type VisitorDataStoreOptions as av, type VisitorDataStoreEvents as aw, VisitorDataStore as ax, type Tests as ay, type Goals as az, type TransitionDataStoreOptions as b, type CriteriaEvaluator as c, type StringMatch as d, type VariantMatchCriteria as e, type LogMessage as f, type PersonalizeOptions as g, Context as h, type PersonalizedResult as i, type VariationMatchDimensionCriteria as j, type PersonalizationSelectionAlgorithmOptions as k, type DevToolsEvents as l, CONTEXTUAL_EDITING_TEST_NAME as m, CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID as n, type PersonalizationSelectionAlgorithm as o, type PersonalizationSelectionAlgorithms as p, type ContextOptions as q, type PersonalizationEventVariantId as r, type PersonalizationEvent as s, type TestEvent as t, type ContextEvents as u, type ContextInstance as v, type DevToolsUiVersion as w, type DevToolsState as x, type DevToolsActions as y, type DevToolsEvent 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.102+d621aa22b2",
|
|
4
4
|
"description": "Uniform Context core package",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -41,26 +41,30 @@
|
|
|
41
41
|
"dev": "run-s update-openapi dev:ts",
|
|
42
42
|
"dev:ts": "tsup --watch",
|
|
43
43
|
"clean": "rimraf dist",
|
|
44
|
-
"test": "
|
|
44
|
+
"test": "vitest run",
|
|
45
|
+
"test:coverage": "vitest run --coverage",
|
|
45
46
|
"lint": "eslint \"src/**/*.{js,ts,tsx}\"",
|
|
46
47
|
"format": "prettier --write \"src/**/*.{js,ts,tsx}\"",
|
|
47
48
|
"update-openapi": "tsx ./scripts/update-openapi.cts",
|
|
48
49
|
"benchmark:build": "tsup src/storage/__benchmarks__/storage.benchmark.ts",
|
|
49
50
|
"benchmark:run": "node ./dist/storage.benchmark.js",
|
|
50
|
-
"document": "api-extractor run --local"
|
|
51
|
+
"document:prebuild": "api-extractor run --local"
|
|
51
52
|
},
|
|
52
53
|
"devDependencies": {
|
|
53
54
|
"@types/js-cookie": "3.0.6",
|
|
54
55
|
"@types/uuid": "9.0.4",
|
|
55
|
-
"
|
|
56
|
+
"@vitest/coverage-v8": "3.2.4",
|
|
57
|
+
"benny": "3.7.1",
|
|
58
|
+
"vite": "7.1.5",
|
|
59
|
+
"vite-tsconfig-paths": "^5.1.4",
|
|
60
|
+
"vitest": "3.2.4"
|
|
56
61
|
},
|
|
57
62
|
"dependencies": {
|
|
58
63
|
"dequal": "^2.0.2",
|
|
59
64
|
"js-cookie": "3.0.5",
|
|
60
65
|
"mitt": "^3.0.1",
|
|
61
66
|
"p-limit": "^3.1.0",
|
|
62
|
-
"rfdc": "^1.4.1"
|
|
63
|
-
"uuid": "9.0.1"
|
|
67
|
+
"rfdc": "^1.4.1"
|
|
64
68
|
},
|
|
65
69
|
"files": [
|
|
66
70
|
"/dist"
|
|
@@ -68,5 +72,5 @@
|
|
|
68
72
|
"publishConfig": {
|
|
69
73
|
"access": "public"
|
|
70
74
|
},
|
|
71
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "d621aa22b220347565e307b064fb1eda8963abbe"
|
|
72
76
|
}
|