@uniformdev/context 20.35.1-alpha.87 → 20.36.1-alpha.1

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.
@@ -1,4 +1,4 @@
1
- import { aJ as paths$7, $ as ManifestV2 } from '../types-BT2-bPGD.mjs';
1
+ import { aI as paths$7, $ as ManifestV2 } from '../types-CzIkFCDD.mjs';
2
2
  import 'mitt';
3
3
 
4
4
  type LimitPolicy = <ReturnValue>(func: () => Promise<ReturnValue>) => Promise<ReturnValue>;
package/dist/api/api.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { aJ as paths$7, $ as ManifestV2 } from '../types-BT2-bPGD.js';
1
+ import { aI as paths$7, $ as ManifestV2 } from '../types-CzIkFCDD.js';
2
2
  import 'mitt';
3
3
 
4
4
  type LimitPolicy = <ReturnValue>(func: () => Promise<ReturnValue>) => Promise<ReturnValue>;
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { O as OutputSeverity, L as LogDrain, C as ContextPlugin, S as ScoreVector, A as AggregateDimension, T as TransitionDataStore, a as StorageCommands, V as VisitorData, Q as Quirks, b as TransitionDataStoreOptions, D as DecayFunction, c as CriteriaEvaluator, d as StringMatch, e as VariantMatchCriteria, f as LogMessage, P as PersonalizedVariant, g as PersonalizeOptions, h as Context, i as PersonalizedResult, j as VariationMatchDimensionCriteria, k as PersonalizationSelectionAlgorithmOptions, l as DevToolsEvents } from './types-BT2-bPGD.mjs';
2
- export { a7 as AggregateDimensionInput, ad as BehaviorTag, m as CONTEXTUAL_EDITING_TEST_NAME, n as CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID, aF as CompositionMetadata, u as ContextEvents, v as ContextInstance, q as ContextOptions, aG as ContextState, aH as ContextStateUpdate, Z as CriteriaEvaluatorParameters, Y as CriteriaEvaluatorResult, au as DecayOptions, y as DevToolsActions, E as DevToolsDataEvent, z as DevToolsEvent, I as DevToolsForgetEvent, F as DevToolsHelloEvent, B as DevToolsLogEvent, H as DevToolsRawCommandsEvent, x as DevToolsState, w as DevToolsUiVersion, G as DevToolsUpdateEvent, ab as DimensionMatch, a4 as EnrichmentCategory, aA as EnrichmentData, aD as EventData, aI as GoalStateUpdate, az as Goals, X as GroupCriteriaEvaluator, an as IdentifyCommand, U as LogMessageGroup, R as LogMessageSingle, J as LogMessages, W as ManifestInstance, $ as ManifestV2, M as MessageCategory, N as MessageFunc, ai as ModifyScoreCommand, aj as ModifySessionScoreCommand, a5 as NumberMatch, s as PersonalizationEvent, r as PersonalizationEventVariantId, a0 as PersonalizationManifest, o as PersonalizationSelectionAlgorithm, p as PersonalizationSelectionAlgorithms, aB as PersonalizeControlVariant, aC as PersonalizeVariants, ac as QuirkMatch, as as SERVER_STATE_ID, ar as ServerToClientTransitionState, ak as SetConsentCommand, ao as SetControlGroupCommand, ah as SetGoalCommand, ap as SetPersonalizeVariantControlCommand, al as SetQuirkCommand, am as SetTestCommand, K as Severity, a1 as Signal, a3 as SignalCriteria, a2 as SignalCriteriaGroup, _ as SignalData, ag as StorageCommand, a6 as TestDefinition, t as TestEvent, a8 as TestOptions, af as TestResult, ae as TestVariant, ay as Tests, at as TransitionDataStoreEvents, aa as VariationMatchMetadata, ax as VisitorDataStore, aw as VisitorDataStoreEvents, av as VisitorDataStoreOptions, aq as areCommandsEqual, aE as emptyVisitorData, a9 as testVariations } from './types-BT2-bPGD.mjs';
1
+ import { O as OutputSeverity, L as LogDrain, C as ContextPlugin, S as ScoreVector, A as AggregateDimension, T as TransitionDataStore, a as StorageCommands, V as VisitorData, Q as Quirks, b as TransitionDataStoreOptions, D as DecayFunction, c as CriteriaEvaluator, d as StringMatch, e as VariantMatchCriteria, f as LogMessage, P as PersonalizedVariant, g as PersonalizeOptions, h as Context, i as PersonalizedResult, j as VariationMatchDimensionCriteria, k as PersonalizationSelectionAlgorithmOptions, l as DevToolsEvents } from './types-CzIkFCDD.mjs';
2
+ export { a7 as AggregateDimensionInput, ad as BehaviorTag, m as CONTEXTUAL_EDITING_TEST_NAME, n as CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID, u as ContextEvents, v as ContextInstance, q as ContextOptions, aF as ContextState, aG as ContextStateUpdate, Z as CriteriaEvaluatorParameters, Y as CriteriaEvaluatorResult, au as DecayOptions, y as DevToolsActions, E as DevToolsDataEvent, z as DevToolsEvent, I as DevToolsForgetEvent, F as DevToolsHelloEvent, B as DevToolsLogEvent, H as DevToolsRawCommandsEvent, x as DevToolsState, w as DevToolsUiVersion, G as DevToolsUpdateEvent, ab as DimensionMatch, a4 as EnrichmentCategory, aA as EnrichmentData, aD as EventData, aH as GoalStateUpdate, az as Goals, X as GroupCriteriaEvaluator, an as IdentifyCommand, U as LogMessageGroup, R as LogMessageSingle, J as LogMessages, W as ManifestInstance, $ as ManifestV2, M as MessageCategory, N as MessageFunc, ai as ModifyScoreCommand, aj as ModifySessionScoreCommand, a5 as NumberMatch, s as PersonalizationEvent, r as PersonalizationEventVariantId, a0 as PersonalizationManifest, o as PersonalizationSelectionAlgorithm, p as PersonalizationSelectionAlgorithms, aB as PersonalizeControlVariant, aC as PersonalizeVariants, ac as QuirkMatch, as as SERVER_STATE_ID, ar as ServerToClientTransitionState, ak as SetConsentCommand, ao as SetControlGroupCommand, ah as SetGoalCommand, ap as SetPersonalizeVariantControlCommand, al as SetQuirkCommand, am as SetTestCommand, K as Severity, a1 as Signal, a3 as SignalCriteria, a2 as SignalCriteriaGroup, _ as SignalData, ag as StorageCommand, a6 as TestDefinition, t as TestEvent, a8 as TestOptions, af as TestResult, ae as TestVariant, ay as Tests, at as TransitionDataStoreEvents, aa as VariationMatchMetadata, ax as VisitorDataStore, aw as VisitorDataStoreEvents, av as VisitorDataStoreOptions, aq as areCommandsEqual, aE as emptyVisitorData, a9 as testVariations } from './types-CzIkFCDD.mjs';
3
3
  import Cookies from 'js-cookie';
4
4
  import 'mitt';
5
5
 
@@ -229,13 +229,9 @@ type InsightsEndpoint = {
229
229
  apiKey?: string;
230
230
  projectId?: string;
231
231
  };
232
-
233
232
  type EnableUniformInsightsOptions = {
234
233
  endpoint: InsightsEndpoint;
235
234
  };
236
- /**
237
- * @deprecated Use `import { enableUniformInsights } from '@uniformdev/insights'` instead
238
- */
239
235
  declare const enableUniformInsights: (options: EnableUniformInsightsOptions) => ContextPlugin;
240
236
 
241
237
  type QuickConnectConfig = {
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { O as OutputSeverity, L as LogDrain, C as ContextPlugin, S as ScoreVector, A as AggregateDimension, T as TransitionDataStore, a as StorageCommands, V as VisitorData, Q as Quirks, b as TransitionDataStoreOptions, D as DecayFunction, c as CriteriaEvaluator, d as StringMatch, e as VariantMatchCriteria, f as LogMessage, P as PersonalizedVariant, g as PersonalizeOptions, h as Context, i as PersonalizedResult, j as VariationMatchDimensionCriteria, k as PersonalizationSelectionAlgorithmOptions, l as DevToolsEvents } from './types-BT2-bPGD.js';
2
- export { a7 as AggregateDimensionInput, ad as BehaviorTag, m as CONTEXTUAL_EDITING_TEST_NAME, n as CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID, aF as CompositionMetadata, u as ContextEvents, v as ContextInstance, q as ContextOptions, aG as ContextState, aH as ContextStateUpdate, Z as CriteriaEvaluatorParameters, Y as CriteriaEvaluatorResult, au as DecayOptions, y as DevToolsActions, E as DevToolsDataEvent, z as DevToolsEvent, I as DevToolsForgetEvent, F as DevToolsHelloEvent, B as DevToolsLogEvent, H as DevToolsRawCommandsEvent, x as DevToolsState, w as DevToolsUiVersion, G as DevToolsUpdateEvent, ab as DimensionMatch, a4 as EnrichmentCategory, aA as EnrichmentData, aD as EventData, aI as GoalStateUpdate, az as Goals, X as GroupCriteriaEvaluator, an as IdentifyCommand, U as LogMessageGroup, R as LogMessageSingle, J as LogMessages, W as ManifestInstance, $ as ManifestV2, M as MessageCategory, N as MessageFunc, ai as ModifyScoreCommand, aj as ModifySessionScoreCommand, a5 as NumberMatch, s as PersonalizationEvent, r as PersonalizationEventVariantId, a0 as PersonalizationManifest, o as PersonalizationSelectionAlgorithm, p as PersonalizationSelectionAlgorithms, aB as PersonalizeControlVariant, aC as PersonalizeVariants, ac as QuirkMatch, as as SERVER_STATE_ID, ar as ServerToClientTransitionState, ak as SetConsentCommand, ao as SetControlGroupCommand, ah as SetGoalCommand, ap as SetPersonalizeVariantControlCommand, al as SetQuirkCommand, am as SetTestCommand, K as Severity, a1 as Signal, a3 as SignalCriteria, a2 as SignalCriteriaGroup, _ as SignalData, ag as StorageCommand, a6 as TestDefinition, t as TestEvent, a8 as TestOptions, af as TestResult, ae as TestVariant, ay as Tests, at as TransitionDataStoreEvents, aa as VariationMatchMetadata, ax as VisitorDataStore, aw as VisitorDataStoreEvents, av as VisitorDataStoreOptions, aq as areCommandsEqual, aE as emptyVisitorData, a9 as testVariations } from './types-BT2-bPGD.js';
1
+ import { O as OutputSeverity, L as LogDrain, C as ContextPlugin, S as ScoreVector, A as AggregateDimension, T as TransitionDataStore, a as StorageCommands, V as VisitorData, Q as Quirks, b as TransitionDataStoreOptions, D as DecayFunction, c as CriteriaEvaluator, d as StringMatch, e as VariantMatchCriteria, f as LogMessage, P as PersonalizedVariant, g as PersonalizeOptions, h as Context, i as PersonalizedResult, j as VariationMatchDimensionCriteria, k as PersonalizationSelectionAlgorithmOptions, l as DevToolsEvents } from './types-CzIkFCDD.js';
2
+ export { a7 as AggregateDimensionInput, ad as BehaviorTag, m as CONTEXTUAL_EDITING_TEST_NAME, n as CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID, u as ContextEvents, v as ContextInstance, q as ContextOptions, aF as ContextState, aG as ContextStateUpdate, Z as CriteriaEvaluatorParameters, Y as CriteriaEvaluatorResult, au as DecayOptions, y as DevToolsActions, E as DevToolsDataEvent, z as DevToolsEvent, I as DevToolsForgetEvent, F as DevToolsHelloEvent, B as DevToolsLogEvent, H as DevToolsRawCommandsEvent, x as DevToolsState, w as DevToolsUiVersion, G as DevToolsUpdateEvent, ab as DimensionMatch, a4 as EnrichmentCategory, aA as EnrichmentData, aD as EventData, aH as GoalStateUpdate, az as Goals, X as GroupCriteriaEvaluator, an as IdentifyCommand, U as LogMessageGroup, R as LogMessageSingle, J as LogMessages, W as ManifestInstance, $ as ManifestV2, M as MessageCategory, N as MessageFunc, ai as ModifyScoreCommand, aj as ModifySessionScoreCommand, a5 as NumberMatch, s as PersonalizationEvent, r as PersonalizationEventVariantId, a0 as PersonalizationManifest, o as PersonalizationSelectionAlgorithm, p as PersonalizationSelectionAlgorithms, aB as PersonalizeControlVariant, aC as PersonalizeVariants, ac as QuirkMatch, as as SERVER_STATE_ID, ar as ServerToClientTransitionState, ak as SetConsentCommand, ao as SetControlGroupCommand, ah as SetGoalCommand, ap as SetPersonalizeVariantControlCommand, al as SetQuirkCommand, am as SetTestCommand, K as Severity, a1 as Signal, a3 as SignalCriteria, a2 as SignalCriteriaGroup, _ as SignalData, ag as StorageCommand, a6 as TestDefinition, t as TestEvent, a8 as TestOptions, af as TestResult, ae as TestVariant, ay as Tests, at as TransitionDataStoreEvents, aa as VariationMatchMetadata, ax as VisitorDataStore, aw as VisitorDataStoreEvents, av as VisitorDataStoreOptions, aq as areCommandsEqual, aE as emptyVisitorData, a9 as testVariations } from './types-CzIkFCDD.js';
3
3
  import Cookies from 'js-cookie';
4
4
  import 'mitt';
5
5
 
@@ -229,13 +229,9 @@ type InsightsEndpoint = {
229
229
  apiKey?: string;
230
230
  projectId?: string;
231
231
  };
232
-
233
232
  type EnableUniformInsightsOptions = {
234
233
  endpoint: InsightsEndpoint;
235
234
  };
236
- /**
237
- * @deprecated Use `import { enableUniformInsights } from '@uniformdev/insights'` instead
238
- */
239
235
  declare const enableUniformInsights: (options: EnableUniformInsightsOptions) => ContextPlugin;
240
236
 
241
237
  type QuickConnectConfig = {
package/dist/index.esm.js CHANGED
@@ -941,9 +941,6 @@ var testVariations = ({
941
941
  }
942
942
  if (selectedVariant) {
943
943
  onLogMessage == null ? void 0 : onLogMessage(["info", 404, selectedVariant.id]);
944
- if (selectedVariant.control === void 0) {
945
- selectedVariant.control = variations.findIndex((variation) => variation.id === selectedVariantId) === 0;
946
- }
947
944
  }
948
945
  return {
949
946
  result: selectedVariant,
@@ -1798,7 +1795,7 @@ var Context = class {
1798
1795
  * i.e. pushing the same URL or cookies as before,
1799
1796
  * will NOT result in a recomputation of signal state.
1800
1797
  */
1801
- async update({ compositionMetadata, ...newData }) {
1798
+ async update(newData) {
1802
1799
  var _a, _b, _c, _d, _e;
1803
1800
  const commands = [];
1804
1801
  const newServerSideTests = {};
@@ -1907,9 +1904,7 @@ var Context = class {
1907
1904
  __privateMethod(this, _Context_instances, emitTest_fn).call(this, {
1908
1905
  name: testName,
1909
1906
  variantId: testVariantId,
1910
- variantAssigned: true,
1911
- control: false,
1912
- compositionMetadata: void 0
1907
+ variantAssigned: true
1913
1908
  });
1914
1909
  });
1915
1910
  const haveQuirksChanged = __privateGet(this, _serverTransitionState) && !dequal5(__privateGet(this, _serverTransitionState).quirks, this.storage.data.quirks);
@@ -1991,7 +1986,7 @@ var Context = class {
1991
1986
  }
1992
1987
  /** 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) */
1993
1988
  test(options) {
1994
- var _a, _b, _c, _d, _e;
1989
+ var _a, _b, _c;
1995
1990
  if (options.name === CONTEXTUAL_EDITING_TEST_NAME) {
1996
1991
  const selectedVariant = (_a = options.variations.find((variant) => variant.id === CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID)) != null ? _a : options.variations.at(-1);
1997
1992
  const value2 = {
@@ -2008,9 +2003,7 @@ var Context = class {
2008
2003
  __privateMethod(this, _Context_instances, emitTest_fn).call(this, {
2009
2004
  name: options.name,
2010
2005
  variantId: (_c = (_b = value.result) == null ? void 0 : _b.id) != null ? _c : void 0,
2011
- variantAssigned: value.variantAssigned,
2012
- control: (_e = (_d = value.result) == null ? void 0 : _d.control) != null ? _e : false,
2013
- compositionMetadata: options.compositionMetadata
2006
+ variantAssigned: value.variantAssigned
2014
2007
  });
2015
2008
  return value;
2016
2009
  }
@@ -2039,8 +2032,7 @@ var Context = class {
2039
2032
  control: variation.control
2040
2033
  })),
2041
2034
  control: this.storage.data.controlGroup,
2042
- changed: true,
2043
- compositionMetadata: options.compositionMetadata
2035
+ changed: true
2044
2036
  };
2045
2037
  if (previousPlacement && dequal5(eventData.variantIds, previousPlacement)) {
2046
2038
  eventData.changed = false;
@@ -2100,27 +2092,6 @@ var Context = class {
2100
2092
  __privateGet(this, _pzCache)[event.name] = event.variantIds;
2101
2093
  __privateGet(this, _mitt3).emit("personalizationResult", event);
2102
2094
  }
2103
- /**
2104
- * Gets the current canvas data
2105
- */
2106
- getCompositionMetadata() {
2107
- return __privateGet(this, _state).compositionMetadata;
2108
- }
2109
- /**
2110
- * Updates the canvas data and emits a canvasDataUpdated event
2111
- */
2112
- async updateCompositionMetadata(newData) {
2113
- const currentCanvas = __privateGet(this, _state).compositionMetadata || {};
2114
- const updatedCanvas = { ...currentCanvas, ...newData };
2115
- if (!dequal5(currentCanvas, updatedCanvas)) {
2116
- __privateSet(this, _state, {
2117
- ...__privateGet(this, _state),
2118
- compositionMetadata: updatedCanvas
2119
- });
2120
- __privateGet(this, _mitt3).emit("canvasDataUpdated", updatedCanvas);
2121
- __privateGet(this, _mitt3).emit("log", ["info", 4, "Canvas data updated"]);
2122
- }
2123
- }
2124
2095
  };
2125
2096
  _personalizationSelectionAlgorithms = new WeakMap();
2126
2097
  _serverTransitionState = new WeakMap();
@@ -2285,31 +2256,7 @@ var ScriptType = /* @__PURE__ */ ((ScriptType2) => {
2285
2256
  })(ScriptType || {});
2286
2257
  var EdgeNodeTagName = "nesitag";
2287
2258
 
2288
- // src/insights/storage.ts
2289
- var createInsightsStorage = () => {
2290
- const STORAGE_KEY2 = "ufin";
2291
- return {
2292
- get: () => {
2293
- const data = localStorage.getItem(STORAGE_KEY2);
2294
- if (!data) {
2295
- return;
2296
- }
2297
- return JSON.parse(data);
2298
- },
2299
- set: (data) => {
2300
- const toSet = {
2301
- ...data,
2302
- updated: Date.now()
2303
- };
2304
- localStorage.setItem(STORAGE_KEY2, JSON.stringify(toSet));
2305
- },
2306
- clear: () => {
2307
- localStorage.removeItem(STORAGE_KEY2);
2308
- }
2309
- };
2310
- };
2311
-
2312
- // src/insights/types.ts
2259
+ // src/insights/index.ts
2313
2260
  var getBasePayload = () => {
2314
2261
  const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
2315
2262
  const locale = navigator.languages && navigator.languages.length ? navigator.languages[0] : navigator.userLanguage || navigator.language || navigator.browserLanguage || "en";
@@ -2322,34 +2269,13 @@ var getBasePayload = () => {
2322
2269
  href: window.location.href
2323
2270
  };
2324
2271
  };
2325
- var generateVisitorId = async () => {
2326
- return `visitor_${generalRandomId()}`;
2327
- };
2328
- var generateSessionId = async () => {
2329
- return `session_${generalRandomId()}`;
2330
- };
2331
- var generatePageId = () => {
2332
- return `page_${generalRandomId()}`;
2333
- };
2334
- var generalRandomId = () => {
2335
- if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
2336
- const id = crypto.randomUUID();
2337
- return id.replaceAll("-", "").toLowerCase();
2338
- }
2339
- return Math.random().toString(32).substring(2);
2340
- };
2341
-
2342
- // src/insights/v1.ts
2343
2272
  var createInsightsClient = ({ endpoint }) => {
2344
2273
  let endpointUrl;
2345
2274
  const apiKey = endpoint.apiKey;
2346
2275
  const projectId = endpoint.projectId;
2347
2276
  if (endpoint.type === "api") {
2348
2277
  const url = new URL(endpoint.host);
2349
- url.pathname = `/v0/events`;
2350
- if (endpoint.host.includes("tinybird.co")) {
2351
- url.pathname = "/v0/events";
2352
- }
2278
+ url.pathname = "/v0/events";
2353
2279
  url.searchParams.set("name", "analytics_events");
2354
2280
  endpointUrl = url.toString();
2355
2281
  } else {
@@ -2479,7 +2405,38 @@ var createInsightsClient = ({ endpoint }) => {
2479
2405
  }
2480
2406
  };
2481
2407
  };
2482
- var createInsightsV1 = ({
2408
+ var createInsightsStorage = () => {
2409
+ const STORAGE_KEY2 = "ufin";
2410
+ return {
2411
+ get: () => {
2412
+ const data = localStorage.getItem(STORAGE_KEY2);
2413
+ if (!data) {
2414
+ return;
2415
+ }
2416
+ return JSON.parse(data);
2417
+ },
2418
+ set: (data) => {
2419
+ const toSet = {
2420
+ ...data,
2421
+ updated: Date.now()
2422
+ };
2423
+ localStorage.setItem(STORAGE_KEY2, JSON.stringify(toSet));
2424
+ },
2425
+ clear: () => {
2426
+ localStorage.removeItem(STORAGE_KEY2);
2427
+ }
2428
+ };
2429
+ };
2430
+ var generateVisitorId = () => {
2431
+ return `visitor_${generalRandomId()}`;
2432
+ };
2433
+ var generateSessionId = () => {
2434
+ return `session_${generalRandomId()}`;
2435
+ };
2436
+ var generatePageId = () => {
2437
+ return `page_${generalRandomId()}`;
2438
+ };
2439
+ var createInsights = ({
2483
2440
  endpoint,
2484
2441
  sessionDurationSeconds = 30 * 60
2485
2442
  }) => {
@@ -2580,10 +2537,8 @@ var createInsightsV1 = ({
2580
2537
  }
2581
2538
  };
2582
2539
  };
2583
-
2584
- // src/insights/index.ts
2585
2540
  var enableUniformInsights = (options) => {
2586
- const insights = createInsightsV1({
2541
+ const insights = createInsights({
2587
2542
  endpoint: options.endpoint
2588
2543
  });
2589
2544
  let previousUrl = void 0;
@@ -2629,8 +2584,8 @@ var enableUniformInsights = (options) => {
2629
2584
  };
2630
2585
  },
2631
2586
  update: (context) => {
2632
- if (context.url && context.url.toString() !== previousUrl) {
2633
- previousUrl = context.url.toString();
2587
+ if (context.url && context.url !== previousUrl) {
2588
+ previousUrl = context.url;
2634
2589
  insights.pageHit();
2635
2590
  }
2636
2591
  },
@@ -2639,6 +2594,13 @@ var enableUniformInsights = (options) => {
2639
2594
  }
2640
2595
  };
2641
2596
  };
2597
+ var generalRandomId = () => {
2598
+ if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
2599
+ const id = crypto.randomUUID();
2600
+ return id.replaceAll("-", "").toLowerCase();
2601
+ }
2602
+ return Math.random().toString(32).substring(2);
2603
+ };
2642
2604
 
2643
2605
  // src/logging/enableConsoleLogDrain.ts
2644
2606
  import rfdc2 from "rfdc";
package/dist/index.js CHANGED
@@ -1034,9 +1034,6 @@ var testVariations = ({
1034
1034
  }
1035
1035
  if (selectedVariant) {
1036
1036
  onLogMessage == null ? void 0 : onLogMessage(["info", 404, selectedVariant.id]);
1037
- if (selectedVariant.control === void 0) {
1038
- selectedVariant.control = variations.findIndex((variation) => variation.id === selectedVariantId) === 0;
1039
- }
1040
1037
  }
1041
1038
  return {
1042
1039
  result: selectedVariant,
@@ -1891,7 +1888,7 @@ var Context = class {
1891
1888
  * i.e. pushing the same URL or cookies as before,
1892
1889
  * will NOT result in a recomputation of signal state.
1893
1890
  */
1894
- async update({ compositionMetadata, ...newData }) {
1891
+ async update(newData) {
1895
1892
  var _a, _b, _c, _d, _e;
1896
1893
  const commands = [];
1897
1894
  const newServerSideTests = {};
@@ -2000,9 +1997,7 @@ var Context = class {
2000
1997
  __privateMethod(this, _Context_instances, emitTest_fn).call(this, {
2001
1998
  name: testName,
2002
1999
  variantId: testVariantId,
2003
- variantAssigned: true,
2004
- control: false,
2005
- compositionMetadata: void 0
2000
+ variantAssigned: true
2006
2001
  });
2007
2002
  });
2008
2003
  const haveQuirksChanged = __privateGet(this, _serverTransitionState) && !(0, import_lite5.dequal)(__privateGet(this, _serverTransitionState).quirks, this.storage.data.quirks);
@@ -2084,7 +2079,7 @@ var Context = class {
2084
2079
  }
2085
2080
  /** 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) */
2086
2081
  test(options) {
2087
- var _a, _b, _c, _d, _e;
2082
+ var _a, _b, _c;
2088
2083
  if (options.name === CONTEXTUAL_EDITING_TEST_NAME) {
2089
2084
  const selectedVariant = (_a = options.variations.find((variant) => variant.id === CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID)) != null ? _a : options.variations.at(-1);
2090
2085
  const value2 = {
@@ -2101,9 +2096,7 @@ var Context = class {
2101
2096
  __privateMethod(this, _Context_instances, emitTest_fn).call(this, {
2102
2097
  name: options.name,
2103
2098
  variantId: (_c = (_b = value.result) == null ? void 0 : _b.id) != null ? _c : void 0,
2104
- variantAssigned: value.variantAssigned,
2105
- control: (_e = (_d = value.result) == null ? void 0 : _d.control) != null ? _e : false,
2106
- compositionMetadata: options.compositionMetadata
2099
+ variantAssigned: value.variantAssigned
2107
2100
  });
2108
2101
  return value;
2109
2102
  }
@@ -2132,8 +2125,7 @@ var Context = class {
2132
2125
  control: variation.control
2133
2126
  })),
2134
2127
  control: this.storage.data.controlGroup,
2135
- changed: true,
2136
- compositionMetadata: options.compositionMetadata
2128
+ changed: true
2137
2129
  };
2138
2130
  if (previousPlacement && (0, import_lite5.dequal)(eventData.variantIds, previousPlacement)) {
2139
2131
  eventData.changed = false;
@@ -2193,27 +2185,6 @@ var Context = class {
2193
2185
  __privateGet(this, _pzCache)[event.name] = event.variantIds;
2194
2186
  __privateGet(this, _mitt3).emit("personalizationResult", event);
2195
2187
  }
2196
- /**
2197
- * Gets the current canvas data
2198
- */
2199
- getCompositionMetadata() {
2200
- return __privateGet(this, _state).compositionMetadata;
2201
- }
2202
- /**
2203
- * Updates the canvas data and emits a canvasDataUpdated event
2204
- */
2205
- async updateCompositionMetadata(newData) {
2206
- const currentCanvas = __privateGet(this, _state).compositionMetadata || {};
2207
- const updatedCanvas = { ...currentCanvas, ...newData };
2208
- if (!(0, import_lite5.dequal)(currentCanvas, updatedCanvas)) {
2209
- __privateSet(this, _state, {
2210
- ...__privateGet(this, _state),
2211
- compositionMetadata: updatedCanvas
2212
- });
2213
- __privateGet(this, _mitt3).emit("canvasDataUpdated", updatedCanvas);
2214
- __privateGet(this, _mitt3).emit("log", ["info", 4, "Canvas data updated"]);
2215
- }
2216
- }
2217
2188
  };
2218
2189
  _personalizationSelectionAlgorithms = new WeakMap();
2219
2190
  _serverTransitionState = new WeakMap();
@@ -2378,31 +2349,7 @@ var ScriptType = /* @__PURE__ */ ((ScriptType2) => {
2378
2349
  })(ScriptType || {});
2379
2350
  var EdgeNodeTagName = "nesitag";
2380
2351
 
2381
- // src/insights/storage.ts
2382
- var createInsightsStorage = () => {
2383
- const STORAGE_KEY2 = "ufin";
2384
- return {
2385
- get: () => {
2386
- const data = localStorage.getItem(STORAGE_KEY2);
2387
- if (!data) {
2388
- return;
2389
- }
2390
- return JSON.parse(data);
2391
- },
2392
- set: (data) => {
2393
- const toSet = {
2394
- ...data,
2395
- updated: Date.now()
2396
- };
2397
- localStorage.setItem(STORAGE_KEY2, JSON.stringify(toSet));
2398
- },
2399
- clear: () => {
2400
- localStorage.removeItem(STORAGE_KEY2);
2401
- }
2402
- };
2403
- };
2404
-
2405
- // src/insights/types.ts
2352
+ // src/insights/index.ts
2406
2353
  var getBasePayload = () => {
2407
2354
  const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
2408
2355
  const locale = navigator.languages && navigator.languages.length ? navigator.languages[0] : navigator.userLanguage || navigator.language || navigator.browserLanguage || "en";
@@ -2415,34 +2362,13 @@ var getBasePayload = () => {
2415
2362
  href: window.location.href
2416
2363
  };
2417
2364
  };
2418
- var generateVisitorId = async () => {
2419
- return `visitor_${generalRandomId()}`;
2420
- };
2421
- var generateSessionId = async () => {
2422
- return `session_${generalRandomId()}`;
2423
- };
2424
- var generatePageId = () => {
2425
- return `page_${generalRandomId()}`;
2426
- };
2427
- var generalRandomId = () => {
2428
- if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
2429
- const id = crypto.randomUUID();
2430
- return id.replaceAll("-", "").toLowerCase();
2431
- }
2432
- return Math.random().toString(32).substring(2);
2433
- };
2434
-
2435
- // src/insights/v1.ts
2436
2365
  var createInsightsClient = ({ endpoint }) => {
2437
2366
  let endpointUrl;
2438
2367
  const apiKey = endpoint.apiKey;
2439
2368
  const projectId = endpoint.projectId;
2440
2369
  if (endpoint.type === "api") {
2441
2370
  const url = new URL(endpoint.host);
2442
- url.pathname = `/v0/events`;
2443
- if (endpoint.host.includes("tinybird.co")) {
2444
- url.pathname = "/v0/events";
2445
- }
2371
+ url.pathname = "/v0/events";
2446
2372
  url.searchParams.set("name", "analytics_events");
2447
2373
  endpointUrl = url.toString();
2448
2374
  } else {
@@ -2572,7 +2498,38 @@ var createInsightsClient = ({ endpoint }) => {
2572
2498
  }
2573
2499
  };
2574
2500
  };
2575
- var createInsightsV1 = ({
2501
+ var createInsightsStorage = () => {
2502
+ const STORAGE_KEY2 = "ufin";
2503
+ return {
2504
+ get: () => {
2505
+ const data = localStorage.getItem(STORAGE_KEY2);
2506
+ if (!data) {
2507
+ return;
2508
+ }
2509
+ return JSON.parse(data);
2510
+ },
2511
+ set: (data) => {
2512
+ const toSet = {
2513
+ ...data,
2514
+ updated: Date.now()
2515
+ };
2516
+ localStorage.setItem(STORAGE_KEY2, JSON.stringify(toSet));
2517
+ },
2518
+ clear: () => {
2519
+ localStorage.removeItem(STORAGE_KEY2);
2520
+ }
2521
+ };
2522
+ };
2523
+ var generateVisitorId = () => {
2524
+ return `visitor_${generalRandomId()}`;
2525
+ };
2526
+ var generateSessionId = () => {
2527
+ return `session_${generalRandomId()}`;
2528
+ };
2529
+ var generatePageId = () => {
2530
+ return `page_${generalRandomId()}`;
2531
+ };
2532
+ var createInsights = ({
2576
2533
  endpoint,
2577
2534
  sessionDurationSeconds = 30 * 60
2578
2535
  }) => {
@@ -2673,10 +2630,8 @@ var createInsightsV1 = ({
2673
2630
  }
2674
2631
  };
2675
2632
  };
2676
-
2677
- // src/insights/index.ts
2678
2633
  var enableUniformInsights = (options) => {
2679
- const insights = createInsightsV1({
2634
+ const insights = createInsights({
2680
2635
  endpoint: options.endpoint
2681
2636
  });
2682
2637
  let previousUrl = void 0;
@@ -2722,8 +2677,8 @@ var enableUniformInsights = (options) => {
2722
2677
  };
2723
2678
  },
2724
2679
  update: (context) => {
2725
- if (context.url && context.url.toString() !== previousUrl) {
2726
- previousUrl = context.url.toString();
2680
+ if (context.url && context.url !== previousUrl) {
2681
+ previousUrl = context.url;
2727
2682
  insights.pageHit();
2728
2683
  }
2729
2684
  },
@@ -2732,6 +2687,13 @@ var enableUniformInsights = (options) => {
2732
2687
  }
2733
2688
  };
2734
2689
  };
2690
+ var generalRandomId = () => {
2691
+ if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
2692
+ const id = crypto.randomUUID();
2693
+ return id.replaceAll("-", "").toLowerCase();
2694
+ }
2695
+ return Math.random().toString(32).substring(2);
2696
+ };
2735
2697
 
2736
2698
  // src/logging/enableConsoleLogDrain.ts
2737
2699
  var import_rfdc2 = __toESM(require("rfdc"));
package/dist/index.mjs CHANGED
@@ -941,9 +941,6 @@ var testVariations = ({
941
941
  }
942
942
  if (selectedVariant) {
943
943
  onLogMessage == null ? void 0 : onLogMessage(["info", 404, selectedVariant.id]);
944
- if (selectedVariant.control === void 0) {
945
- selectedVariant.control = variations.findIndex((variation) => variation.id === selectedVariantId) === 0;
946
- }
947
944
  }
948
945
  return {
949
946
  result: selectedVariant,
@@ -1798,7 +1795,7 @@ var Context = class {
1798
1795
  * i.e. pushing the same URL or cookies as before,
1799
1796
  * will NOT result in a recomputation of signal state.
1800
1797
  */
1801
- async update({ compositionMetadata, ...newData }) {
1798
+ async update(newData) {
1802
1799
  var _a, _b, _c, _d, _e;
1803
1800
  const commands = [];
1804
1801
  const newServerSideTests = {};
@@ -1907,9 +1904,7 @@ var Context = class {
1907
1904
  __privateMethod(this, _Context_instances, emitTest_fn).call(this, {
1908
1905
  name: testName,
1909
1906
  variantId: testVariantId,
1910
- variantAssigned: true,
1911
- control: false,
1912
- compositionMetadata: void 0
1907
+ variantAssigned: true
1913
1908
  });
1914
1909
  });
1915
1910
  const haveQuirksChanged = __privateGet(this, _serverTransitionState) && !dequal5(__privateGet(this, _serverTransitionState).quirks, this.storage.data.quirks);
@@ -1991,7 +1986,7 @@ var Context = class {
1991
1986
  }
1992
1987
  /** 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) */
1993
1988
  test(options) {
1994
- var _a, _b, _c, _d, _e;
1989
+ var _a, _b, _c;
1995
1990
  if (options.name === CONTEXTUAL_EDITING_TEST_NAME) {
1996
1991
  const selectedVariant = (_a = options.variations.find((variant) => variant.id === CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID)) != null ? _a : options.variations.at(-1);
1997
1992
  const value2 = {
@@ -2008,9 +2003,7 @@ var Context = class {
2008
2003
  __privateMethod(this, _Context_instances, emitTest_fn).call(this, {
2009
2004
  name: options.name,
2010
2005
  variantId: (_c = (_b = value.result) == null ? void 0 : _b.id) != null ? _c : void 0,
2011
- variantAssigned: value.variantAssigned,
2012
- control: (_e = (_d = value.result) == null ? void 0 : _d.control) != null ? _e : false,
2013
- compositionMetadata: options.compositionMetadata
2006
+ variantAssigned: value.variantAssigned
2014
2007
  });
2015
2008
  return value;
2016
2009
  }
@@ -2039,8 +2032,7 @@ var Context = class {
2039
2032
  control: variation.control
2040
2033
  })),
2041
2034
  control: this.storage.data.controlGroup,
2042
- changed: true,
2043
- compositionMetadata: options.compositionMetadata
2035
+ changed: true
2044
2036
  };
2045
2037
  if (previousPlacement && dequal5(eventData.variantIds, previousPlacement)) {
2046
2038
  eventData.changed = false;
@@ -2100,27 +2092,6 @@ var Context = class {
2100
2092
  __privateGet(this, _pzCache)[event.name] = event.variantIds;
2101
2093
  __privateGet(this, _mitt3).emit("personalizationResult", event);
2102
2094
  }
2103
- /**
2104
- * Gets the current canvas data
2105
- */
2106
- getCompositionMetadata() {
2107
- return __privateGet(this, _state).compositionMetadata;
2108
- }
2109
- /**
2110
- * Updates the canvas data and emits a canvasDataUpdated event
2111
- */
2112
- async updateCompositionMetadata(newData) {
2113
- const currentCanvas = __privateGet(this, _state).compositionMetadata || {};
2114
- const updatedCanvas = { ...currentCanvas, ...newData };
2115
- if (!dequal5(currentCanvas, updatedCanvas)) {
2116
- __privateSet(this, _state, {
2117
- ...__privateGet(this, _state),
2118
- compositionMetadata: updatedCanvas
2119
- });
2120
- __privateGet(this, _mitt3).emit("canvasDataUpdated", updatedCanvas);
2121
- __privateGet(this, _mitt3).emit("log", ["info", 4, "Canvas data updated"]);
2122
- }
2123
- }
2124
2095
  };
2125
2096
  _personalizationSelectionAlgorithms = new WeakMap();
2126
2097
  _serverTransitionState = new WeakMap();
@@ -2285,31 +2256,7 @@ var ScriptType = /* @__PURE__ */ ((ScriptType2) => {
2285
2256
  })(ScriptType || {});
2286
2257
  var EdgeNodeTagName = "nesitag";
2287
2258
 
2288
- // src/insights/storage.ts
2289
- var createInsightsStorage = () => {
2290
- const STORAGE_KEY2 = "ufin";
2291
- return {
2292
- get: () => {
2293
- const data = localStorage.getItem(STORAGE_KEY2);
2294
- if (!data) {
2295
- return;
2296
- }
2297
- return JSON.parse(data);
2298
- },
2299
- set: (data) => {
2300
- const toSet = {
2301
- ...data,
2302
- updated: Date.now()
2303
- };
2304
- localStorage.setItem(STORAGE_KEY2, JSON.stringify(toSet));
2305
- },
2306
- clear: () => {
2307
- localStorage.removeItem(STORAGE_KEY2);
2308
- }
2309
- };
2310
- };
2311
-
2312
- // src/insights/types.ts
2259
+ // src/insights/index.ts
2313
2260
  var getBasePayload = () => {
2314
2261
  const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
2315
2262
  const locale = navigator.languages && navigator.languages.length ? navigator.languages[0] : navigator.userLanguage || navigator.language || navigator.browserLanguage || "en";
@@ -2322,34 +2269,13 @@ var getBasePayload = () => {
2322
2269
  href: window.location.href
2323
2270
  };
2324
2271
  };
2325
- var generateVisitorId = async () => {
2326
- return `visitor_${generalRandomId()}`;
2327
- };
2328
- var generateSessionId = async () => {
2329
- return `session_${generalRandomId()}`;
2330
- };
2331
- var generatePageId = () => {
2332
- return `page_${generalRandomId()}`;
2333
- };
2334
- var generalRandomId = () => {
2335
- if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
2336
- const id = crypto.randomUUID();
2337
- return id.replaceAll("-", "").toLowerCase();
2338
- }
2339
- return Math.random().toString(32).substring(2);
2340
- };
2341
-
2342
- // src/insights/v1.ts
2343
2272
  var createInsightsClient = ({ endpoint }) => {
2344
2273
  let endpointUrl;
2345
2274
  const apiKey = endpoint.apiKey;
2346
2275
  const projectId = endpoint.projectId;
2347
2276
  if (endpoint.type === "api") {
2348
2277
  const url = new URL(endpoint.host);
2349
- url.pathname = `/v0/events`;
2350
- if (endpoint.host.includes("tinybird.co")) {
2351
- url.pathname = "/v0/events";
2352
- }
2278
+ url.pathname = "/v0/events";
2353
2279
  url.searchParams.set("name", "analytics_events");
2354
2280
  endpointUrl = url.toString();
2355
2281
  } else {
@@ -2479,7 +2405,38 @@ var createInsightsClient = ({ endpoint }) => {
2479
2405
  }
2480
2406
  };
2481
2407
  };
2482
- var createInsightsV1 = ({
2408
+ var createInsightsStorage = () => {
2409
+ const STORAGE_KEY2 = "ufin";
2410
+ return {
2411
+ get: () => {
2412
+ const data = localStorage.getItem(STORAGE_KEY2);
2413
+ if (!data) {
2414
+ return;
2415
+ }
2416
+ return JSON.parse(data);
2417
+ },
2418
+ set: (data) => {
2419
+ const toSet = {
2420
+ ...data,
2421
+ updated: Date.now()
2422
+ };
2423
+ localStorage.setItem(STORAGE_KEY2, JSON.stringify(toSet));
2424
+ },
2425
+ clear: () => {
2426
+ localStorage.removeItem(STORAGE_KEY2);
2427
+ }
2428
+ };
2429
+ };
2430
+ var generateVisitorId = () => {
2431
+ return `visitor_${generalRandomId()}`;
2432
+ };
2433
+ var generateSessionId = () => {
2434
+ return `session_${generalRandomId()}`;
2435
+ };
2436
+ var generatePageId = () => {
2437
+ return `page_${generalRandomId()}`;
2438
+ };
2439
+ var createInsights = ({
2483
2440
  endpoint,
2484
2441
  sessionDurationSeconds = 30 * 60
2485
2442
  }) => {
@@ -2580,10 +2537,8 @@ var createInsightsV1 = ({
2580
2537
  }
2581
2538
  };
2582
2539
  };
2583
-
2584
- // src/insights/index.ts
2585
2540
  var enableUniformInsights = (options) => {
2586
- const insights = createInsightsV1({
2541
+ const insights = createInsights({
2587
2542
  endpoint: options.endpoint
2588
2543
  });
2589
2544
  let previousUrl = void 0;
@@ -2629,8 +2584,8 @@ var enableUniformInsights = (options) => {
2629
2584
  };
2630
2585
  },
2631
2586
  update: (context) => {
2632
- if (context.url && context.url.toString() !== previousUrl) {
2633
- previousUrl = context.url.toString();
2587
+ if (context.url && context.url !== previousUrl) {
2588
+ previousUrl = context.url;
2634
2589
  insights.pageHit();
2635
2590
  }
2636
2591
  },
@@ -2639,6 +2594,13 @@ var enableUniformInsights = (options) => {
2639
2594
  }
2640
2595
  };
2641
2596
  };
2597
+ var generalRandomId = () => {
2598
+ if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
2599
+ const id = crypto.randomUUID();
2600
+ return id.replaceAll("-", "").toLowerCase();
2601
+ }
2602
+ return Math.random().toString(32).substring(2);
2603
+ };
2642
2604
 
2643
2605
  // src/logging/enableConsoleLogDrain.ts
2644
2606
  import rfdc2 from "rfdc";
@@ -76,17 +76,6 @@ 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
- };
90
79
  /**
91
80
  * Expresses a 'patch' to the Uniform Context state
92
81
  */
@@ -96,11 +85,6 @@ type ContextState = {
96
85
  quirks: Quirks;
97
86
  enrichments: EnrichmentData[];
98
87
  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;
104
88
  };
105
89
  type ContextStateUpdate = {
106
90
  /** The new effective state of the visitor after this state update is applied */
@@ -1046,10 +1030,6 @@ type TestVariant = {
1046
1030
  * If not provided, this variant will be selected in equal proportion to other variants without an explicit distribution.
1047
1031
  */
1048
1032
  testDistribution?: number;
1049
- /** Whether this variant is a control variant.
1050
- * Can be undefined for backward compatibility with older versions of the SDK which were not explicitly setting the control flag.
1051
- */
1052
- control?: boolean;
1053
1033
  };
1054
1034
  /** The result of computing an A/B test result */
1055
1035
  type TestResult<TVariant> = {
@@ -1071,8 +1051,6 @@ interface PersonalizeOptions<TVariant> {
1071
1051
  take?: number;
1072
1052
  /** Name of the personalization selection algorithm to use. Defaults to top-down criteria when not specified. */
1073
1053
  algorithm?: string;
1074
- /** Composition metadata where the personalization is being rendered for analytics tracking */
1075
- compositionMetadata?: CompositionMetadata;
1076
1054
  }
1077
1055
  interface PersonalizationSelectionAlgorithmOptions<TCriteria, TVariant extends PersonalizedVariant<TCriteria> = PersonalizedVariant<TCriteria>> {
1078
1056
  /** Name of placement (sent to analytics) */
@@ -1092,8 +1070,6 @@ type TestOptions<TVariant extends TestVariant> = {
1092
1070
  name: string;
1093
1071
  /** Variations that are being tested. */
1094
1072
  variations: TVariant[];
1095
- /** Composition metadata where the personalization is being rendered for analytics tracking */
1096
- compositionMetadata?: CompositionMetadata;
1097
1073
  };
1098
1074
  declare const testVariations: <TVariant extends TestVariant>({ name, context, variations, onLogMessage, }: TestOptions<TVariant> & {
1099
1075
  context: Context;
@@ -1164,12 +1140,6 @@ type PersonalizationEvent = {
1164
1140
  * False: the variant(s) selected were the same as a previous evaluation of this placement.
1165
1141
  */
1166
1142
  changed: boolean;
1167
- /**
1168
- * Contains information about the composition that contains personalization wrapper component,
1169
- * which triggered the personalization event.
1170
- * Only references top level root composition after pattern resolutions.
1171
- */
1172
- compositionMetadata?: CompositionMetadata;
1173
1143
  };
1174
1144
  /** Emitted event when an A/B test runs */
1175
1145
  type TestEvent = {
@@ -1177,22 +1147,12 @@ type TestEvent = {
1177
1147
  name: string;
1178
1148
  /** ID of the variant that was selected */
1179
1149
  variantId: string | undefined;
1180
- /**
1181
- * Whether the variant is part of the control group.
1182
- */
1183
- control: boolean;
1184
1150
  /**
1185
1151
  * Whether the test variant was newly assigned to the visitor.
1186
1152
  * True: variant was assigned to the visitor for the first time.
1187
1153
  * False: variant was already assigned to the visitor and is being reused.
1188
1154
  */
1189
1155
  variantAssigned: boolean;
1190
- /**
1191
- * Contains information about the composition that contains A/B test wrapper component,
1192
- * which triggered the A/B test event.
1193
- * Only references top level root composition after pattern resolutions.
1194
- */
1195
- compositionMetadata?: CompositionMetadata;
1196
1156
  };
1197
1157
  type ContextEvents = {
1198
1158
  /**
@@ -1216,8 +1176,6 @@ type ContextEvents = {
1216
1176
  testResult: TestEvent;
1217
1177
  /** Personalization variants have been selected */
1218
1178
  personalizationResult: PersonalizationEvent;
1219
- /** Composition metadata has been set/updated, usually happens when new composition is being rendered during client-side navigation for example */
1220
- canvasDataUpdated: CompositionMetadata;
1221
1179
  };
1222
1180
  interface ContextInstance {
1223
1181
  get scores(): Readonly<ScoreVector>;
@@ -1239,14 +1197,6 @@ interface ContextInstance {
1239
1197
  internal_processTestEvent(event: TestEvent): void;
1240
1198
  /** @deprecated */
1241
1199
  internal_processPersonalizationEvent(event: PersonalizationEvent): void;
1242
- /**
1243
- * Gets the current canvas data
1244
- */
1245
- getCompositionMetadata(): Readonly<CompositionMetadata | undefined>;
1246
- /**
1247
- * Updates the canvas data and emits a canvasDataUpdated event
1248
- */
1249
- updateCompositionMetadata(newData: CompositionMetadata): Promise<void>;
1250
1200
  }
1251
1201
  declare class Context implements ContextInstance {
1252
1202
  #private;
@@ -1282,7 +1232,7 @@ declare class Context implements ContextInstance {
1282
1232
  * i.e. pushing the same URL or cookies as before,
1283
1233
  * will NOT result in a recomputation of signal state.
1284
1234
  */
1285
- update({ compositionMetadata, ...newData }: Partial<ContextState>): Promise<void>;
1235
+ update(newData: Partial<ContextState>): Promise<void>;
1286
1236
  processServerCommands({ serverCommands, commands, }: {
1287
1237
  serverCommands: StorageCommands[] | undefined;
1288
1238
  commands: StorageCommands[];
@@ -1316,14 +1266,6 @@ declare class Context implements ContextInstance {
1316
1266
  internal_processTestEvent(event: TestEvent): void;
1317
1267
  /** @deprecated */
1318
1268
  internal_processPersonalizationEvent(event: PersonalizationEvent): void;
1319
- /**
1320
- * Gets the current canvas data
1321
- */
1322
- getCompositionMetadata(): Readonly<CompositionMetadata | undefined>;
1323
- /**
1324
- * Updates the canvas data and emits a canvasDataUpdated event
1325
- */
1326
- updateCompositionMetadata(newData: CompositionMetadata): Promise<void>;
1327
1269
  }
1328
1270
 
1329
1271
  /**
@@ -1395,4 +1337,4 @@ declare global {
1395
1337
  }
1396
1338
  }
1397
1339
 
1398
- 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 };
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 };
@@ -76,17 +76,6 @@ 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
- };
90
79
  /**
91
80
  * Expresses a 'patch' to the Uniform Context state
92
81
  */
@@ -96,11 +85,6 @@ type ContextState = {
96
85
  quirks: Quirks;
97
86
  enrichments: EnrichmentData[];
98
87
  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;
104
88
  };
105
89
  type ContextStateUpdate = {
106
90
  /** The new effective state of the visitor after this state update is applied */
@@ -1046,10 +1030,6 @@ type TestVariant = {
1046
1030
  * If not provided, this variant will be selected in equal proportion to other variants without an explicit distribution.
1047
1031
  */
1048
1032
  testDistribution?: number;
1049
- /** Whether this variant is a control variant.
1050
- * Can be undefined for backward compatibility with older versions of the SDK which were not explicitly setting the control flag.
1051
- */
1052
- control?: boolean;
1053
1033
  };
1054
1034
  /** The result of computing an A/B test result */
1055
1035
  type TestResult<TVariant> = {
@@ -1071,8 +1051,6 @@ interface PersonalizeOptions<TVariant> {
1071
1051
  take?: number;
1072
1052
  /** Name of the personalization selection algorithm to use. Defaults to top-down criteria when not specified. */
1073
1053
  algorithm?: string;
1074
- /** Composition metadata where the personalization is being rendered for analytics tracking */
1075
- compositionMetadata?: CompositionMetadata;
1076
1054
  }
1077
1055
  interface PersonalizationSelectionAlgorithmOptions<TCriteria, TVariant extends PersonalizedVariant<TCriteria> = PersonalizedVariant<TCriteria>> {
1078
1056
  /** Name of placement (sent to analytics) */
@@ -1092,8 +1070,6 @@ type TestOptions<TVariant extends TestVariant> = {
1092
1070
  name: string;
1093
1071
  /** Variations that are being tested. */
1094
1072
  variations: TVariant[];
1095
- /** Composition metadata where the personalization is being rendered for analytics tracking */
1096
- compositionMetadata?: CompositionMetadata;
1097
1073
  };
1098
1074
  declare const testVariations: <TVariant extends TestVariant>({ name, context, variations, onLogMessage, }: TestOptions<TVariant> & {
1099
1075
  context: Context;
@@ -1164,12 +1140,6 @@ type PersonalizationEvent = {
1164
1140
  * False: the variant(s) selected were the same as a previous evaluation of this placement.
1165
1141
  */
1166
1142
  changed: boolean;
1167
- /**
1168
- * Contains information about the composition that contains personalization wrapper component,
1169
- * which triggered the personalization event.
1170
- * Only references top level root composition after pattern resolutions.
1171
- */
1172
- compositionMetadata?: CompositionMetadata;
1173
1143
  };
1174
1144
  /** Emitted event when an A/B test runs */
1175
1145
  type TestEvent = {
@@ -1177,22 +1147,12 @@ type TestEvent = {
1177
1147
  name: string;
1178
1148
  /** ID of the variant that was selected */
1179
1149
  variantId: string | undefined;
1180
- /**
1181
- * Whether the variant is part of the control group.
1182
- */
1183
- control: boolean;
1184
1150
  /**
1185
1151
  * Whether the test variant was newly assigned to the visitor.
1186
1152
  * True: variant was assigned to the visitor for the first time.
1187
1153
  * False: variant was already assigned to the visitor and is being reused.
1188
1154
  */
1189
1155
  variantAssigned: boolean;
1190
- /**
1191
- * Contains information about the composition that contains A/B test wrapper component,
1192
- * which triggered the A/B test event.
1193
- * Only references top level root composition after pattern resolutions.
1194
- */
1195
- compositionMetadata?: CompositionMetadata;
1196
1156
  };
1197
1157
  type ContextEvents = {
1198
1158
  /**
@@ -1216,8 +1176,6 @@ type ContextEvents = {
1216
1176
  testResult: TestEvent;
1217
1177
  /** Personalization variants have been selected */
1218
1178
  personalizationResult: PersonalizationEvent;
1219
- /** Composition metadata has been set/updated, usually happens when new composition is being rendered during client-side navigation for example */
1220
- canvasDataUpdated: CompositionMetadata;
1221
1179
  };
1222
1180
  interface ContextInstance {
1223
1181
  get scores(): Readonly<ScoreVector>;
@@ -1239,14 +1197,6 @@ interface ContextInstance {
1239
1197
  internal_processTestEvent(event: TestEvent): void;
1240
1198
  /** @deprecated */
1241
1199
  internal_processPersonalizationEvent(event: PersonalizationEvent): void;
1242
- /**
1243
- * Gets the current canvas data
1244
- */
1245
- getCompositionMetadata(): Readonly<CompositionMetadata | undefined>;
1246
- /**
1247
- * Updates the canvas data and emits a canvasDataUpdated event
1248
- */
1249
- updateCompositionMetadata(newData: CompositionMetadata): Promise<void>;
1250
1200
  }
1251
1201
  declare class Context implements ContextInstance {
1252
1202
  #private;
@@ -1282,7 +1232,7 @@ declare class Context implements ContextInstance {
1282
1232
  * i.e. pushing the same URL or cookies as before,
1283
1233
  * will NOT result in a recomputation of signal state.
1284
1234
  */
1285
- update({ compositionMetadata, ...newData }: Partial<ContextState>): Promise<void>;
1235
+ update(newData: Partial<ContextState>): Promise<void>;
1286
1236
  processServerCommands({ serverCommands, commands, }: {
1287
1237
  serverCommands: StorageCommands[] | undefined;
1288
1238
  commands: StorageCommands[];
@@ -1316,14 +1266,6 @@ declare class Context implements ContextInstance {
1316
1266
  internal_processTestEvent(event: TestEvent): void;
1317
1267
  /** @deprecated */
1318
1268
  internal_processPersonalizationEvent(event: PersonalizationEvent): void;
1319
- /**
1320
- * Gets the current canvas data
1321
- */
1322
- getCompositionMetadata(): Readonly<CompositionMetadata | undefined>;
1323
- /**
1324
- * Updates the canvas data and emits a canvasDataUpdated event
1325
- */
1326
- updateCompositionMetadata(newData: CompositionMetadata): Promise<void>;
1327
1269
  }
1328
1270
 
1329
1271
  /**
@@ -1395,4 +1337,4 @@ declare global {
1395
1337
  }
1396
1338
  }
1397
1339
 
1398
- 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 };
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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/context",
3
- "version": "20.35.1-alpha.87+2cf616f622",
3
+ "version": "20.36.1-alpha.1+38de886ef3",
4
4
  "description": "Uniform Context core package",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -72,5 +72,5 @@
72
72
  "publishConfig": {
73
73
  "access": "public"
74
74
  },
75
- "gitHead": "2cf616f622322e5322575c106742078b5e3d7992"
75
+ "gitHead": "38de886ef32586054df84137f0abe58fc968f146"
76
76
  }