@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/dist/index.mjs CHANGED
@@ -227,6 +227,10 @@ var ManifestInstance = class {
227
227
  }
228
228
  return (_d = (_c = __privateGet(this, _mf).pz) == null ? void 0 : _c.enr) == null ? void 0 : _d[scoreKey.substring(0, enrichmentIndex)];
229
229
  }
230
+ getAggregateDimensionByKey(scoreKey) {
231
+ var _a, _b;
232
+ return (_b = (_a = __privateGet(this, _mf).pz) == null ? void 0 : _a.agg) == null ? void 0 : _b[scoreKey];
233
+ }
230
234
  };
231
235
  _mf = new WeakMap();
232
236
  _signalInstances = new WeakMap();
@@ -796,6 +800,7 @@ function strongestScorePersonalizationSelectionAlgorithm({
796
800
  const needsConsentToPersonalize = context.requireConsentForPersonalization;
797
801
  const isInGlobalControlGroup = (_a = context.storage.data.controlGroup) != null ? _a : false;
798
802
  const personalizationAllowed = !needsConsentToPersonalize || context.storage.data.consent;
803
+ let originalIndex = 0;
799
804
  for (const variation of variations) {
800
805
  const isInvalidFormat = variation.pz && typeof variation.pz !== "object";
801
806
  let validVariation;
@@ -813,12 +818,19 @@ function strongestScorePersonalizationSelectionAlgorithm({
813
818
  if (score === void 0 || score <= 0) {
814
819
  continue;
815
820
  }
816
- variationMatches.push({ variation: validVariation, score });
821
+ variationMatches.push({ variation: validVariation, score, originalIndex });
822
+ originalIndex++;
817
823
  } else {
818
824
  defaultVariations.push(validVariation);
819
825
  }
820
826
  }
821
- variationMatches.sort((a, b) => b.score - a.score);
827
+ variationMatches.sort((a, b) => {
828
+ const scoreComparison = b.score - a.score;
829
+ if (scoreComparison === 0) {
830
+ return a.originalIndex - b.originalIndex;
831
+ }
832
+ return scoreComparison;
833
+ });
822
834
  const result = [];
823
835
  for (let i = 0; i < variationMatches.length; i++) {
824
836
  const variationMatch = variationMatches[i];
@@ -917,11 +929,11 @@ var testVariations = ({
917
929
  }
918
930
  if (!selectedVariant) {
919
931
  const distributions = normalizeVariationDistributions(variations);
920
- const random = Math.floor(Math.random() * 100);
932
+ const random = Math.random() * 100;
921
933
  let distributionOffset = 0;
922
934
  selectedVariant = variations.find((variant, index) => {
923
935
  const distribution = distributions[index];
924
- if ((random > distributionOffset || random === 0) && random <= distributionOffset + distribution) {
936
+ if (random >= distributionOffset && random < distributionOffset + distribution) {
925
937
  return variant;
926
938
  }
927
939
  distributionOffset += distribution;
@@ -933,6 +945,9 @@ var testVariations = ({
933
945
  }
934
946
  if (selectedVariant) {
935
947
  onLogMessage == null ? void 0 : onLogMessage(["info", 404, selectedVariant.id]);
948
+ if (selectedVariant.control === void 0) {
949
+ selectedVariant.control = variations.findIndex((variation) => variation.id === selectedVariantId) === 0;
950
+ }
936
951
  }
937
952
  return {
938
953
  result: selectedVariant,
@@ -1114,6 +1129,7 @@ _quirksEnabled = new WeakMap();
1114
1129
  var TYPE_SEP = "~";
1115
1130
  var PAIR_SEP = "!";
1116
1131
  var KV_SEP = "-";
1132
+ var QUIRK_KV_SEP = "=";
1117
1133
  var QUIRK_SEP = "!!";
1118
1134
  function parseScoreCookie(cookieValue, quirkCookieValue) {
1119
1135
  if (!cookieValue) return;
@@ -1137,7 +1153,7 @@ function parseScoreCookie(cookieValue, quirkCookieValue) {
1137
1153
  function parseQuirkCookie(quirkCookieValue) {
1138
1154
  const pairs = quirkCookieValue.split(QUIRK_SEP);
1139
1155
  const splitPairs = pairs.map((pair) => {
1140
- const sep = pair.indexOf(KV_SEP);
1156
+ const sep = pair.indexOf(QUIRK_KV_SEP);
1141
1157
  if (sep === -1) {
1142
1158
  return void 0;
1143
1159
  }
@@ -1238,7 +1254,7 @@ function serializeCookieType(type) {
1238
1254
  return Object.entries(type).map((kv) => kv.join(KV_SEP)).join(PAIR_SEP);
1239
1255
  }
1240
1256
  function serializeQuirks(quirks) {
1241
- return Object.entries(quirks).map((kv) => kv.join(KV_SEP)).join(QUIRK_SEP);
1257
+ return Object.entries(quirks).map((kv) => kv.join(QUIRK_KV_SEP)).join(QUIRK_SEP);
1242
1258
  }
1243
1259
 
1244
1260
  // src/storage/EdgeTransitionDataStore.ts
@@ -1729,6 +1745,9 @@ var Context = class {
1729
1745
  __privateSet(this, _scores, state.ssv);
1730
1746
  __privateGet(this, _mitt3).emit("log", ["debug", 130, state]);
1731
1747
  }
1748
+ if (state.compositionMetadata) {
1749
+ __privateGet(this, _state).compositionMetadata = state.compositionMetadata;
1750
+ }
1732
1751
  },
1733
1752
  onLogMessage: (message) => __privateGet(this, _mitt3).emit("log", message)
1734
1753
  });
@@ -1881,10 +1900,16 @@ var Context = class {
1881
1900
  scores: __privateGet(this, _serverTransitionState) ? __privateMethod(this, _Context_instances, calculateScores_fn).call(this, this.storage.data) : __privateGet(this, _scores)
1882
1901
  })
1883
1902
  );
1903
+ const previousCompositionMetadata = __privateGet(this, _state).compositionMetadata;
1884
1904
  __privateSet(this, _state, {
1885
1905
  ...__privateGet(this, _state),
1886
1906
  ...newData
1887
1907
  });
1908
+ if (newData.compositionMetadata && // deep equal is not too bad, as we only have 1 level of depth in dynamic inputs
1909
+ !dequal5(previousCompositionMetadata, __privateGet(this, _state).compositionMetadata)) {
1910
+ __privateGet(this, _mitt3).emit("canvasDataUpdated", __privateGet(this, _state).compositionMetadata);
1911
+ __privateGet(this, _state).compositionMetadata = newData.compositionMetadata;
1912
+ }
1888
1913
  await this.storage.updateData(commands);
1889
1914
  if (__privateGet(this, _serverTransitionState)) {
1890
1915
  await this.processServerCommands({
@@ -1896,7 +1921,9 @@ var Context = class {
1896
1921
  __privateMethod(this, _Context_instances, emitTest_fn).call(this, {
1897
1922
  name: testName,
1898
1923
  variantId: testVariantId,
1899
- variantAssigned: true
1924
+ variantAssigned: true,
1925
+ control: false,
1926
+ compositionMetadata: void 0
1900
1927
  });
1901
1928
  });
1902
1929
  const haveQuirksChanged = __privateGet(this, _serverTransitionState) && !dequal5(__privateGet(this, _serverTransitionState).quirks, this.storage.data.quirks);
@@ -1912,7 +1939,7 @@ var Context = class {
1912
1939
  if (!plugin.update) {
1913
1940
  continue;
1914
1941
  }
1915
- await plugin.update(newData);
1942
+ await plugin.update(newData, __privateGet(this, _scores));
1916
1943
  }
1917
1944
  }
1918
1945
  (_e = __privateGet(this, _commands)) == null ? void 0 : _e.push(...commands);
@@ -1978,7 +2005,7 @@ var Context = class {
1978
2005
  }
1979
2006
  /** 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) */
1980
2007
  test(options) {
1981
- var _a, _b, _c;
2008
+ var _a, _b, _c, _d, _e;
1982
2009
  if (options.name === CONTEXTUAL_EDITING_TEST_NAME) {
1983
2010
  const selectedVariant = (_a = options.variations.find((variant) => variant.id === CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID)) != null ? _a : options.variations.at(-1);
1984
2011
  const value2 = {
@@ -1995,7 +2022,9 @@ var Context = class {
1995
2022
  __privateMethod(this, _Context_instances, emitTest_fn).call(this, {
1996
2023
  name: options.name,
1997
2024
  variantId: (_c = (_b = value.result) == null ? void 0 : _b.id) != null ? _c : void 0,
1998
- variantAssigned: value.variantAssigned
2025
+ variantAssigned: value.variantAssigned,
2026
+ control: (_e = (_d = value.result) == null ? void 0 : _d.control) != null ? _e : false,
2027
+ compositionMetadata: options.compositionMetadata
1999
2028
  });
2000
2029
  return value;
2001
2030
  }
@@ -2024,7 +2053,8 @@ var Context = class {
2024
2053
  control: variation.control
2025
2054
  })),
2026
2055
  control: this.storage.data.controlGroup,
2027
- changed: true
2056
+ changed: true,
2057
+ compositionMetadata: options.compositionMetadata
2028
2058
  };
2029
2059
  if (previousPlacement && dequal5(eventData.variantIds, previousPlacement)) {
2030
2060
  eventData.changed = false;
@@ -2038,7 +2068,10 @@ var Context = class {
2038
2068
  * @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
2039
2069
  */
2040
2070
  async forget(fromAllDevices) {
2041
- __privateSet(this, _state, {});
2071
+ const previousCompositionMetadata = __privateGet(this, _state).compositionMetadata;
2072
+ __privateSet(this, _state, {
2073
+ compositionMetadata: previousCompositionMetadata
2074
+ });
2042
2075
  if (__privateGet(this, _plugins)) {
2043
2076
  for (let i = 0; i < __privateGet(this, _plugins).length; i++) {
2044
2077
  const plugin = __privateGet(this, _plugins)[i];
@@ -2061,7 +2094,8 @@ var Context = class {
2061
2094
  ssv: __privateGet(this, _scores),
2062
2095
  tests: {},
2063
2096
  personalizeVariants: this.storage.data.personalizeVariants,
2064
- commands: __privateGet(this, _commands)
2097
+ commands: __privateGet(this, _commands),
2098
+ compositionMetadata: __privateGet(this, _state).compositionMetadata
2065
2099
  };
2066
2100
  const allTests = this.storage.data.tests;
2067
2101
  Object.entries(allTests).map(([testName, testValue]) => {
@@ -2084,6 +2118,27 @@ var Context = class {
2084
2118
  __privateGet(this, _pzCache)[event.name] = event.variantIds;
2085
2119
  __privateGet(this, _mitt3).emit("personalizationResult", event);
2086
2120
  }
2121
+ /**
2122
+ * Gets the current canvas data
2123
+ */
2124
+ getCompositionMetadata() {
2125
+ return __privateGet(this, _state).compositionMetadata;
2126
+ }
2127
+ /**
2128
+ * Updates the canvas data and emits a canvasDataUpdated event
2129
+ */
2130
+ async updateCompositionMetadata(newData) {
2131
+ const currentCanvas = __privateGet(this, _state).compositionMetadata || {};
2132
+ const updatedCanvas = { ...currentCanvas, ...newData };
2133
+ if (!dequal5(currentCanvas, updatedCanvas)) {
2134
+ __privateSet(this, _state, {
2135
+ ...__privateGet(this, _state),
2136
+ compositionMetadata: updatedCanvas
2137
+ });
2138
+ __privateGet(this, _mitt3).emit("canvasDataUpdated", updatedCanvas);
2139
+ __privateGet(this, _mitt3).emit("log", ["info", 4, "Canvas data updated"]);
2140
+ }
2141
+ }
2087
2142
  };
2088
2143
  _personalizationSelectionAlgorithms = new WeakMap();
2089
2144
  _serverTransitionState = new WeakMap();
@@ -2248,8 +2303,31 @@ var ScriptType = /* @__PURE__ */ ((ScriptType2) => {
2248
2303
  })(ScriptType || {});
2249
2304
  var EdgeNodeTagName = "nesitag";
2250
2305
 
2251
- // src/insights/index.ts
2252
- import { v4 } from "uuid";
2306
+ // src/insights/storage.ts
2307
+ var createInsightsStorage = () => {
2308
+ const STORAGE_KEY2 = "ufin";
2309
+ return {
2310
+ get: () => {
2311
+ const data = localStorage.getItem(STORAGE_KEY2);
2312
+ if (!data) {
2313
+ return;
2314
+ }
2315
+ return JSON.parse(data);
2316
+ },
2317
+ set: (data) => {
2318
+ const toSet = {
2319
+ ...data,
2320
+ updated: Date.now()
2321
+ };
2322
+ localStorage.setItem(STORAGE_KEY2, JSON.stringify(toSet));
2323
+ },
2324
+ clear: () => {
2325
+ localStorage.removeItem(STORAGE_KEY2);
2326
+ }
2327
+ };
2328
+ };
2329
+
2330
+ // src/insights/types.ts
2253
2331
  var getBasePayload = () => {
2254
2332
  const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
2255
2333
  const locale = navigator.languages && navigator.languages.length ? navigator.languages[0] : navigator.userLanguage || navigator.language || navigator.browserLanguage || "en";
@@ -2262,13 +2340,34 @@ var getBasePayload = () => {
2262
2340
  href: window.location.href
2263
2341
  };
2264
2342
  };
2343
+ var generateVisitorId = () => {
2344
+ return `visitor_${generalRandomId()}`;
2345
+ };
2346
+ var generateSessionId = () => {
2347
+ return `session_${generalRandomId()}`;
2348
+ };
2349
+ var generatePageId = () => {
2350
+ return `page_${generalRandomId()}`;
2351
+ };
2352
+ var generalRandomId = () => {
2353
+ if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
2354
+ const id = crypto.randomUUID();
2355
+ return id.replaceAll("-", "").toLowerCase();
2356
+ }
2357
+ return Math.random().toString(32).substring(2);
2358
+ };
2359
+
2360
+ // src/insights/v1.ts
2265
2361
  var createInsightsClient = ({ endpoint }) => {
2266
2362
  let endpointUrl;
2267
2363
  const apiKey = endpoint.apiKey;
2268
2364
  const projectId = endpoint.projectId;
2269
2365
  if (endpoint.type === "api") {
2270
2366
  const url = new URL(endpoint.host);
2271
- url.pathname = "/v0/events";
2367
+ url.pathname = `/v0/events`;
2368
+ if (endpoint.host.includes("tinybird.co")) {
2369
+ url.pathname = "/v0/events";
2370
+ }
2272
2371
  url.searchParams.set("name", "analytics_events");
2273
2372
  endpointUrl = url.toString();
2274
2373
  } else {
@@ -2398,38 +2497,7 @@ var createInsightsClient = ({ endpoint }) => {
2398
2497
  }
2399
2498
  };
2400
2499
  };
2401
- var createInsightsStorage = () => {
2402
- const STORAGE_KEY2 = "ufin";
2403
- return {
2404
- get: () => {
2405
- const data = localStorage.getItem(STORAGE_KEY2);
2406
- if (!data) {
2407
- return;
2408
- }
2409
- return JSON.parse(data);
2410
- },
2411
- set: (data) => {
2412
- const toSet = {
2413
- ...data,
2414
- updated: Date.now()
2415
- };
2416
- localStorage.setItem(STORAGE_KEY2, JSON.stringify(toSet));
2417
- },
2418
- clear: () => {
2419
- localStorage.removeItem(STORAGE_KEY2);
2420
- }
2421
- };
2422
- };
2423
- var generateVisitorId = () => {
2424
- return `visitor_${generalRandomId()}`;
2425
- };
2426
- var generateSessionId = () => {
2427
- return `session_${generalRandomId()}`;
2428
- };
2429
- var generatePageId = () => {
2430
- return `page_${generalRandomId()}`;
2431
- };
2432
- var createInsights = ({
2500
+ var createInsightsV1 = ({
2433
2501
  endpoint,
2434
2502
  sessionDurationSeconds = 30 * 60
2435
2503
  }) => {
@@ -2530,8 +2598,10 @@ var createInsights = ({
2530
2598
  }
2531
2599
  };
2532
2600
  };
2601
+
2602
+ // src/insights/index.ts
2533
2603
  var enableUniformInsights = (options) => {
2534
- const insights = createInsights({
2604
+ const insights = createInsightsV1({
2535
2605
  endpoint: options.endpoint
2536
2606
  });
2537
2607
  let previousUrl = void 0;
@@ -2577,8 +2647,8 @@ var enableUniformInsights = (options) => {
2577
2647
  };
2578
2648
  },
2579
2649
  update: (context) => {
2580
- if (context.url && context.url !== previousUrl) {
2581
- previousUrl = context.url;
2650
+ if (context.url && context.url.toString() !== previousUrl) {
2651
+ previousUrl = context.url.toString();
2582
2652
  insights.pageHit();
2583
2653
  }
2584
2654
  },
@@ -2587,10 +2657,6 @@ var enableUniformInsights = (options) => {
2587
2657
  }
2588
2658
  };
2589
2659
  };
2590
- var generalRandomId = () => {
2591
- const id = v4();
2592
- return id.replaceAll("-", "").toLowerCase();
2593
- };
2594
2660
 
2595
2661
  // src/logging/enableConsoleLogDrain.ts
2596
2662
  import rfdc2 from "rfdc";
@@ -2787,6 +2853,7 @@ export {
2787
2853
  KV_SEP,
2788
2854
  ManifestInstance,
2789
2855
  PAIR_SEP,
2856
+ QUIRK_KV_SEP,
2790
2857
  QUIRK_SEP,
2791
2858
  SERVER_STATE_ID,
2792
2859
  STRONGEST_SCORE_PERSONALIZATION_ALGORITHM,
@@ -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>) => Promise<void> | void;
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 ContextState as aF, type ContextStateUpdate as aG, type GoalStateUpdate as aH, type paths as aI, 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 };
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 };