@uniformdev/context 20.33.1-alpha.54 → 20.34.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-BxuNEj-w.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-BxuNEj-w.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-BxuNEj-w.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-BxuNEj-w.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/context-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-BxuNEj-w.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-BxuNEj-w.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/context-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,10 +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
- // @todo this needs to be fixed, we should provide correct is control as well as canvas data
1912
- control: false,
1913
- compositionMetadata: void 0
1907
+ variantAssigned: true
1914
1908
  });
1915
1909
  });
1916
1910
  const haveQuirksChanged = __privateGet(this, _serverTransitionState) && !dequal5(__privateGet(this, _serverTransitionState).quirks, this.storage.data.quirks);
@@ -1992,7 +1986,7 @@ var Context = class {
1992
1986
  }
1993
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) */
1994
1988
  test(options) {
1995
- var _a, _b, _c, _d, _e;
1989
+ var _a, _b, _c;
1996
1990
  if (options.name === CONTEXTUAL_EDITING_TEST_NAME) {
1997
1991
  const selectedVariant = (_a = options.variations.find((variant) => variant.id === CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID)) != null ? _a : options.variations.at(-1);
1998
1992
  const value2 = {
@@ -2009,9 +2003,7 @@ var Context = class {
2009
2003
  __privateMethod(this, _Context_instances, emitTest_fn).call(this, {
2010
2004
  name: options.name,
2011
2005
  variantId: (_c = (_b = value.result) == null ? void 0 : _b.id) != null ? _c : void 0,
2012
- variantAssigned: value.variantAssigned,
2013
- control: (_e = (_d = value.result) == null ? void 0 : _d.control) != null ? _e : false,
2014
- compositionMetadata: options.compositionMetadata
2006
+ variantAssigned: value.variantAssigned
2015
2007
  });
2016
2008
  return value;
2017
2009
  }
@@ -2040,8 +2032,7 @@ var Context = class {
2040
2032
  control: variation.control
2041
2033
  })),
2042
2034
  control: this.storage.data.controlGroup,
2043
- changed: true,
2044
- compositionMetadata: options.compositionMetadata
2035
+ changed: true
2045
2036
  };
2046
2037
  if (previousPlacement && dequal5(eventData.variantIds, previousPlacement)) {
2047
2038
  eventData.changed = false;
@@ -2101,27 +2092,6 @@ var Context = class {
2101
2092
  __privateGet(this, _pzCache)[event.name] = event.variantIds;
2102
2093
  __privateGet(this, _mitt3).emit("personalizationResult", event);
2103
2094
  }
2104
- /**
2105
- * Gets the current canvas data
2106
- */
2107
- getCompositionMetadata() {
2108
- return __privateGet(this, _state).compositionMetadata;
2109
- }
2110
- /**
2111
- * Updates the canvas data and emits a canvasDataUpdated event
2112
- */
2113
- async updateCompositionMetadata(newData) {
2114
- const currentCanvas = __privateGet(this, _state).compositionMetadata || {};
2115
- const updatedCanvas = { ...currentCanvas, ...newData };
2116
- if (!dequal5(currentCanvas, updatedCanvas)) {
2117
- __privateSet(this, _state, {
2118
- ...__privateGet(this, _state),
2119
- compositionMetadata: updatedCanvas
2120
- });
2121
- __privateGet(this, _mitt3).emit("canvasDataUpdated", updatedCanvas);
2122
- __privateGet(this, _mitt3).emit("log", ["info", 4, "Canvas data updated"]);
2123
- }
2124
- }
2125
2095
  };
2126
2096
  _personalizationSelectionAlgorithms = new WeakMap();
2127
2097
  _serverTransitionState = new WeakMap();
@@ -2286,31 +2256,7 @@ var ScriptType = /* @__PURE__ */ ((ScriptType2) => {
2286
2256
  })(ScriptType || {});
2287
2257
  var EdgeNodeTagName = "nesitag";
2288
2258
 
2289
- // src/insights/storage.ts
2290
- var createInsightsStorage = () => {
2291
- const STORAGE_KEY2 = "ufin";
2292
- return {
2293
- get: () => {
2294
- const data = localStorage.getItem(STORAGE_KEY2);
2295
- if (!data) {
2296
- return;
2297
- }
2298
- return JSON.parse(data);
2299
- },
2300
- set: (data) => {
2301
- const toSet = {
2302
- ...data,
2303
- updated: Date.now()
2304
- };
2305
- localStorage.setItem(STORAGE_KEY2, JSON.stringify(toSet));
2306
- },
2307
- clear: () => {
2308
- localStorage.removeItem(STORAGE_KEY2);
2309
- }
2310
- };
2311
- };
2312
-
2313
- // src/insights/types.ts
2259
+ // src/insights/index.ts
2314
2260
  var getBasePayload = () => {
2315
2261
  const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
2316
2262
  const locale = navigator.languages && navigator.languages.length ? navigator.languages[0] : navigator.userLanguage || navigator.language || navigator.browserLanguage || "en";
@@ -2323,34 +2269,13 @@ var getBasePayload = () => {
2323
2269
  href: window.location.href
2324
2270
  };
2325
2271
  };
2326
- var generateVisitorId = async () => {
2327
- return `visitor_${generalRandomId()}`;
2328
- };
2329
- var generateSessionId = async () => {
2330
- return `session_${generalRandomId()}`;
2331
- };
2332
- var generatePageId = () => {
2333
- return `page_${generalRandomId()}`;
2334
- };
2335
- var generalRandomId = () => {
2336
- if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
2337
- const id = crypto.randomUUID();
2338
- return id.replaceAll("-", "").toLowerCase();
2339
- }
2340
- return Math.random().toString(32).substring(2);
2341
- };
2342
-
2343
- // src/insights/v1.ts
2344
2272
  var createInsightsClient = ({ endpoint }) => {
2345
2273
  let endpointUrl;
2346
2274
  const apiKey = endpoint.apiKey;
2347
2275
  const projectId = endpoint.projectId;
2348
2276
  if (endpoint.type === "api") {
2349
2277
  const url = new URL(endpoint.host);
2350
- url.pathname = `/v0/events`;
2351
- if (endpoint.host.includes("tinybird.co")) {
2352
- url.pathname = "/v0/events";
2353
- }
2278
+ url.pathname = "/v0/events";
2354
2279
  url.searchParams.set("name", "analytics_events");
2355
2280
  endpointUrl = url.toString();
2356
2281
  } else {
@@ -2480,7 +2405,38 @@ var createInsightsClient = ({ endpoint }) => {
2480
2405
  }
2481
2406
  };
2482
2407
  };
2483
- 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 = ({
2484
2440
  endpoint,
2485
2441
  sessionDurationSeconds = 30 * 60
2486
2442
  }) => {
@@ -2581,10 +2537,8 @@ var createInsightsV1 = ({
2581
2537
  }
2582
2538
  };
2583
2539
  };
2584
-
2585
- // src/insights/index.ts
2586
2540
  var enableUniformInsights = (options) => {
2587
- const insights = createInsightsV1({
2541
+ const insights = createInsights({
2588
2542
  endpoint: options.endpoint
2589
2543
  });
2590
2544
  let previousUrl = void 0;
@@ -2630,8 +2584,8 @@ var enableUniformInsights = (options) => {
2630
2584
  };
2631
2585
  },
2632
2586
  update: (context) => {
2633
- if (context.url && context.url.toString() !== previousUrl) {
2634
- previousUrl = context.url.toString();
2587
+ if (context.url && context.url !== previousUrl) {
2588
+ previousUrl = context.url;
2635
2589
  insights.pageHit();
2636
2590
  }
2637
2591
  },
@@ -2640,6 +2594,13 @@ var enableUniformInsights = (options) => {
2640
2594
  }
2641
2595
  };
2642
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
+ };
2643
2604
 
2644
2605
  // src/logging/enableConsoleLogDrain.ts
2645
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,10 +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
- // @todo this needs to be fixed, we should provide correct is control as well as canvas data
2005
- control: false,
2006
- compositionMetadata: void 0
2000
+ variantAssigned: true
2007
2001
  });
2008
2002
  });
2009
2003
  const haveQuirksChanged = __privateGet(this, _serverTransitionState) && !(0, import_lite5.dequal)(__privateGet(this, _serverTransitionState).quirks, this.storage.data.quirks);
@@ -2085,7 +2079,7 @@ var Context = class {
2085
2079
  }
2086
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) */
2087
2081
  test(options) {
2088
- var _a, _b, _c, _d, _e;
2082
+ var _a, _b, _c;
2089
2083
  if (options.name === CONTEXTUAL_EDITING_TEST_NAME) {
2090
2084
  const selectedVariant = (_a = options.variations.find((variant) => variant.id === CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID)) != null ? _a : options.variations.at(-1);
2091
2085
  const value2 = {
@@ -2102,9 +2096,7 @@ var Context = class {
2102
2096
  __privateMethod(this, _Context_instances, emitTest_fn).call(this, {
2103
2097
  name: options.name,
2104
2098
  variantId: (_c = (_b = value.result) == null ? void 0 : _b.id) != null ? _c : void 0,
2105
- variantAssigned: value.variantAssigned,
2106
- control: (_e = (_d = value.result) == null ? void 0 : _d.control) != null ? _e : false,
2107
- compositionMetadata: options.compositionMetadata
2099
+ variantAssigned: value.variantAssigned
2108
2100
  });
2109
2101
  return value;
2110
2102
  }
@@ -2133,8 +2125,7 @@ var Context = class {
2133
2125
  control: variation.control
2134
2126
  })),
2135
2127
  control: this.storage.data.controlGroup,
2136
- changed: true,
2137
- compositionMetadata: options.compositionMetadata
2128
+ changed: true
2138
2129
  };
2139
2130
  if (previousPlacement && (0, import_lite5.dequal)(eventData.variantIds, previousPlacement)) {
2140
2131
  eventData.changed = false;
@@ -2194,27 +2185,6 @@ var Context = class {
2194
2185
  __privateGet(this, _pzCache)[event.name] = event.variantIds;
2195
2186
  __privateGet(this, _mitt3).emit("personalizationResult", event);
2196
2187
  }
2197
- /**
2198
- * Gets the current canvas data
2199
- */
2200
- getCompositionMetadata() {
2201
- return __privateGet(this, _state).compositionMetadata;
2202
- }
2203
- /**
2204
- * Updates the canvas data and emits a canvasDataUpdated event
2205
- */
2206
- async updateCompositionMetadata(newData) {
2207
- const currentCanvas = __privateGet(this, _state).compositionMetadata || {};
2208
- const updatedCanvas = { ...currentCanvas, ...newData };
2209
- if (!(0, import_lite5.dequal)(currentCanvas, updatedCanvas)) {
2210
- __privateSet(this, _state, {
2211
- ...__privateGet(this, _state),
2212
- compositionMetadata: updatedCanvas
2213
- });
2214
- __privateGet(this, _mitt3).emit("canvasDataUpdated", updatedCanvas);
2215
- __privateGet(this, _mitt3).emit("log", ["info", 4, "Canvas data updated"]);
2216
- }
2217
- }
2218
2188
  };
2219
2189
  _personalizationSelectionAlgorithms = new WeakMap();
2220
2190
  _serverTransitionState = new WeakMap();
@@ -2379,31 +2349,7 @@ var ScriptType = /* @__PURE__ */ ((ScriptType2) => {
2379
2349
  })(ScriptType || {});
2380
2350
  var EdgeNodeTagName = "nesitag";
2381
2351
 
2382
- // src/insights/storage.ts
2383
- var createInsightsStorage = () => {
2384
- const STORAGE_KEY2 = "ufin";
2385
- return {
2386
- get: () => {
2387
- const data = localStorage.getItem(STORAGE_KEY2);
2388
- if (!data) {
2389
- return;
2390
- }
2391
- return JSON.parse(data);
2392
- },
2393
- set: (data) => {
2394
- const toSet = {
2395
- ...data,
2396
- updated: Date.now()
2397
- };
2398
- localStorage.setItem(STORAGE_KEY2, JSON.stringify(toSet));
2399
- },
2400
- clear: () => {
2401
- localStorage.removeItem(STORAGE_KEY2);
2402
- }
2403
- };
2404
- };
2405
-
2406
- // src/insights/types.ts
2352
+ // src/insights/index.ts
2407
2353
  var getBasePayload = () => {
2408
2354
  const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
2409
2355
  const locale = navigator.languages && navigator.languages.length ? navigator.languages[0] : navigator.userLanguage || navigator.language || navigator.browserLanguage || "en";
@@ -2416,34 +2362,13 @@ var getBasePayload = () => {
2416
2362
  href: window.location.href
2417
2363
  };
2418
2364
  };
2419
- var generateVisitorId = async () => {
2420
- return `visitor_${generalRandomId()}`;
2421
- };
2422
- var generateSessionId = async () => {
2423
- return `session_${generalRandomId()}`;
2424
- };
2425
- var generatePageId = () => {
2426
- return `page_${generalRandomId()}`;
2427
- };
2428
- var generalRandomId = () => {
2429
- if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
2430
- const id = crypto.randomUUID();
2431
- return id.replaceAll("-", "").toLowerCase();
2432
- }
2433
- return Math.random().toString(32).substring(2);
2434
- };
2435
-
2436
- // src/insights/v1.ts
2437
2365
  var createInsightsClient = ({ endpoint }) => {
2438
2366
  let endpointUrl;
2439
2367
  const apiKey = endpoint.apiKey;
2440
2368
  const projectId = endpoint.projectId;
2441
2369
  if (endpoint.type === "api") {
2442
2370
  const url = new URL(endpoint.host);
2443
- url.pathname = `/v0/events`;
2444
- if (endpoint.host.includes("tinybird.co")) {
2445
- url.pathname = "/v0/events";
2446
- }
2371
+ url.pathname = "/v0/events";
2447
2372
  url.searchParams.set("name", "analytics_events");
2448
2373
  endpointUrl = url.toString();
2449
2374
  } else {
@@ -2573,7 +2498,38 @@ var createInsightsClient = ({ endpoint }) => {
2573
2498
  }
2574
2499
  };
2575
2500
  };
2576
- 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 = ({
2577
2533
  endpoint,
2578
2534
  sessionDurationSeconds = 30 * 60
2579
2535
  }) => {
@@ -2674,10 +2630,8 @@ var createInsightsV1 = ({
2674
2630
  }
2675
2631
  };
2676
2632
  };
2677
-
2678
- // src/insights/index.ts
2679
2633
  var enableUniformInsights = (options) => {
2680
- const insights = createInsightsV1({
2634
+ const insights = createInsights({
2681
2635
  endpoint: options.endpoint
2682
2636
  });
2683
2637
  let previousUrl = void 0;
@@ -2723,8 +2677,8 @@ var enableUniformInsights = (options) => {
2723
2677
  };
2724
2678
  },
2725
2679
  update: (context) => {
2726
- if (context.url && context.url.toString() !== previousUrl) {
2727
- previousUrl = context.url.toString();
2680
+ if (context.url && context.url !== previousUrl) {
2681
+ previousUrl = context.url;
2728
2682
  insights.pageHit();
2729
2683
  }
2730
2684
  },
@@ -2733,6 +2687,13 @@ var enableUniformInsights = (options) => {
2733
2687
  }
2734
2688
  };
2735
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
+ };
2736
2697
 
2737
2698
  // src/logging/enableConsoleLogDrain.ts
2738
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,10 +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
- // @todo this needs to be fixed, we should provide correct is control as well as canvas data
1912
- control: false,
1913
- compositionMetadata: void 0
1907
+ variantAssigned: true
1914
1908
  });
1915
1909
  });
1916
1910
  const haveQuirksChanged = __privateGet(this, _serverTransitionState) && !dequal5(__privateGet(this, _serverTransitionState).quirks, this.storage.data.quirks);
@@ -1992,7 +1986,7 @@ var Context = class {
1992
1986
  }
1993
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) */
1994
1988
  test(options) {
1995
- var _a, _b, _c, _d, _e;
1989
+ var _a, _b, _c;
1996
1990
  if (options.name === CONTEXTUAL_EDITING_TEST_NAME) {
1997
1991
  const selectedVariant = (_a = options.variations.find((variant) => variant.id === CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID)) != null ? _a : options.variations.at(-1);
1998
1992
  const value2 = {
@@ -2009,9 +2003,7 @@ var Context = class {
2009
2003
  __privateMethod(this, _Context_instances, emitTest_fn).call(this, {
2010
2004
  name: options.name,
2011
2005
  variantId: (_c = (_b = value.result) == null ? void 0 : _b.id) != null ? _c : void 0,
2012
- variantAssigned: value.variantAssigned,
2013
- control: (_e = (_d = value.result) == null ? void 0 : _d.control) != null ? _e : false,
2014
- compositionMetadata: options.compositionMetadata
2006
+ variantAssigned: value.variantAssigned
2015
2007
  });
2016
2008
  return value;
2017
2009
  }
@@ -2040,8 +2032,7 @@ var Context = class {
2040
2032
  control: variation.control
2041
2033
  })),
2042
2034
  control: this.storage.data.controlGroup,
2043
- changed: true,
2044
- compositionMetadata: options.compositionMetadata
2035
+ changed: true
2045
2036
  };
2046
2037
  if (previousPlacement && dequal5(eventData.variantIds, previousPlacement)) {
2047
2038
  eventData.changed = false;
@@ -2101,27 +2092,6 @@ var Context = class {
2101
2092
  __privateGet(this, _pzCache)[event.name] = event.variantIds;
2102
2093
  __privateGet(this, _mitt3).emit("personalizationResult", event);
2103
2094
  }
2104
- /**
2105
- * Gets the current canvas data
2106
- */
2107
- getCompositionMetadata() {
2108
- return __privateGet(this, _state).compositionMetadata;
2109
- }
2110
- /**
2111
- * Updates the canvas data and emits a canvasDataUpdated event
2112
- */
2113
- async updateCompositionMetadata(newData) {
2114
- const currentCanvas = __privateGet(this, _state).compositionMetadata || {};
2115
- const updatedCanvas = { ...currentCanvas, ...newData };
2116
- if (!dequal5(currentCanvas, updatedCanvas)) {
2117
- __privateSet(this, _state, {
2118
- ...__privateGet(this, _state),
2119
- compositionMetadata: updatedCanvas
2120
- });
2121
- __privateGet(this, _mitt3).emit("canvasDataUpdated", updatedCanvas);
2122
- __privateGet(this, _mitt3).emit("log", ["info", 4, "Canvas data updated"]);
2123
- }
2124
- }
2125
2095
  };
2126
2096
  _personalizationSelectionAlgorithms = new WeakMap();
2127
2097
  _serverTransitionState = new WeakMap();
@@ -2286,31 +2256,7 @@ var ScriptType = /* @__PURE__ */ ((ScriptType2) => {
2286
2256
  })(ScriptType || {});
2287
2257
  var EdgeNodeTagName = "nesitag";
2288
2258
 
2289
- // src/insights/storage.ts
2290
- var createInsightsStorage = () => {
2291
- const STORAGE_KEY2 = "ufin";
2292
- return {
2293
- get: () => {
2294
- const data = localStorage.getItem(STORAGE_KEY2);
2295
- if (!data) {
2296
- return;
2297
- }
2298
- return JSON.parse(data);
2299
- },
2300
- set: (data) => {
2301
- const toSet = {
2302
- ...data,
2303
- updated: Date.now()
2304
- };
2305
- localStorage.setItem(STORAGE_KEY2, JSON.stringify(toSet));
2306
- },
2307
- clear: () => {
2308
- localStorage.removeItem(STORAGE_KEY2);
2309
- }
2310
- };
2311
- };
2312
-
2313
- // src/insights/types.ts
2259
+ // src/insights/index.ts
2314
2260
  var getBasePayload = () => {
2315
2261
  const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
2316
2262
  const locale = navigator.languages && navigator.languages.length ? navigator.languages[0] : navigator.userLanguage || navigator.language || navigator.browserLanguage || "en";
@@ -2323,34 +2269,13 @@ var getBasePayload = () => {
2323
2269
  href: window.location.href
2324
2270
  };
2325
2271
  };
2326
- var generateVisitorId = async () => {
2327
- return `visitor_${generalRandomId()}`;
2328
- };
2329
- var generateSessionId = async () => {
2330
- return `session_${generalRandomId()}`;
2331
- };
2332
- var generatePageId = () => {
2333
- return `page_${generalRandomId()}`;
2334
- };
2335
- var generalRandomId = () => {
2336
- if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
2337
- const id = crypto.randomUUID();
2338
- return id.replaceAll("-", "").toLowerCase();
2339
- }
2340
- return Math.random().toString(32).substring(2);
2341
- };
2342
-
2343
- // src/insights/v1.ts
2344
2272
  var createInsightsClient = ({ endpoint }) => {
2345
2273
  let endpointUrl;
2346
2274
  const apiKey = endpoint.apiKey;
2347
2275
  const projectId = endpoint.projectId;
2348
2276
  if (endpoint.type === "api") {
2349
2277
  const url = new URL(endpoint.host);
2350
- url.pathname = `/v0/events`;
2351
- if (endpoint.host.includes("tinybird.co")) {
2352
- url.pathname = "/v0/events";
2353
- }
2278
+ url.pathname = "/v0/events";
2354
2279
  url.searchParams.set("name", "analytics_events");
2355
2280
  endpointUrl = url.toString();
2356
2281
  } else {
@@ -2480,7 +2405,38 @@ var createInsightsClient = ({ endpoint }) => {
2480
2405
  }
2481
2406
  };
2482
2407
  };
2483
- 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 = ({
2484
2440
  endpoint,
2485
2441
  sessionDurationSeconds = 30 * 60
2486
2442
  }) => {
@@ -2581,10 +2537,8 @@ var createInsightsV1 = ({
2581
2537
  }
2582
2538
  };
2583
2539
  };
2584
-
2585
- // src/insights/index.ts
2586
2540
  var enableUniformInsights = (options) => {
2587
- const insights = createInsightsV1({
2541
+ const insights = createInsights({
2588
2542
  endpoint: options.endpoint
2589
2543
  });
2590
2544
  let previousUrl = void 0;
@@ -2630,8 +2584,8 @@ var enableUniformInsights = (options) => {
2630
2584
  };
2631
2585
  },
2632
2586
  update: (context) => {
2633
- if (context.url && context.url.toString() !== previousUrl) {
2634
- previousUrl = context.url.toString();
2587
+ if (context.url && context.url !== previousUrl) {
2588
+ previousUrl = context.url;
2635
2589
  insights.pageHit();
2636
2590
  }
2637
2591
  },
@@ -2640,6 +2594,13 @@ var enableUniformInsights = (options) => {
2640
2594
  }
2641
2595
  };
2642
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
+ };
2643
2604
 
2644
2605
  // src/logging/enableConsoleLogDrain.ts
2645
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: Partial<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: Partial<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.33.1-alpha.54+03ae0b17d0",
3
+ "version": "20.34.1",
4
4
  "description": "Uniform Context core package",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -41,7 +41,7 @@
41
41
  "dev": "run-s update-openapi dev:ts",
42
42
  "dev:ts": "tsup --watch",
43
43
  "clean": "rimraf dist",
44
- "test": "vitest run",
44
+ "test": "vitest",
45
45
  "test:coverage": "vitest run --coverage",
46
46
  "lint": "eslint \"src/**/*.{js,ts,tsx}\"",
47
47
  "format": "prettier --write \"src/**/*.{js,ts,tsx}\"",
@@ -72,5 +72,5 @@
72
72
  "publishConfig": {
73
73
  "access": "public"
74
74
  },
75
- "gitHead": "03ae0b17d098f1a09099ea76cf7625dec9a54b21"
75
+ "gitHead": "e118be221d19f1e59da7c5845bc3e784e0b42cf3"
76
76
  }