@uniformdev/context 20.7.1-alpha.79 → 20.7.1-alpha.83
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/api.d.mts +1 -1
- package/dist/api/api.d.ts +1 -1
- package/dist/index.d.mts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.esm.js +91 -49
- package/dist/index.js +91 -49
- package/dist/index.mjs +91 -49
- package/dist/{types-CzIkFCDD.d.mts → types-CKTfVAJs.d.mts} +62 -3
- package/dist/{types-CzIkFCDD.d.ts → types-CKTfVAJs.d.ts} +62 -3
- package/package.json +4 -4
package/dist/api/api.d.mts
CHANGED
package/dist/api/api.d.ts
CHANGED
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-
|
|
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,
|
|
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-CKTfVAJs.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-CKTfVAJs.mjs';
|
|
3
3
|
import Cookies from 'js-cookie';
|
|
4
4
|
import 'mitt';
|
|
5
5
|
|
|
@@ -230,9 +230,13 @@ type InsightsEndpoint = {
|
|
|
230
230
|
apiKey?: string;
|
|
231
231
|
projectId?: string;
|
|
232
232
|
};
|
|
233
|
+
|
|
233
234
|
type EnableUniformInsightsOptions = {
|
|
234
235
|
endpoint: InsightsEndpoint;
|
|
235
236
|
};
|
|
237
|
+
/**
|
|
238
|
+
* @deprecated Use `import { enableUniformInsights } from '@uniformdev/insights'` instead
|
|
239
|
+
*/
|
|
236
240
|
declare const enableUniformInsights: (options: EnableUniformInsightsOptions) => ContextPlugin;
|
|
237
241
|
|
|
238
242
|
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-
|
|
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,
|
|
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-CKTfVAJs.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-CKTfVAJs.js';
|
|
3
3
|
import Cookies from 'js-cookie';
|
|
4
4
|
import 'mitt';
|
|
5
5
|
|
|
@@ -230,9 +230,13 @@ type InsightsEndpoint = {
|
|
|
230
230
|
apiKey?: string;
|
|
231
231
|
projectId?: string;
|
|
232
232
|
};
|
|
233
|
+
|
|
233
234
|
type EnableUniformInsightsOptions = {
|
|
234
235
|
endpoint: InsightsEndpoint;
|
|
235
236
|
};
|
|
237
|
+
/**
|
|
238
|
+
* @deprecated Use `import { enableUniformInsights } from '@uniformdev/insights'` instead
|
|
239
|
+
*/
|
|
236
240
|
declare const enableUniformInsights: (options: EnableUniformInsightsOptions) => ContextPlugin;
|
|
237
241
|
|
|
238
242
|
type QuickConnectConfig = {
|
package/dist/index.esm.js
CHANGED
|
@@ -227,6 +227,10 @@ var ManifestInstance = class {
|
|
|
227
227
|
}
|
|
228
228
|
return (_d = (_c = __privateGet(this, _mf).pz) == null ? void 0 : _c.enr) == null ? void 0 : _d[scoreKey.substring(0, enrichmentIndex)];
|
|
229
229
|
}
|
|
230
|
+
getAggregateDimensionByKey(scoreKey) {
|
|
231
|
+
var _a, _b;
|
|
232
|
+
return (_b = (_a = __privateGet(this, _mf).pz) == null ? void 0 : _a.agg) == null ? void 0 : _b[scoreKey];
|
|
233
|
+
}
|
|
230
234
|
};
|
|
231
235
|
_mf = new WeakMap();
|
|
232
236
|
_signalInstances = new WeakMap();
|
|
@@ -941,6 +945,9 @@ var testVariations = ({
|
|
|
941
945
|
}
|
|
942
946
|
if (selectedVariant) {
|
|
943
947
|
onLogMessage == null ? void 0 : onLogMessage(["info", 404, selectedVariant.id]);
|
|
948
|
+
if (selectedVariant.control === void 0) {
|
|
949
|
+
selectedVariant.control = variations.findIndex((variation) => variation.id === selectedVariantId) === 0;
|
|
950
|
+
}
|
|
944
951
|
}
|
|
945
952
|
return {
|
|
946
953
|
result: selectedVariant,
|
|
@@ -1905,7 +1912,9 @@ var Context = class {
|
|
|
1905
1912
|
__privateMethod(this, _Context_instances, emitTest_fn).call(this, {
|
|
1906
1913
|
name: testName,
|
|
1907
1914
|
variantId: testVariantId,
|
|
1908
|
-
variantAssigned: true
|
|
1915
|
+
variantAssigned: true,
|
|
1916
|
+
control: false,
|
|
1917
|
+
compositionMetadata: void 0
|
|
1909
1918
|
});
|
|
1910
1919
|
});
|
|
1911
1920
|
const haveQuirksChanged = __privateGet(this, _serverTransitionState) && !dequal5(__privateGet(this, _serverTransitionState).quirks, this.storage.data.quirks);
|
|
@@ -1921,7 +1930,7 @@ var Context = class {
|
|
|
1921
1930
|
if (!plugin.update) {
|
|
1922
1931
|
continue;
|
|
1923
1932
|
}
|
|
1924
|
-
await plugin.update(newData);
|
|
1933
|
+
await plugin.update(newData, __privateGet(this, _scores));
|
|
1925
1934
|
}
|
|
1926
1935
|
}
|
|
1927
1936
|
(_e = __privateGet(this, _commands)) == null ? void 0 : _e.push(...commands);
|
|
@@ -1987,7 +1996,7 @@ var Context = class {
|
|
|
1987
1996
|
}
|
|
1988
1997
|
/** 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) */
|
|
1989
1998
|
test(options) {
|
|
1990
|
-
var _a, _b, _c;
|
|
1999
|
+
var _a, _b, _c, _d, _e;
|
|
1991
2000
|
if (options.name === CONTEXTUAL_EDITING_TEST_NAME) {
|
|
1992
2001
|
const selectedVariant = (_a = options.variations.find((variant) => variant.id === CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID)) != null ? _a : options.variations.at(-1);
|
|
1993
2002
|
const value2 = {
|
|
@@ -2004,7 +2013,9 @@ var Context = class {
|
|
|
2004
2013
|
__privateMethod(this, _Context_instances, emitTest_fn).call(this, {
|
|
2005
2014
|
name: options.name,
|
|
2006
2015
|
variantId: (_c = (_b = value.result) == null ? void 0 : _b.id) != null ? _c : void 0,
|
|
2007
|
-
variantAssigned: value.variantAssigned
|
|
2016
|
+
variantAssigned: value.variantAssigned,
|
|
2017
|
+
control: (_e = (_d = value.result) == null ? void 0 : _d.control) != null ? _e : false,
|
|
2018
|
+
compositionMetadata: options.compositionMetadata
|
|
2008
2019
|
});
|
|
2009
2020
|
return value;
|
|
2010
2021
|
}
|
|
@@ -2033,7 +2044,8 @@ var Context = class {
|
|
|
2033
2044
|
control: variation.control
|
|
2034
2045
|
})),
|
|
2035
2046
|
control: this.storage.data.controlGroup,
|
|
2036
|
-
changed: true
|
|
2047
|
+
changed: true,
|
|
2048
|
+
compositionMetadata: options.compositionMetadata
|
|
2037
2049
|
};
|
|
2038
2050
|
if (previousPlacement && dequal5(eventData.variantIds, previousPlacement)) {
|
|
2039
2051
|
eventData.changed = false;
|
|
@@ -2093,6 +2105,27 @@ var Context = class {
|
|
|
2093
2105
|
__privateGet(this, _pzCache)[event.name] = event.variantIds;
|
|
2094
2106
|
__privateGet(this, _mitt3).emit("personalizationResult", event);
|
|
2095
2107
|
}
|
|
2108
|
+
/**
|
|
2109
|
+
* Gets the current canvas data
|
|
2110
|
+
*/
|
|
2111
|
+
getCompositionMetadata() {
|
|
2112
|
+
return __privateGet(this, _state).compositionMetadata;
|
|
2113
|
+
}
|
|
2114
|
+
/**
|
|
2115
|
+
* Updates the canvas data and emits a canvasDataUpdated event
|
|
2116
|
+
*/
|
|
2117
|
+
async updateCompositionMetadata(newData) {
|
|
2118
|
+
const currentCanvas = __privateGet(this, _state).compositionMetadata || {};
|
|
2119
|
+
const updatedCanvas = { ...currentCanvas, ...newData };
|
|
2120
|
+
if (!dequal5(currentCanvas, updatedCanvas)) {
|
|
2121
|
+
__privateSet(this, _state, {
|
|
2122
|
+
...__privateGet(this, _state),
|
|
2123
|
+
compositionMetadata: updatedCanvas
|
|
2124
|
+
});
|
|
2125
|
+
__privateGet(this, _mitt3).emit("canvasDataUpdated", updatedCanvas);
|
|
2126
|
+
__privateGet(this, _mitt3).emit("log", ["info", 4, "Canvas data updated"]);
|
|
2127
|
+
}
|
|
2128
|
+
}
|
|
2096
2129
|
};
|
|
2097
2130
|
_personalizationSelectionAlgorithms = new WeakMap();
|
|
2098
2131
|
_serverTransitionState = new WeakMap();
|
|
@@ -2257,7 +2290,31 @@ var ScriptType = /* @__PURE__ */ ((ScriptType2) => {
|
|
|
2257
2290
|
})(ScriptType || {});
|
|
2258
2291
|
var EdgeNodeTagName = "nesitag";
|
|
2259
2292
|
|
|
2260
|
-
// src/insights/
|
|
2293
|
+
// src/insights/storage.ts
|
|
2294
|
+
var createInsightsStorage = () => {
|
|
2295
|
+
const STORAGE_KEY2 = "ufin";
|
|
2296
|
+
return {
|
|
2297
|
+
get: () => {
|
|
2298
|
+
const data = localStorage.getItem(STORAGE_KEY2);
|
|
2299
|
+
if (!data) {
|
|
2300
|
+
return;
|
|
2301
|
+
}
|
|
2302
|
+
return JSON.parse(data);
|
|
2303
|
+
},
|
|
2304
|
+
set: (data) => {
|
|
2305
|
+
const toSet = {
|
|
2306
|
+
...data,
|
|
2307
|
+
updated: Date.now()
|
|
2308
|
+
};
|
|
2309
|
+
localStorage.setItem(STORAGE_KEY2, JSON.stringify(toSet));
|
|
2310
|
+
},
|
|
2311
|
+
clear: () => {
|
|
2312
|
+
localStorage.removeItem(STORAGE_KEY2);
|
|
2313
|
+
}
|
|
2314
|
+
};
|
|
2315
|
+
};
|
|
2316
|
+
|
|
2317
|
+
// src/insights/types.ts
|
|
2261
2318
|
var getBasePayload = () => {
|
|
2262
2319
|
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
2263
2320
|
const locale = navigator.languages && navigator.languages.length ? navigator.languages[0] : navigator.userLanguage || navigator.language || navigator.browserLanguage || "en";
|
|
@@ -2270,13 +2327,34 @@ var getBasePayload = () => {
|
|
|
2270
2327
|
href: window.location.href
|
|
2271
2328
|
};
|
|
2272
2329
|
};
|
|
2330
|
+
var generateVisitorId = () => {
|
|
2331
|
+
return `visitor_${generalRandomId()}`;
|
|
2332
|
+
};
|
|
2333
|
+
var generateSessionId = () => {
|
|
2334
|
+
return `session_${generalRandomId()}`;
|
|
2335
|
+
};
|
|
2336
|
+
var generatePageId = () => {
|
|
2337
|
+
return `page_${generalRandomId()}`;
|
|
2338
|
+
};
|
|
2339
|
+
var generalRandomId = () => {
|
|
2340
|
+
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
2341
|
+
const id = crypto.randomUUID();
|
|
2342
|
+
return id.replaceAll("-", "").toLowerCase();
|
|
2343
|
+
}
|
|
2344
|
+
return Math.random().toString(32).substring(2);
|
|
2345
|
+
};
|
|
2346
|
+
|
|
2347
|
+
// src/insights/v1.ts
|
|
2273
2348
|
var createInsightsClient = ({ endpoint }) => {
|
|
2274
2349
|
let endpointUrl;
|
|
2275
2350
|
const apiKey = endpoint.apiKey;
|
|
2276
2351
|
const projectId = endpoint.projectId;
|
|
2277
2352
|
if (endpoint.type === "api") {
|
|
2278
2353
|
const url = new URL(endpoint.host);
|
|
2279
|
-
url.pathname =
|
|
2354
|
+
url.pathname = `/v0/events`;
|
|
2355
|
+
if (endpoint.host.includes("tinybird.co")) {
|
|
2356
|
+
url.pathname = "/v0/events";
|
|
2357
|
+
}
|
|
2280
2358
|
url.searchParams.set("name", "analytics_events");
|
|
2281
2359
|
endpointUrl = url.toString();
|
|
2282
2360
|
} else {
|
|
@@ -2406,38 +2484,7 @@ var createInsightsClient = ({ endpoint }) => {
|
|
|
2406
2484
|
}
|
|
2407
2485
|
};
|
|
2408
2486
|
};
|
|
2409
|
-
var
|
|
2410
|
-
const STORAGE_KEY2 = "ufin";
|
|
2411
|
-
return {
|
|
2412
|
-
get: () => {
|
|
2413
|
-
const data = localStorage.getItem(STORAGE_KEY2);
|
|
2414
|
-
if (!data) {
|
|
2415
|
-
return;
|
|
2416
|
-
}
|
|
2417
|
-
return JSON.parse(data);
|
|
2418
|
-
},
|
|
2419
|
-
set: (data) => {
|
|
2420
|
-
const toSet = {
|
|
2421
|
-
...data,
|
|
2422
|
-
updated: Date.now()
|
|
2423
|
-
};
|
|
2424
|
-
localStorage.setItem(STORAGE_KEY2, JSON.stringify(toSet));
|
|
2425
|
-
},
|
|
2426
|
-
clear: () => {
|
|
2427
|
-
localStorage.removeItem(STORAGE_KEY2);
|
|
2428
|
-
}
|
|
2429
|
-
};
|
|
2430
|
-
};
|
|
2431
|
-
var generateVisitorId = () => {
|
|
2432
|
-
return `visitor_${generalRandomId()}`;
|
|
2433
|
-
};
|
|
2434
|
-
var generateSessionId = () => {
|
|
2435
|
-
return `session_${generalRandomId()}`;
|
|
2436
|
-
};
|
|
2437
|
-
var generatePageId = () => {
|
|
2438
|
-
return `page_${generalRandomId()}`;
|
|
2439
|
-
};
|
|
2440
|
-
var createInsights = ({
|
|
2487
|
+
var createInsightsV1 = ({
|
|
2441
2488
|
endpoint,
|
|
2442
2489
|
sessionDurationSeconds = 30 * 60
|
|
2443
2490
|
}) => {
|
|
@@ -2538,8 +2585,10 @@ var createInsights = ({
|
|
|
2538
2585
|
}
|
|
2539
2586
|
};
|
|
2540
2587
|
};
|
|
2588
|
+
|
|
2589
|
+
// src/insights/index.ts
|
|
2541
2590
|
var enableUniformInsights = (options) => {
|
|
2542
|
-
const insights =
|
|
2591
|
+
const insights = createInsightsV1({
|
|
2543
2592
|
endpoint: options.endpoint
|
|
2544
2593
|
});
|
|
2545
2594
|
let previousUrl = void 0;
|
|
@@ -2585,8 +2634,8 @@ var enableUniformInsights = (options) => {
|
|
|
2585
2634
|
};
|
|
2586
2635
|
},
|
|
2587
2636
|
update: (context) => {
|
|
2588
|
-
if (context.url && context.url !== previousUrl) {
|
|
2589
|
-
previousUrl = context.url;
|
|
2637
|
+
if (context.url && context.url.toString() !== previousUrl) {
|
|
2638
|
+
previousUrl = context.url.toString();
|
|
2590
2639
|
insights.pageHit();
|
|
2591
2640
|
}
|
|
2592
2641
|
},
|
|
@@ -2595,13 +2644,6 @@ var enableUniformInsights = (options) => {
|
|
|
2595
2644
|
}
|
|
2596
2645
|
};
|
|
2597
2646
|
};
|
|
2598
|
-
var generalRandomId = () => {
|
|
2599
|
-
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
2600
|
-
const id = crypto.randomUUID();
|
|
2601
|
-
return id.replaceAll("-", "").toLowerCase();
|
|
2602
|
-
}
|
|
2603
|
-
return Math.random().toString(32).substring(2);
|
|
2604
|
-
};
|
|
2605
2647
|
|
|
2606
2648
|
// src/logging/enableConsoleLogDrain.ts
|
|
2607
2649
|
import rfdc2 from "rfdc";
|
package/dist/index.js
CHANGED
|
@@ -321,6 +321,10 @@ var ManifestInstance = class {
|
|
|
321
321
|
}
|
|
322
322
|
return (_d = (_c = __privateGet(this, _mf).pz) == null ? void 0 : _c.enr) == null ? void 0 : _d[scoreKey.substring(0, enrichmentIndex)];
|
|
323
323
|
}
|
|
324
|
+
getAggregateDimensionByKey(scoreKey) {
|
|
325
|
+
var _a, _b;
|
|
326
|
+
return (_b = (_a = __privateGet(this, _mf).pz) == null ? void 0 : _a.agg) == null ? void 0 : _b[scoreKey];
|
|
327
|
+
}
|
|
324
328
|
};
|
|
325
329
|
_mf = new WeakMap();
|
|
326
330
|
_signalInstances = new WeakMap();
|
|
@@ -1035,6 +1039,9 @@ var testVariations = ({
|
|
|
1035
1039
|
}
|
|
1036
1040
|
if (selectedVariant) {
|
|
1037
1041
|
onLogMessage == null ? void 0 : onLogMessage(["info", 404, selectedVariant.id]);
|
|
1042
|
+
if (selectedVariant.control === void 0) {
|
|
1043
|
+
selectedVariant.control = variations.findIndex((variation) => variation.id === selectedVariantId) === 0;
|
|
1044
|
+
}
|
|
1038
1045
|
}
|
|
1039
1046
|
return {
|
|
1040
1047
|
result: selectedVariant,
|
|
@@ -1999,7 +2006,9 @@ var Context = class {
|
|
|
1999
2006
|
__privateMethod(this, _Context_instances, emitTest_fn).call(this, {
|
|
2000
2007
|
name: testName,
|
|
2001
2008
|
variantId: testVariantId,
|
|
2002
|
-
variantAssigned: true
|
|
2009
|
+
variantAssigned: true,
|
|
2010
|
+
control: false,
|
|
2011
|
+
compositionMetadata: void 0
|
|
2003
2012
|
});
|
|
2004
2013
|
});
|
|
2005
2014
|
const haveQuirksChanged = __privateGet(this, _serverTransitionState) && !(0, import_lite5.dequal)(__privateGet(this, _serverTransitionState).quirks, this.storage.data.quirks);
|
|
@@ -2015,7 +2024,7 @@ var Context = class {
|
|
|
2015
2024
|
if (!plugin.update) {
|
|
2016
2025
|
continue;
|
|
2017
2026
|
}
|
|
2018
|
-
await plugin.update(newData);
|
|
2027
|
+
await plugin.update(newData, __privateGet(this, _scores));
|
|
2019
2028
|
}
|
|
2020
2029
|
}
|
|
2021
2030
|
(_e = __privateGet(this, _commands)) == null ? void 0 : _e.push(...commands);
|
|
@@ -2081,7 +2090,7 @@ var Context = class {
|
|
|
2081
2090
|
}
|
|
2082
2091
|
/** 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) */
|
|
2083
2092
|
test(options) {
|
|
2084
|
-
var _a, _b, _c;
|
|
2093
|
+
var _a, _b, _c, _d, _e;
|
|
2085
2094
|
if (options.name === CONTEXTUAL_EDITING_TEST_NAME) {
|
|
2086
2095
|
const selectedVariant = (_a = options.variations.find((variant) => variant.id === CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID)) != null ? _a : options.variations.at(-1);
|
|
2087
2096
|
const value2 = {
|
|
@@ -2098,7 +2107,9 @@ var Context = class {
|
|
|
2098
2107
|
__privateMethod(this, _Context_instances, emitTest_fn).call(this, {
|
|
2099
2108
|
name: options.name,
|
|
2100
2109
|
variantId: (_c = (_b = value.result) == null ? void 0 : _b.id) != null ? _c : void 0,
|
|
2101
|
-
variantAssigned: value.variantAssigned
|
|
2110
|
+
variantAssigned: value.variantAssigned,
|
|
2111
|
+
control: (_e = (_d = value.result) == null ? void 0 : _d.control) != null ? _e : false,
|
|
2112
|
+
compositionMetadata: options.compositionMetadata
|
|
2102
2113
|
});
|
|
2103
2114
|
return value;
|
|
2104
2115
|
}
|
|
@@ -2127,7 +2138,8 @@ var Context = class {
|
|
|
2127
2138
|
control: variation.control
|
|
2128
2139
|
})),
|
|
2129
2140
|
control: this.storage.data.controlGroup,
|
|
2130
|
-
changed: true
|
|
2141
|
+
changed: true,
|
|
2142
|
+
compositionMetadata: options.compositionMetadata
|
|
2131
2143
|
};
|
|
2132
2144
|
if (previousPlacement && (0, import_lite5.dequal)(eventData.variantIds, previousPlacement)) {
|
|
2133
2145
|
eventData.changed = false;
|
|
@@ -2187,6 +2199,27 @@ var Context = class {
|
|
|
2187
2199
|
__privateGet(this, _pzCache)[event.name] = event.variantIds;
|
|
2188
2200
|
__privateGet(this, _mitt3).emit("personalizationResult", event);
|
|
2189
2201
|
}
|
|
2202
|
+
/**
|
|
2203
|
+
* Gets the current canvas data
|
|
2204
|
+
*/
|
|
2205
|
+
getCompositionMetadata() {
|
|
2206
|
+
return __privateGet(this, _state).compositionMetadata;
|
|
2207
|
+
}
|
|
2208
|
+
/**
|
|
2209
|
+
* Updates the canvas data and emits a canvasDataUpdated event
|
|
2210
|
+
*/
|
|
2211
|
+
async updateCompositionMetadata(newData) {
|
|
2212
|
+
const currentCanvas = __privateGet(this, _state).compositionMetadata || {};
|
|
2213
|
+
const updatedCanvas = { ...currentCanvas, ...newData };
|
|
2214
|
+
if (!(0, import_lite5.dequal)(currentCanvas, updatedCanvas)) {
|
|
2215
|
+
__privateSet(this, _state, {
|
|
2216
|
+
...__privateGet(this, _state),
|
|
2217
|
+
compositionMetadata: updatedCanvas
|
|
2218
|
+
});
|
|
2219
|
+
__privateGet(this, _mitt3).emit("canvasDataUpdated", updatedCanvas);
|
|
2220
|
+
__privateGet(this, _mitt3).emit("log", ["info", 4, "Canvas data updated"]);
|
|
2221
|
+
}
|
|
2222
|
+
}
|
|
2190
2223
|
};
|
|
2191
2224
|
_personalizationSelectionAlgorithms = new WeakMap();
|
|
2192
2225
|
_serverTransitionState = new WeakMap();
|
|
@@ -2351,7 +2384,31 @@ var ScriptType = /* @__PURE__ */ ((ScriptType2) => {
|
|
|
2351
2384
|
})(ScriptType || {});
|
|
2352
2385
|
var EdgeNodeTagName = "nesitag";
|
|
2353
2386
|
|
|
2354
|
-
// src/insights/
|
|
2387
|
+
// src/insights/storage.ts
|
|
2388
|
+
var createInsightsStorage = () => {
|
|
2389
|
+
const STORAGE_KEY2 = "ufin";
|
|
2390
|
+
return {
|
|
2391
|
+
get: () => {
|
|
2392
|
+
const data = localStorage.getItem(STORAGE_KEY2);
|
|
2393
|
+
if (!data) {
|
|
2394
|
+
return;
|
|
2395
|
+
}
|
|
2396
|
+
return JSON.parse(data);
|
|
2397
|
+
},
|
|
2398
|
+
set: (data) => {
|
|
2399
|
+
const toSet = {
|
|
2400
|
+
...data,
|
|
2401
|
+
updated: Date.now()
|
|
2402
|
+
};
|
|
2403
|
+
localStorage.setItem(STORAGE_KEY2, JSON.stringify(toSet));
|
|
2404
|
+
},
|
|
2405
|
+
clear: () => {
|
|
2406
|
+
localStorage.removeItem(STORAGE_KEY2);
|
|
2407
|
+
}
|
|
2408
|
+
};
|
|
2409
|
+
};
|
|
2410
|
+
|
|
2411
|
+
// src/insights/types.ts
|
|
2355
2412
|
var getBasePayload = () => {
|
|
2356
2413
|
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
2357
2414
|
const locale = navigator.languages && navigator.languages.length ? navigator.languages[0] : navigator.userLanguage || navigator.language || navigator.browserLanguage || "en";
|
|
@@ -2364,13 +2421,34 @@ var getBasePayload = () => {
|
|
|
2364
2421
|
href: window.location.href
|
|
2365
2422
|
};
|
|
2366
2423
|
};
|
|
2424
|
+
var generateVisitorId = () => {
|
|
2425
|
+
return `visitor_${generalRandomId()}`;
|
|
2426
|
+
};
|
|
2427
|
+
var generateSessionId = () => {
|
|
2428
|
+
return `session_${generalRandomId()}`;
|
|
2429
|
+
};
|
|
2430
|
+
var generatePageId = () => {
|
|
2431
|
+
return `page_${generalRandomId()}`;
|
|
2432
|
+
};
|
|
2433
|
+
var generalRandomId = () => {
|
|
2434
|
+
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
2435
|
+
const id = crypto.randomUUID();
|
|
2436
|
+
return id.replaceAll("-", "").toLowerCase();
|
|
2437
|
+
}
|
|
2438
|
+
return Math.random().toString(32).substring(2);
|
|
2439
|
+
};
|
|
2440
|
+
|
|
2441
|
+
// src/insights/v1.ts
|
|
2367
2442
|
var createInsightsClient = ({ endpoint }) => {
|
|
2368
2443
|
let endpointUrl;
|
|
2369
2444
|
const apiKey = endpoint.apiKey;
|
|
2370
2445
|
const projectId = endpoint.projectId;
|
|
2371
2446
|
if (endpoint.type === "api") {
|
|
2372
2447
|
const url = new URL(endpoint.host);
|
|
2373
|
-
url.pathname =
|
|
2448
|
+
url.pathname = `/v0/events`;
|
|
2449
|
+
if (endpoint.host.includes("tinybird.co")) {
|
|
2450
|
+
url.pathname = "/v0/events";
|
|
2451
|
+
}
|
|
2374
2452
|
url.searchParams.set("name", "analytics_events");
|
|
2375
2453
|
endpointUrl = url.toString();
|
|
2376
2454
|
} else {
|
|
@@ -2500,38 +2578,7 @@ var createInsightsClient = ({ endpoint }) => {
|
|
|
2500
2578
|
}
|
|
2501
2579
|
};
|
|
2502
2580
|
};
|
|
2503
|
-
var
|
|
2504
|
-
const STORAGE_KEY2 = "ufin";
|
|
2505
|
-
return {
|
|
2506
|
-
get: () => {
|
|
2507
|
-
const data = localStorage.getItem(STORAGE_KEY2);
|
|
2508
|
-
if (!data) {
|
|
2509
|
-
return;
|
|
2510
|
-
}
|
|
2511
|
-
return JSON.parse(data);
|
|
2512
|
-
},
|
|
2513
|
-
set: (data) => {
|
|
2514
|
-
const toSet = {
|
|
2515
|
-
...data,
|
|
2516
|
-
updated: Date.now()
|
|
2517
|
-
};
|
|
2518
|
-
localStorage.setItem(STORAGE_KEY2, JSON.stringify(toSet));
|
|
2519
|
-
},
|
|
2520
|
-
clear: () => {
|
|
2521
|
-
localStorage.removeItem(STORAGE_KEY2);
|
|
2522
|
-
}
|
|
2523
|
-
};
|
|
2524
|
-
};
|
|
2525
|
-
var generateVisitorId = () => {
|
|
2526
|
-
return `visitor_${generalRandomId()}`;
|
|
2527
|
-
};
|
|
2528
|
-
var generateSessionId = () => {
|
|
2529
|
-
return `session_${generalRandomId()}`;
|
|
2530
|
-
};
|
|
2531
|
-
var generatePageId = () => {
|
|
2532
|
-
return `page_${generalRandomId()}`;
|
|
2533
|
-
};
|
|
2534
|
-
var createInsights = ({
|
|
2581
|
+
var createInsightsV1 = ({
|
|
2535
2582
|
endpoint,
|
|
2536
2583
|
sessionDurationSeconds = 30 * 60
|
|
2537
2584
|
}) => {
|
|
@@ -2632,8 +2679,10 @@ var createInsights = ({
|
|
|
2632
2679
|
}
|
|
2633
2680
|
};
|
|
2634
2681
|
};
|
|
2682
|
+
|
|
2683
|
+
// src/insights/index.ts
|
|
2635
2684
|
var enableUniformInsights = (options) => {
|
|
2636
|
-
const insights =
|
|
2685
|
+
const insights = createInsightsV1({
|
|
2637
2686
|
endpoint: options.endpoint
|
|
2638
2687
|
});
|
|
2639
2688
|
let previousUrl = void 0;
|
|
@@ -2679,8 +2728,8 @@ var enableUniformInsights = (options) => {
|
|
|
2679
2728
|
};
|
|
2680
2729
|
},
|
|
2681
2730
|
update: (context) => {
|
|
2682
|
-
if (context.url && context.url !== previousUrl) {
|
|
2683
|
-
previousUrl = context.url;
|
|
2731
|
+
if (context.url && context.url.toString() !== previousUrl) {
|
|
2732
|
+
previousUrl = context.url.toString();
|
|
2684
2733
|
insights.pageHit();
|
|
2685
2734
|
}
|
|
2686
2735
|
},
|
|
@@ -2689,13 +2738,6 @@ var enableUniformInsights = (options) => {
|
|
|
2689
2738
|
}
|
|
2690
2739
|
};
|
|
2691
2740
|
};
|
|
2692
|
-
var generalRandomId = () => {
|
|
2693
|
-
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
2694
|
-
const id = crypto.randomUUID();
|
|
2695
|
-
return id.replaceAll("-", "").toLowerCase();
|
|
2696
|
-
}
|
|
2697
|
-
return Math.random().toString(32).substring(2);
|
|
2698
|
-
};
|
|
2699
2741
|
|
|
2700
2742
|
// src/logging/enableConsoleLogDrain.ts
|
|
2701
2743
|
var import_rfdc2 = __toESM(require("rfdc"));
|
package/dist/index.mjs
CHANGED
|
@@ -227,6 +227,10 @@ var ManifestInstance = class {
|
|
|
227
227
|
}
|
|
228
228
|
return (_d = (_c = __privateGet(this, _mf).pz) == null ? void 0 : _c.enr) == null ? void 0 : _d[scoreKey.substring(0, enrichmentIndex)];
|
|
229
229
|
}
|
|
230
|
+
getAggregateDimensionByKey(scoreKey) {
|
|
231
|
+
var _a, _b;
|
|
232
|
+
return (_b = (_a = __privateGet(this, _mf).pz) == null ? void 0 : _a.agg) == null ? void 0 : _b[scoreKey];
|
|
233
|
+
}
|
|
230
234
|
};
|
|
231
235
|
_mf = new WeakMap();
|
|
232
236
|
_signalInstances = new WeakMap();
|
|
@@ -941,6 +945,9 @@ var testVariations = ({
|
|
|
941
945
|
}
|
|
942
946
|
if (selectedVariant) {
|
|
943
947
|
onLogMessage == null ? void 0 : onLogMessage(["info", 404, selectedVariant.id]);
|
|
948
|
+
if (selectedVariant.control === void 0) {
|
|
949
|
+
selectedVariant.control = variations.findIndex((variation) => variation.id === selectedVariantId) === 0;
|
|
950
|
+
}
|
|
944
951
|
}
|
|
945
952
|
return {
|
|
946
953
|
result: selectedVariant,
|
|
@@ -1905,7 +1912,9 @@ var Context = class {
|
|
|
1905
1912
|
__privateMethod(this, _Context_instances, emitTest_fn).call(this, {
|
|
1906
1913
|
name: testName,
|
|
1907
1914
|
variantId: testVariantId,
|
|
1908
|
-
variantAssigned: true
|
|
1915
|
+
variantAssigned: true,
|
|
1916
|
+
control: false,
|
|
1917
|
+
compositionMetadata: void 0
|
|
1909
1918
|
});
|
|
1910
1919
|
});
|
|
1911
1920
|
const haveQuirksChanged = __privateGet(this, _serverTransitionState) && !dequal5(__privateGet(this, _serverTransitionState).quirks, this.storage.data.quirks);
|
|
@@ -1921,7 +1930,7 @@ var Context = class {
|
|
|
1921
1930
|
if (!plugin.update) {
|
|
1922
1931
|
continue;
|
|
1923
1932
|
}
|
|
1924
|
-
await plugin.update(newData);
|
|
1933
|
+
await plugin.update(newData, __privateGet(this, _scores));
|
|
1925
1934
|
}
|
|
1926
1935
|
}
|
|
1927
1936
|
(_e = __privateGet(this, _commands)) == null ? void 0 : _e.push(...commands);
|
|
@@ -1987,7 +1996,7 @@ var Context = class {
|
|
|
1987
1996
|
}
|
|
1988
1997
|
/** 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) */
|
|
1989
1998
|
test(options) {
|
|
1990
|
-
var _a, _b, _c;
|
|
1999
|
+
var _a, _b, _c, _d, _e;
|
|
1991
2000
|
if (options.name === CONTEXTUAL_EDITING_TEST_NAME) {
|
|
1992
2001
|
const selectedVariant = (_a = options.variations.find((variant) => variant.id === CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID)) != null ? _a : options.variations.at(-1);
|
|
1993
2002
|
const value2 = {
|
|
@@ -2004,7 +2013,9 @@ var Context = class {
|
|
|
2004
2013
|
__privateMethod(this, _Context_instances, emitTest_fn).call(this, {
|
|
2005
2014
|
name: options.name,
|
|
2006
2015
|
variantId: (_c = (_b = value.result) == null ? void 0 : _b.id) != null ? _c : void 0,
|
|
2007
|
-
variantAssigned: value.variantAssigned
|
|
2016
|
+
variantAssigned: value.variantAssigned,
|
|
2017
|
+
control: (_e = (_d = value.result) == null ? void 0 : _d.control) != null ? _e : false,
|
|
2018
|
+
compositionMetadata: options.compositionMetadata
|
|
2008
2019
|
});
|
|
2009
2020
|
return value;
|
|
2010
2021
|
}
|
|
@@ -2033,7 +2044,8 @@ var Context = class {
|
|
|
2033
2044
|
control: variation.control
|
|
2034
2045
|
})),
|
|
2035
2046
|
control: this.storage.data.controlGroup,
|
|
2036
|
-
changed: true
|
|
2047
|
+
changed: true,
|
|
2048
|
+
compositionMetadata: options.compositionMetadata
|
|
2037
2049
|
};
|
|
2038
2050
|
if (previousPlacement && dequal5(eventData.variantIds, previousPlacement)) {
|
|
2039
2051
|
eventData.changed = false;
|
|
@@ -2093,6 +2105,27 @@ var Context = class {
|
|
|
2093
2105
|
__privateGet(this, _pzCache)[event.name] = event.variantIds;
|
|
2094
2106
|
__privateGet(this, _mitt3).emit("personalizationResult", event);
|
|
2095
2107
|
}
|
|
2108
|
+
/**
|
|
2109
|
+
* Gets the current canvas data
|
|
2110
|
+
*/
|
|
2111
|
+
getCompositionMetadata() {
|
|
2112
|
+
return __privateGet(this, _state).compositionMetadata;
|
|
2113
|
+
}
|
|
2114
|
+
/**
|
|
2115
|
+
* Updates the canvas data and emits a canvasDataUpdated event
|
|
2116
|
+
*/
|
|
2117
|
+
async updateCompositionMetadata(newData) {
|
|
2118
|
+
const currentCanvas = __privateGet(this, _state).compositionMetadata || {};
|
|
2119
|
+
const updatedCanvas = { ...currentCanvas, ...newData };
|
|
2120
|
+
if (!dequal5(currentCanvas, updatedCanvas)) {
|
|
2121
|
+
__privateSet(this, _state, {
|
|
2122
|
+
...__privateGet(this, _state),
|
|
2123
|
+
compositionMetadata: updatedCanvas
|
|
2124
|
+
});
|
|
2125
|
+
__privateGet(this, _mitt3).emit("canvasDataUpdated", updatedCanvas);
|
|
2126
|
+
__privateGet(this, _mitt3).emit("log", ["info", 4, "Canvas data updated"]);
|
|
2127
|
+
}
|
|
2128
|
+
}
|
|
2096
2129
|
};
|
|
2097
2130
|
_personalizationSelectionAlgorithms = new WeakMap();
|
|
2098
2131
|
_serverTransitionState = new WeakMap();
|
|
@@ -2257,7 +2290,31 @@ var ScriptType = /* @__PURE__ */ ((ScriptType2) => {
|
|
|
2257
2290
|
})(ScriptType || {});
|
|
2258
2291
|
var EdgeNodeTagName = "nesitag";
|
|
2259
2292
|
|
|
2260
|
-
// src/insights/
|
|
2293
|
+
// src/insights/storage.ts
|
|
2294
|
+
var createInsightsStorage = () => {
|
|
2295
|
+
const STORAGE_KEY2 = "ufin";
|
|
2296
|
+
return {
|
|
2297
|
+
get: () => {
|
|
2298
|
+
const data = localStorage.getItem(STORAGE_KEY2);
|
|
2299
|
+
if (!data) {
|
|
2300
|
+
return;
|
|
2301
|
+
}
|
|
2302
|
+
return JSON.parse(data);
|
|
2303
|
+
},
|
|
2304
|
+
set: (data) => {
|
|
2305
|
+
const toSet = {
|
|
2306
|
+
...data,
|
|
2307
|
+
updated: Date.now()
|
|
2308
|
+
};
|
|
2309
|
+
localStorage.setItem(STORAGE_KEY2, JSON.stringify(toSet));
|
|
2310
|
+
},
|
|
2311
|
+
clear: () => {
|
|
2312
|
+
localStorage.removeItem(STORAGE_KEY2);
|
|
2313
|
+
}
|
|
2314
|
+
};
|
|
2315
|
+
};
|
|
2316
|
+
|
|
2317
|
+
// src/insights/types.ts
|
|
2261
2318
|
var getBasePayload = () => {
|
|
2262
2319
|
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
2263
2320
|
const locale = navigator.languages && navigator.languages.length ? navigator.languages[0] : navigator.userLanguage || navigator.language || navigator.browserLanguage || "en";
|
|
@@ -2270,13 +2327,34 @@ var getBasePayload = () => {
|
|
|
2270
2327
|
href: window.location.href
|
|
2271
2328
|
};
|
|
2272
2329
|
};
|
|
2330
|
+
var generateVisitorId = () => {
|
|
2331
|
+
return `visitor_${generalRandomId()}`;
|
|
2332
|
+
};
|
|
2333
|
+
var generateSessionId = () => {
|
|
2334
|
+
return `session_${generalRandomId()}`;
|
|
2335
|
+
};
|
|
2336
|
+
var generatePageId = () => {
|
|
2337
|
+
return `page_${generalRandomId()}`;
|
|
2338
|
+
};
|
|
2339
|
+
var generalRandomId = () => {
|
|
2340
|
+
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
2341
|
+
const id = crypto.randomUUID();
|
|
2342
|
+
return id.replaceAll("-", "").toLowerCase();
|
|
2343
|
+
}
|
|
2344
|
+
return Math.random().toString(32).substring(2);
|
|
2345
|
+
};
|
|
2346
|
+
|
|
2347
|
+
// src/insights/v1.ts
|
|
2273
2348
|
var createInsightsClient = ({ endpoint }) => {
|
|
2274
2349
|
let endpointUrl;
|
|
2275
2350
|
const apiKey = endpoint.apiKey;
|
|
2276
2351
|
const projectId = endpoint.projectId;
|
|
2277
2352
|
if (endpoint.type === "api") {
|
|
2278
2353
|
const url = new URL(endpoint.host);
|
|
2279
|
-
url.pathname =
|
|
2354
|
+
url.pathname = `/v0/events`;
|
|
2355
|
+
if (endpoint.host.includes("tinybird.co")) {
|
|
2356
|
+
url.pathname = "/v0/events";
|
|
2357
|
+
}
|
|
2280
2358
|
url.searchParams.set("name", "analytics_events");
|
|
2281
2359
|
endpointUrl = url.toString();
|
|
2282
2360
|
} else {
|
|
@@ -2406,38 +2484,7 @@ var createInsightsClient = ({ endpoint }) => {
|
|
|
2406
2484
|
}
|
|
2407
2485
|
};
|
|
2408
2486
|
};
|
|
2409
|
-
var
|
|
2410
|
-
const STORAGE_KEY2 = "ufin";
|
|
2411
|
-
return {
|
|
2412
|
-
get: () => {
|
|
2413
|
-
const data = localStorage.getItem(STORAGE_KEY2);
|
|
2414
|
-
if (!data) {
|
|
2415
|
-
return;
|
|
2416
|
-
}
|
|
2417
|
-
return JSON.parse(data);
|
|
2418
|
-
},
|
|
2419
|
-
set: (data) => {
|
|
2420
|
-
const toSet = {
|
|
2421
|
-
...data,
|
|
2422
|
-
updated: Date.now()
|
|
2423
|
-
};
|
|
2424
|
-
localStorage.setItem(STORAGE_KEY2, JSON.stringify(toSet));
|
|
2425
|
-
},
|
|
2426
|
-
clear: () => {
|
|
2427
|
-
localStorage.removeItem(STORAGE_KEY2);
|
|
2428
|
-
}
|
|
2429
|
-
};
|
|
2430
|
-
};
|
|
2431
|
-
var generateVisitorId = () => {
|
|
2432
|
-
return `visitor_${generalRandomId()}`;
|
|
2433
|
-
};
|
|
2434
|
-
var generateSessionId = () => {
|
|
2435
|
-
return `session_${generalRandomId()}`;
|
|
2436
|
-
};
|
|
2437
|
-
var generatePageId = () => {
|
|
2438
|
-
return `page_${generalRandomId()}`;
|
|
2439
|
-
};
|
|
2440
|
-
var createInsights = ({
|
|
2487
|
+
var createInsightsV1 = ({
|
|
2441
2488
|
endpoint,
|
|
2442
2489
|
sessionDurationSeconds = 30 * 60
|
|
2443
2490
|
}) => {
|
|
@@ -2538,8 +2585,10 @@ var createInsights = ({
|
|
|
2538
2585
|
}
|
|
2539
2586
|
};
|
|
2540
2587
|
};
|
|
2588
|
+
|
|
2589
|
+
// src/insights/index.ts
|
|
2541
2590
|
var enableUniformInsights = (options) => {
|
|
2542
|
-
const insights =
|
|
2591
|
+
const insights = createInsightsV1({
|
|
2543
2592
|
endpoint: options.endpoint
|
|
2544
2593
|
});
|
|
2545
2594
|
let previousUrl = void 0;
|
|
@@ -2585,8 +2634,8 @@ var enableUniformInsights = (options) => {
|
|
|
2585
2634
|
};
|
|
2586
2635
|
},
|
|
2587
2636
|
update: (context) => {
|
|
2588
|
-
if (context.url && context.url !== previousUrl) {
|
|
2589
|
-
previousUrl = context.url;
|
|
2637
|
+
if (context.url && context.url.toString() !== previousUrl) {
|
|
2638
|
+
previousUrl = context.url.toString();
|
|
2590
2639
|
insights.pageHit();
|
|
2591
2640
|
}
|
|
2592
2641
|
},
|
|
@@ -2595,13 +2644,6 @@ var enableUniformInsights = (options) => {
|
|
|
2595
2644
|
}
|
|
2596
2645
|
};
|
|
2597
2646
|
};
|
|
2598
|
-
var generalRandomId = () => {
|
|
2599
|
-
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
2600
|
-
const id = crypto.randomUUID();
|
|
2601
|
-
return id.replaceAll("-", "").toLowerCase();
|
|
2602
|
-
}
|
|
2603
|
-
return Math.random().toString(32).substring(2);
|
|
2604
|
-
};
|
|
2605
2647
|
|
|
2606
2648
|
// src/logging/enableConsoleLogDrain.ts
|
|
2607
2649
|
import rfdc2 from "rfdc";
|
|
@@ -76,6 +76,17 @@ type VisitorData = {
|
|
|
76
76
|
personalizeVariants?: PersonalizeVariants;
|
|
77
77
|
};
|
|
78
78
|
declare const emptyVisitorData: () => VisitorData;
|
|
79
|
+
/**
|
|
80
|
+
* Canvas-specific data that should be managed separately from regular context updates
|
|
81
|
+
*/
|
|
82
|
+
type CompositionMetadata = {
|
|
83
|
+
/** The composition ID always required, otherwise whole metadata should not be set */
|
|
84
|
+
compositionId: string;
|
|
85
|
+
/** The matched route from router endpoint. Same as matched project map node pathname */
|
|
86
|
+
matchedRoute?: string;
|
|
87
|
+
/** Dynamic inputs for the route */
|
|
88
|
+
dynamicInputs?: Record<string, string>;
|
|
89
|
+
};
|
|
79
90
|
/**
|
|
80
91
|
* Expresses a 'patch' to the Uniform Context state
|
|
81
92
|
*/
|
|
@@ -85,6 +96,11 @@ type ContextState = {
|
|
|
85
96
|
quirks: Quirks;
|
|
86
97
|
enrichments: EnrichmentData[];
|
|
87
98
|
events: EventData[];
|
|
99
|
+
/**
|
|
100
|
+
* Metadata about the composition that is being rendered right now.
|
|
101
|
+
* if you have multiple compositions on the page, please set this one manually.
|
|
102
|
+
*/
|
|
103
|
+
compositionMetadata?: CompositionMetadata;
|
|
88
104
|
};
|
|
89
105
|
type ContextStateUpdate = {
|
|
90
106
|
/** The new effective state of the visitor after this state update is applied */
|
|
@@ -374,6 +390,7 @@ declare class ManifestInstance {
|
|
|
374
390
|
*/
|
|
375
391
|
computeAggregateDimensions(primitiveScores: ScoreVector): ScoreVector;
|
|
376
392
|
getDimensionByKey(scoreKey: string): EnrichmentCategory | Signal | undefined;
|
|
393
|
+
getAggregateDimensionByKey(scoreKey: string): AggregateDimension | undefined;
|
|
377
394
|
}
|
|
378
395
|
|
|
379
396
|
interface paths {
|
|
@@ -1030,6 +1047,10 @@ type TestVariant = {
|
|
|
1030
1047
|
* If not provided, this variant will be selected in equal proportion to other variants without an explicit distribution.
|
|
1031
1048
|
*/
|
|
1032
1049
|
testDistribution?: number;
|
|
1050
|
+
/** Whether this variant is a control variant.
|
|
1051
|
+
* Can be undefined for backward compatibility with older versions of the SDK which were not explicitly setting the control flag.
|
|
1052
|
+
*/
|
|
1053
|
+
control?: boolean;
|
|
1033
1054
|
};
|
|
1034
1055
|
/** The result of computing an A/B test result */
|
|
1035
1056
|
type TestResult<TVariant> = {
|
|
@@ -1051,6 +1072,8 @@ interface PersonalizeOptions<TVariant> {
|
|
|
1051
1072
|
take?: number;
|
|
1052
1073
|
/** Name of the personalization selection algorithm to use. Defaults to top-down criteria when not specified. */
|
|
1053
1074
|
algorithm?: string;
|
|
1075
|
+
/** Composition metadata where the personalization is being rendered for analytics tracking */
|
|
1076
|
+
compositionMetadata?: CompositionMetadata;
|
|
1054
1077
|
}
|
|
1055
1078
|
interface PersonalizationSelectionAlgorithmOptions<TCriteria, TVariant extends PersonalizedVariant<TCriteria> = PersonalizedVariant<TCriteria>> {
|
|
1056
1079
|
/** Name of placement (sent to analytics) */
|
|
@@ -1070,6 +1093,8 @@ type TestOptions<TVariant extends TestVariant> = {
|
|
|
1070
1093
|
name: string;
|
|
1071
1094
|
/** Variations that are being tested. */
|
|
1072
1095
|
variations: TVariant[];
|
|
1096
|
+
/** Composition metadata where the personalization is being rendered for analytics tracking */
|
|
1097
|
+
compositionMetadata?: CompositionMetadata;
|
|
1073
1098
|
};
|
|
1074
1099
|
declare const testVariations: <TVariant extends TestVariant>({ name, context, variations, onLogMessage, }: TestOptions<TVariant> & {
|
|
1075
1100
|
context: Context;
|
|
@@ -1092,8 +1117,8 @@ type ContextPlugin = {
|
|
|
1092
1117
|
init?: (context: Context) => () => void;
|
|
1093
1118
|
/** Plugin-specific actions to perform when a user is forgotten */
|
|
1094
1119
|
forget?: () => Promise<void> | void;
|
|
1095
|
-
/** Plugin-specific actions to perform when the visitor context is updated */
|
|
1096
|
-
update?: (newData: Partial<ContextState
|
|
1120
|
+
/** Plugin-specific actions to perform when the visitor context is updated, second parameter is the recalculated scores after the update */
|
|
1121
|
+
update?: (newData: Partial<ContextState>, recalculatedScores: ScoreVector) => Promise<void> | void;
|
|
1097
1122
|
/**
|
|
1098
1123
|
* Allows the plugin to register named personalization selection algorithms
|
|
1099
1124
|
*
|
|
@@ -1140,6 +1165,12 @@ type PersonalizationEvent = {
|
|
|
1140
1165
|
* False: the variant(s) selected were the same as a previous evaluation of this placement.
|
|
1141
1166
|
*/
|
|
1142
1167
|
changed: boolean;
|
|
1168
|
+
/**
|
|
1169
|
+
* Contains information about the composition that contains personalization wrapper component,
|
|
1170
|
+
* which triggered the personalization event.
|
|
1171
|
+
* Only references top level root composition after pattern resolutions.
|
|
1172
|
+
*/
|
|
1173
|
+
compositionMetadata?: CompositionMetadata;
|
|
1143
1174
|
};
|
|
1144
1175
|
/** Emitted event when an A/B test runs */
|
|
1145
1176
|
type TestEvent = {
|
|
@@ -1147,12 +1178,22 @@ type TestEvent = {
|
|
|
1147
1178
|
name: string;
|
|
1148
1179
|
/** ID of the variant that was selected */
|
|
1149
1180
|
variantId: string | undefined;
|
|
1181
|
+
/**
|
|
1182
|
+
* Whether the variant is part of the control group.
|
|
1183
|
+
*/
|
|
1184
|
+
control: boolean;
|
|
1150
1185
|
/**
|
|
1151
1186
|
* Whether the test variant was newly assigned to the visitor.
|
|
1152
1187
|
* True: variant was assigned to the visitor for the first time.
|
|
1153
1188
|
* False: variant was already assigned to the visitor and is being reused.
|
|
1154
1189
|
*/
|
|
1155
1190
|
variantAssigned: boolean;
|
|
1191
|
+
/**
|
|
1192
|
+
* Contains information about the composition that contains A/B test wrapper component,
|
|
1193
|
+
* which triggered the A/B test event.
|
|
1194
|
+
* Only references top level root composition after pattern resolutions.
|
|
1195
|
+
*/
|
|
1196
|
+
compositionMetadata?: CompositionMetadata;
|
|
1156
1197
|
};
|
|
1157
1198
|
type ContextEvents = {
|
|
1158
1199
|
/**
|
|
@@ -1176,6 +1217,8 @@ type ContextEvents = {
|
|
|
1176
1217
|
testResult: TestEvent;
|
|
1177
1218
|
/** Personalization variants have been selected */
|
|
1178
1219
|
personalizationResult: PersonalizationEvent;
|
|
1220
|
+
/** Composition metadata has been set/updated, usually happens when new composition is being rendered during client-side navigation for example */
|
|
1221
|
+
canvasDataUpdated: CompositionMetadata;
|
|
1179
1222
|
};
|
|
1180
1223
|
interface ContextInstance {
|
|
1181
1224
|
get scores(): Readonly<ScoreVector>;
|
|
@@ -1197,6 +1240,14 @@ interface ContextInstance {
|
|
|
1197
1240
|
internal_processTestEvent(event: TestEvent): void;
|
|
1198
1241
|
/** @deprecated */
|
|
1199
1242
|
internal_processPersonalizationEvent(event: PersonalizationEvent): void;
|
|
1243
|
+
/**
|
|
1244
|
+
* Gets the current canvas data
|
|
1245
|
+
*/
|
|
1246
|
+
getCompositionMetadata(): Readonly<CompositionMetadata | undefined>;
|
|
1247
|
+
/**
|
|
1248
|
+
* Updates the canvas data and emits a canvasDataUpdated event
|
|
1249
|
+
*/
|
|
1250
|
+
updateCompositionMetadata(newData: CompositionMetadata): Promise<void>;
|
|
1200
1251
|
}
|
|
1201
1252
|
declare class Context implements ContextInstance {
|
|
1202
1253
|
#private;
|
|
@@ -1266,6 +1317,14 @@ declare class Context implements ContextInstance {
|
|
|
1266
1317
|
internal_processTestEvent(event: TestEvent): void;
|
|
1267
1318
|
/** @deprecated */
|
|
1268
1319
|
internal_processPersonalizationEvent(event: PersonalizationEvent): void;
|
|
1320
|
+
/**
|
|
1321
|
+
* Gets the current canvas data
|
|
1322
|
+
*/
|
|
1323
|
+
getCompositionMetadata(): Readonly<CompositionMetadata | undefined>;
|
|
1324
|
+
/**
|
|
1325
|
+
* Updates the canvas data and emits a canvasDataUpdated event
|
|
1326
|
+
*/
|
|
1327
|
+
updateCompositionMetadata(newData: CompositionMetadata): Promise<void>;
|
|
1269
1328
|
}
|
|
1270
1329
|
|
|
1271
1330
|
/**
|
|
@@ -1337,4 +1396,4 @@ declare global {
|
|
|
1337
1396
|
}
|
|
1338
1397
|
}
|
|
1339
1398
|
|
|
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
|
|
1399
|
+
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 };
|
|
@@ -76,6 +76,17 @@ type VisitorData = {
|
|
|
76
76
|
personalizeVariants?: PersonalizeVariants;
|
|
77
77
|
};
|
|
78
78
|
declare const emptyVisitorData: () => VisitorData;
|
|
79
|
+
/**
|
|
80
|
+
* Canvas-specific data that should be managed separately from regular context updates
|
|
81
|
+
*/
|
|
82
|
+
type CompositionMetadata = {
|
|
83
|
+
/** The composition ID always required, otherwise whole metadata should not be set */
|
|
84
|
+
compositionId: string;
|
|
85
|
+
/** The matched route from router endpoint. Same as matched project map node pathname */
|
|
86
|
+
matchedRoute?: string;
|
|
87
|
+
/** Dynamic inputs for the route */
|
|
88
|
+
dynamicInputs?: Record<string, string>;
|
|
89
|
+
};
|
|
79
90
|
/**
|
|
80
91
|
* Expresses a 'patch' to the Uniform Context state
|
|
81
92
|
*/
|
|
@@ -85,6 +96,11 @@ type ContextState = {
|
|
|
85
96
|
quirks: Quirks;
|
|
86
97
|
enrichments: EnrichmentData[];
|
|
87
98
|
events: EventData[];
|
|
99
|
+
/**
|
|
100
|
+
* Metadata about the composition that is being rendered right now.
|
|
101
|
+
* if you have multiple compositions on the page, please set this one manually.
|
|
102
|
+
*/
|
|
103
|
+
compositionMetadata?: CompositionMetadata;
|
|
88
104
|
};
|
|
89
105
|
type ContextStateUpdate = {
|
|
90
106
|
/** The new effective state of the visitor after this state update is applied */
|
|
@@ -374,6 +390,7 @@ declare class ManifestInstance {
|
|
|
374
390
|
*/
|
|
375
391
|
computeAggregateDimensions(primitiveScores: ScoreVector): ScoreVector;
|
|
376
392
|
getDimensionByKey(scoreKey: string): EnrichmentCategory | Signal | undefined;
|
|
393
|
+
getAggregateDimensionByKey(scoreKey: string): AggregateDimension | undefined;
|
|
377
394
|
}
|
|
378
395
|
|
|
379
396
|
interface paths {
|
|
@@ -1030,6 +1047,10 @@ type TestVariant = {
|
|
|
1030
1047
|
* If not provided, this variant will be selected in equal proportion to other variants without an explicit distribution.
|
|
1031
1048
|
*/
|
|
1032
1049
|
testDistribution?: number;
|
|
1050
|
+
/** Whether this variant is a control variant.
|
|
1051
|
+
* Can be undefined for backward compatibility with older versions of the SDK which were not explicitly setting the control flag.
|
|
1052
|
+
*/
|
|
1053
|
+
control?: boolean;
|
|
1033
1054
|
};
|
|
1034
1055
|
/** The result of computing an A/B test result */
|
|
1035
1056
|
type TestResult<TVariant> = {
|
|
@@ -1051,6 +1072,8 @@ interface PersonalizeOptions<TVariant> {
|
|
|
1051
1072
|
take?: number;
|
|
1052
1073
|
/** Name of the personalization selection algorithm to use. Defaults to top-down criteria when not specified. */
|
|
1053
1074
|
algorithm?: string;
|
|
1075
|
+
/** Composition metadata where the personalization is being rendered for analytics tracking */
|
|
1076
|
+
compositionMetadata?: CompositionMetadata;
|
|
1054
1077
|
}
|
|
1055
1078
|
interface PersonalizationSelectionAlgorithmOptions<TCriteria, TVariant extends PersonalizedVariant<TCriteria> = PersonalizedVariant<TCriteria>> {
|
|
1056
1079
|
/** Name of placement (sent to analytics) */
|
|
@@ -1070,6 +1093,8 @@ type TestOptions<TVariant extends TestVariant> = {
|
|
|
1070
1093
|
name: string;
|
|
1071
1094
|
/** Variations that are being tested. */
|
|
1072
1095
|
variations: TVariant[];
|
|
1096
|
+
/** Composition metadata where the personalization is being rendered for analytics tracking */
|
|
1097
|
+
compositionMetadata?: CompositionMetadata;
|
|
1073
1098
|
};
|
|
1074
1099
|
declare const testVariations: <TVariant extends TestVariant>({ name, context, variations, onLogMessage, }: TestOptions<TVariant> & {
|
|
1075
1100
|
context: Context;
|
|
@@ -1092,8 +1117,8 @@ type ContextPlugin = {
|
|
|
1092
1117
|
init?: (context: Context) => () => void;
|
|
1093
1118
|
/** Plugin-specific actions to perform when a user is forgotten */
|
|
1094
1119
|
forget?: () => Promise<void> | void;
|
|
1095
|
-
/** Plugin-specific actions to perform when the visitor context is updated */
|
|
1096
|
-
update?: (newData: Partial<ContextState
|
|
1120
|
+
/** Plugin-specific actions to perform when the visitor context is updated, second parameter is the recalculated scores after the update */
|
|
1121
|
+
update?: (newData: Partial<ContextState>, recalculatedScores: ScoreVector) => Promise<void> | void;
|
|
1097
1122
|
/**
|
|
1098
1123
|
* Allows the plugin to register named personalization selection algorithms
|
|
1099
1124
|
*
|
|
@@ -1140,6 +1165,12 @@ type PersonalizationEvent = {
|
|
|
1140
1165
|
* False: the variant(s) selected were the same as a previous evaluation of this placement.
|
|
1141
1166
|
*/
|
|
1142
1167
|
changed: boolean;
|
|
1168
|
+
/**
|
|
1169
|
+
* Contains information about the composition that contains personalization wrapper component,
|
|
1170
|
+
* which triggered the personalization event.
|
|
1171
|
+
* Only references top level root composition after pattern resolutions.
|
|
1172
|
+
*/
|
|
1173
|
+
compositionMetadata?: CompositionMetadata;
|
|
1143
1174
|
};
|
|
1144
1175
|
/** Emitted event when an A/B test runs */
|
|
1145
1176
|
type TestEvent = {
|
|
@@ -1147,12 +1178,22 @@ type TestEvent = {
|
|
|
1147
1178
|
name: string;
|
|
1148
1179
|
/** ID of the variant that was selected */
|
|
1149
1180
|
variantId: string | undefined;
|
|
1181
|
+
/**
|
|
1182
|
+
* Whether the variant is part of the control group.
|
|
1183
|
+
*/
|
|
1184
|
+
control: boolean;
|
|
1150
1185
|
/**
|
|
1151
1186
|
* Whether the test variant was newly assigned to the visitor.
|
|
1152
1187
|
* True: variant was assigned to the visitor for the first time.
|
|
1153
1188
|
* False: variant was already assigned to the visitor and is being reused.
|
|
1154
1189
|
*/
|
|
1155
1190
|
variantAssigned: boolean;
|
|
1191
|
+
/**
|
|
1192
|
+
* Contains information about the composition that contains A/B test wrapper component,
|
|
1193
|
+
* which triggered the A/B test event.
|
|
1194
|
+
* Only references top level root composition after pattern resolutions.
|
|
1195
|
+
*/
|
|
1196
|
+
compositionMetadata?: CompositionMetadata;
|
|
1156
1197
|
};
|
|
1157
1198
|
type ContextEvents = {
|
|
1158
1199
|
/**
|
|
@@ -1176,6 +1217,8 @@ type ContextEvents = {
|
|
|
1176
1217
|
testResult: TestEvent;
|
|
1177
1218
|
/** Personalization variants have been selected */
|
|
1178
1219
|
personalizationResult: PersonalizationEvent;
|
|
1220
|
+
/** Composition metadata has been set/updated, usually happens when new composition is being rendered during client-side navigation for example */
|
|
1221
|
+
canvasDataUpdated: CompositionMetadata;
|
|
1179
1222
|
};
|
|
1180
1223
|
interface ContextInstance {
|
|
1181
1224
|
get scores(): Readonly<ScoreVector>;
|
|
@@ -1197,6 +1240,14 @@ interface ContextInstance {
|
|
|
1197
1240
|
internal_processTestEvent(event: TestEvent): void;
|
|
1198
1241
|
/** @deprecated */
|
|
1199
1242
|
internal_processPersonalizationEvent(event: PersonalizationEvent): void;
|
|
1243
|
+
/**
|
|
1244
|
+
* Gets the current canvas data
|
|
1245
|
+
*/
|
|
1246
|
+
getCompositionMetadata(): Readonly<CompositionMetadata | undefined>;
|
|
1247
|
+
/**
|
|
1248
|
+
* Updates the canvas data and emits a canvasDataUpdated event
|
|
1249
|
+
*/
|
|
1250
|
+
updateCompositionMetadata(newData: CompositionMetadata): Promise<void>;
|
|
1200
1251
|
}
|
|
1201
1252
|
declare class Context implements ContextInstance {
|
|
1202
1253
|
#private;
|
|
@@ -1266,6 +1317,14 @@ declare class Context implements ContextInstance {
|
|
|
1266
1317
|
internal_processTestEvent(event: TestEvent): void;
|
|
1267
1318
|
/** @deprecated */
|
|
1268
1319
|
internal_processPersonalizationEvent(event: PersonalizationEvent): void;
|
|
1320
|
+
/**
|
|
1321
|
+
* Gets the current canvas data
|
|
1322
|
+
*/
|
|
1323
|
+
getCompositionMetadata(): Readonly<CompositionMetadata | undefined>;
|
|
1324
|
+
/**
|
|
1325
|
+
* Updates the canvas data and emits a canvasDataUpdated event
|
|
1326
|
+
*/
|
|
1327
|
+
updateCompositionMetadata(newData: CompositionMetadata): Promise<void>;
|
|
1269
1328
|
}
|
|
1270
1329
|
|
|
1271
1330
|
/**
|
|
@@ -1337,4 +1396,4 @@ declare global {
|
|
|
1337
1396
|
}
|
|
1338
1397
|
}
|
|
1339
1398
|
|
|
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
|
|
1399
|
+
export { type ManifestV2 as $, type AggregateDimension as A, type DevToolsLogEvent as B, type ContextPlugin as C, type DecayFunction as D, type DevToolsDataEvent as E, type DevToolsHelloEvent as F, type DevToolsUpdateEvent as G, type DevToolsRawCommandsEvent as H, type DevToolsForgetEvent as I, type LogMessages as J, type Severity as K, type LogDrain as L, type MessageCategory as M, type MessageFunc as N, type OutputSeverity as O, type PersonalizedVariant as P, type Quirks as Q, type LogMessageSingle as R, type ScoreVector as S, TransitionDataStore as T, type LogMessageGroup as U, type VisitorData as V, ManifestInstance as W, GroupCriteriaEvaluator as X, type CriteriaEvaluatorResult as Y, type CriteriaEvaluatorParameters as Z, type SignalData as _, type StorageCommands as a, type PersonalizationManifest as a0, type Signal as a1, type SignalCriteriaGroup as a2, type SignalCriteria as a3, type EnrichmentCategory as a4, type NumberMatch as a5, type TestDefinition as a6, type AggregateDimensionInput as a7, type TestOptions as a8, testVariations as a9, type EnrichmentData as aA, type PersonalizeControlVariant as aB, type PersonalizeVariants as aC, type EventData as aD, emptyVisitorData as aE, type CompositionMetadata as aF, type ContextState as aG, type ContextStateUpdate as aH, type GoalStateUpdate as aI, type paths as aJ, type VariationMatchMetadata as aa, type DimensionMatch as ab, type QuirkMatch as ac, type BehaviorTag as ad, type TestVariant as ae, type TestResult as af, type StorageCommand as ag, type SetGoalCommand as ah, type ModifyScoreCommand as ai, type ModifySessionScoreCommand as aj, type SetConsentCommand as ak, type SetQuirkCommand as al, type SetTestCommand as am, type IdentifyCommand as an, type SetControlGroupCommand as ao, type SetPersonalizeVariantControlCommand as ap, areCommandsEqual as aq, type ServerToClientTransitionState as ar, SERVER_STATE_ID as as, type TransitionDataStoreEvents as at, type DecayOptions as au, type VisitorDataStoreOptions as av, type VisitorDataStoreEvents as aw, VisitorDataStore as ax, type Tests as ay, type Goals as az, type TransitionDataStoreOptions as b, type CriteriaEvaluator as c, type StringMatch as d, type VariantMatchCriteria as e, type LogMessage as f, type PersonalizeOptions as g, Context as h, type PersonalizedResult as i, type VariationMatchDimensionCriteria as j, type PersonalizationSelectionAlgorithmOptions as k, type DevToolsEvents as l, CONTEXTUAL_EDITING_TEST_NAME as m, CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID as n, type PersonalizationSelectionAlgorithm as o, type PersonalizationSelectionAlgorithms as p, type ContextOptions as q, type PersonalizationEventVariantId as r, type PersonalizationEvent as s, type TestEvent as t, type ContextEvents as u, type ContextInstance as v, type DevToolsUiVersion as w, type DevToolsState as x, type DevToolsActions as y, type DevToolsEvent as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/context",
|
|
3
|
-
"version": "20.7.1-alpha.
|
|
3
|
+
"version": "20.7.1-alpha.83+9085e999d1",
|
|
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",
|
|
44
|
+
"test": "vitest run",
|
|
45
45
|
"test:coverage": "vitest run --coverage",
|
|
46
46
|
"lint": "eslint \"src/**/*.{js,ts,tsx}\"",
|
|
47
47
|
"format": "prettier --write \"src/**/*.{js,ts,tsx}\"",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@types/uuid": "9.0.4",
|
|
56
56
|
"@vitest/coverage-v8": "3.2.4",
|
|
57
57
|
"benny": "3.7.1",
|
|
58
|
-
"vite": "
|
|
58
|
+
"vite": "7.1.5",
|
|
59
59
|
"vite-tsconfig-paths": "^5.1.4",
|
|
60
60
|
"vitest": "3.2.4"
|
|
61
61
|
},
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"publishConfig": {
|
|
73
73
|
"access": "public"
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "9085e999d1c99bc2d084085dc9983eb5df91f556"
|
|
76
76
|
}
|