@splithub/core 0.3.0 → 0.4.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.
package/dist/index.cjs CHANGED
@@ -23,6 +23,7 @@ __export(index_exports, {
23
23
  CLOUD_ENDPOINT: () => CLOUD_ENDPOINT,
24
24
  ConfigError: () => ConfigError,
25
25
  EMPTY_OVERRIDES: () => EMPTY_OVERRIDES,
26
+ EVENT_NAME_PATTERN: () => EVENT_NAME_PATTERN,
26
27
  EventQueue: () => EventQueue,
27
28
  HOLDOUT_KEY: () => HOLDOUT_KEY,
28
29
  KEYED_FIELDS: () => KEYED_FIELDS,
@@ -30,6 +31,7 @@ __export(index_exports, {
30
31
  MVT_MAX_COMBINATIONS: () => MVT_MAX_COMBINATIONS,
31
32
  MVT_MAX_FACTORS: () => MVT_MAX_FACTORS,
32
33
  MVT_MAX_LEVELS: () => MVT_MAX_LEVELS,
34
+ PROPERTY_KEY_PATTERN: () => PROPERTY_KEY_PATTERN,
33
35
  REMOTE_TTL_MS: () => REMOTE_TTL_MS,
34
36
  REMOTE_WAIT_MS: () => REMOTE_WAIT_MS,
35
37
  SDK_VERSION: () => SDK_VERSION,
@@ -49,11 +51,13 @@ __export(index_exports, {
49
51
  defineConfig: () => defineConfig,
50
52
  devNote: () => devNote,
51
53
  evaluateCondition: () => evaluateCondition,
54
+ eventKey: () => eventKey,
52
55
  explainAssignment: () => explainAssignment,
53
56
  fetchRemoteOverrides: () => fetchRemoteOverrides,
54
57
  getExperiment: () => getExperiment,
55
58
  getOrCreateSessionId: () => getOrCreateSessionId,
56
59
  getOrCreateVisitorId: () => getOrCreateVisitorId,
60
+ goalKeyFor: () => goalKeyFor,
57
61
  hasVisitorId: () => hasVisitorId,
58
62
  hashToUnit: () => hashToUnit,
59
63
  holdoutExperiment: () => holdoutExperiment,
@@ -76,16 +80,21 @@ __export(index_exports, {
76
80
  murmur3: () => murmur3,
77
81
  mvtVariants: () => mvtVariants,
78
82
  newId: () => newId,
83
+ newPropertyId: () => newPropertyId,
79
84
  newSessionId: () => newSessionId,
80
85
  newVisitorId: () => newVisitorId,
81
86
  normalizePath: () => normalizePath,
87
+ normalizeProperty: () => normalizeProperty,
82
88
  onDebug: () => onDebug,
83
89
  parseCookies: () => parseCookies,
84
90
  parseForceParam: () => parseForceParam,
85
91
  parseUserAgent: () => parseUserAgent,
92
+ pickProperty: () => pickProperty,
86
93
  pickVariant: () => pickVariant,
87
94
  readRemoteCache: () => readRemoteCache,
88
95
  redirectTarget: () => redirectTarget,
96
+ referrerOrigin: () => referrerOrigin,
97
+ resetAnalyticsClaims: () => resetAnalyticsClaims,
89
98
  resetDevNotes: () => resetDevNotes,
90
99
  resolveOverridesUrl: () => resolveOverridesUrl,
91
100
  runFlow: () => runFlow,
@@ -492,13 +501,13 @@ function normalizeVariants(expKey, input) {
492
501
  }
493
502
  var HOLDOUT_KEY = "__holdout";
494
503
  var LAYER_BUCKETS = 100;
495
- function normalizeMetrics(key, input, goals) {
504
+ function normalizeMetrics(key, input, primary, goals) {
496
505
  const m = input.metrics;
497
506
  if (!m) return void 0;
498
- if (!input.goal) throw new ConfigError(`experiment "${key}": metrics need a primary "goal" too.`);
499
- const seen = /* @__PURE__ */ new Set([input.goal]);
500
- const check = (goal, where) => {
501
- if (typeof goal !== "string" || !goals.some((g) => g.key === goal)) throw new ConfigError(`experiment "${key}": metrics.${where} goal "${String(goal)}" is not declared in "goals".`);
507
+ if (!primary) throw new ConfigError(`experiment "${key}": metrics need a primary "goal" too.`);
508
+ const seen = /* @__PURE__ */ new Set([primary]);
509
+ const check = (name, where) => {
510
+ const goal = goalFor(name, goals, `experiment "${key}": metrics.${where}`);
502
511
  if (seen.has(goal)) throw new ConfigError(`experiment "${key}": goal "${goal}" is listed twice (primary goal and metrics count once each).`);
503
512
  seen.add(goal);
504
513
  return goal;
@@ -539,9 +548,9 @@ function normalizeHoldout(input, goals) {
539
548
  const h = input.holdout;
540
549
  if (!h) return null;
541
550
  if (typeof h.percent !== "number" || !Number.isFinite(h.percent) || h.percent < 0 || h.percent > 50) throw new ConfigError("holdout.percent must be a number between 0 and 50.");
542
- if (h.goal && !goals.some((g) => g.key === h.goal)) throw new ConfigError(`holdout.goal "${h.goal}" is not declared in "goals".`);
551
+ const goal = h.goal ? goalFor(h.goal, goals, "holdout.goal") : null;
543
552
  if (h.percent === 0) return null;
544
- return { percent: h.percent, seed: h.seed ?? HOLDOUT_KEY, goal: h.goal ?? goals[0]?.key ?? null };
553
+ return { percent: h.percent, seed: h.seed ?? HOLDOUT_KEY, goal: goal ?? goals[0]?.key ?? null };
545
554
  }
546
555
  function normalizeExperiment(key, input, goals, layers = {}) {
547
556
  assertKey("experiment", key);
@@ -549,9 +558,7 @@ function normalizeExperiment(key, input, goals, layers = {}) {
549
558
  if (traffic < 0 || traffic > 1) {
550
559
  throw new ConfigError(`experiment "${key}": traffic must be between 0 and 1.`);
551
560
  }
552
- if (input.goal && !goals.some((g) => g.key === input.goal)) {
553
- throw new ConfigError(`experiment "${key}": goal "${input.goal}" is not declared in "goals".`);
554
- }
561
+ const goal = input.goal ? goalFor(input.goal, goals, `experiment "${key}"`) : null;
555
562
  if (input.kind === "redirect" && !input.match) {
556
563
  throw new ConfigError(`experiment "${key}": redirect experiments need "match".`);
557
564
  }
@@ -571,7 +578,7 @@ function normalizeExperiment(key, input, goals, layers = {}) {
571
578
  if (v !== void 0 && Number.isNaN(Date.parse(v))) throw new ConfigError(`experiment "${key}": schedule.${k} must be an ISO date.`);
572
579
  }
573
580
  const variants = normalizeVariants(key, input);
574
- const metrics = normalizeMetrics(key, input, goals);
581
+ const metrics = normalizeMetrics(key, input, goal, goals);
575
582
  const layer = normalizeLayer(key, input, layers);
576
583
  if (input.flow) {
577
584
  const problem = validateFlow(input.flow, variants.map((v) => v.key));
@@ -582,7 +589,7 @@ function normalizeExperiment(key, input, goals, layers = {}) {
582
589
  kind: input.kind,
583
590
  status: input.status,
584
591
  traffic,
585
- goal: input.goal ?? null,
592
+ goal,
586
593
  seed: input.seed ?? key,
587
594
  description: input.description ?? null,
588
595
  ...input.name !== void 0 ? { name: input.name.trim() } : {},
@@ -598,6 +605,67 @@ function normalizeExperiment(key, input, goals, layers = {}) {
598
605
  ...input.schedule && (input.schedule.startAt || input.schedule.endAt) ? { schedule: { startAt: input.schedule.startAt ?? null, endAt: input.schedule.endAt ?? null } } : {}
599
606
  };
600
607
  }
608
+ function goalExtras(key, g) {
609
+ if (g.name !== void 0 && !(typeof g.name === "string" && g.name.trim() && g.name.trim().length <= 80)) throw new ConfigError(`goal "${key}": name must be text of 1 to 80 characters.`);
610
+ if (g.value !== void 0 && !(typeof g.value === "number" && Number.isFinite(g.value) && g.value >= 0)) throw new ConfigError(`goal "${key}": value must be a number of 0 or more.`);
611
+ const event = g.type === "event" ? g.event : void 0;
612
+ if (event !== void 0 && !EVENT_NAME_PATTERN.test(event)) throw new ConfigError(`goal "${key}": event "${event}" is not a valid event name.`);
613
+ return { ...g.name !== void 0 ? { name: g.name.trim() } : {}, ...g.value !== void 0 ? { value: g.value } : {}, ...event !== void 0 && event !== key ? { event } : {} };
614
+ }
615
+ var PROPERTY_KEY_PATTERN = KEY_PATTERN;
616
+ var ID_ALPHABET = "abcdefghjkmnpqrstuvwxyz23456789";
617
+ function newPropertyId() {
618
+ const bytes = new Uint8Array(6);
619
+ globalThis.crypto.getRandomValues(bytes);
620
+ return `sh-${Array.from(bytes, (b) => ID_ALPHABET[b % ID_ALPHABET.length]).join("")}`;
621
+ }
622
+ var EVENT_NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9 _.:/-]{0,63}$/;
623
+ function eventKey(name) {
624
+ return String(name).trim().toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^[^a-z0-9]+/, "").slice(0, 64).replace(/-+$/, "");
625
+ }
626
+ function goalKeyFor(goals, name) {
627
+ if (goals.some((g) => g.key === name)) return name;
628
+ const byEvent = goals.find((g) => g.event === name);
629
+ if (byEvent) return byEvent.key;
630
+ const slug = eventKey(name);
631
+ return KEY_PATTERN.test(slug) ? slug : null;
632
+ }
633
+ function goalFor(name, goals, where) {
634
+ if (typeof name !== "string" || !(KEY_PATTERN.test(name) || EVENT_NAME_PATTERN.test(name))) {
635
+ throw new ConfigError(`${where}: goal "${String(name)}" is not a valid event name (letters, digits, spaces and "_ . : / -", up to 64 characters).`);
636
+ }
637
+ const key = goalKeyFor(goals, name);
638
+ if (!key) throw new ConfigError(`${where}: goal "${name}" has no usable key; use letters or digits in the name.`);
639
+ if (!goals.some((g) => g.key === key)) {
640
+ goals.push({ key, type: "event", path: null, selector: null, revenue: false, description: null, ...name !== key ? { event: name } : {} });
641
+ }
642
+ return key;
643
+ }
644
+ function normalizeProperty(key, input, goals) {
645
+ assertKey("property", key);
646
+ const p = input ?? {};
647
+ const status = p.status ?? "running";
648
+ if (status !== "running" && status !== "paused") throw new ConfigError(`property "${key}": status must be "running" or "paused".`);
649
+ if (p.name !== void 0 && !(typeof p.name === "string" && p.name.trim() && p.name.trim().length <= 80)) {
650
+ throw new ConfigError(`property "${key}": name must be text of 1 to 80 characters.`);
651
+ }
652
+ const list2 = p.goals ?? [];
653
+ if (!Array.isArray(list2)) throw new ConfigError(`property "${key}": goals must be a list of goal keys.`);
654
+ for (const g of list2) {
655
+ if (!goals.some((d) => d.key === g)) throw new ConfigError(`property "${key}": goal "${String(g)}" is not declared in "goals".`);
656
+ }
657
+ return {
658
+ key,
659
+ status,
660
+ ...p.name !== void 0 ? { name: p.name.trim() } : {},
661
+ description: p.description ?? null,
662
+ goals: [...new Set(list2)]
663
+ };
664
+ }
665
+ function pickProperty(config, key) {
666
+ if (!key) return null;
667
+ return (config.properties ?? []).find((p) => p.key === key) ?? null;
668
+ }
601
669
  function defineConfig(input) {
602
670
  if (!input || typeof input !== "object") throw new ConfigError("config must be an object.");
603
671
  if (!input.project) throw new ConfigError('"project" is required.');
@@ -613,7 +681,8 @@ function defineConfig(input) {
613
681
  path: g.type === "pageview" ? g.path : null,
614
682
  selector: g.type === "click" ? g.selector : null,
615
683
  revenue: g.type === "event" ? Boolean(g.revenue) : false,
616
- description: g.description ?? null
684
+ description: g.description ?? null,
685
+ ...goalExtras(key, g)
617
686
  };
618
687
  });
619
688
  const layers = {};
@@ -626,6 +695,7 @@ function defineConfig(input) {
626
695
  );
627
696
  assertNoOverlap(experiments);
628
697
  const holdout = normalizeHoldout(input, goals);
698
+ const properties = Object.entries(input.properties ?? {}).map(([key, p]) => normalizeProperty(key, p, goals));
629
699
  return {
630
700
  project: input.project,
631
701
  storage: input.storage,
@@ -633,6 +703,7 @@ function defineConfig(input) {
633
703
  runDraftsInDev: input.runDraftsInDev === true,
634
704
  goals,
635
705
  experiments,
706
+ ...properties.length ? { properties } : {},
636
707
  ...Object.keys(layers).length ? { layers } : {},
637
708
  ...holdout ? { holdout } : {},
638
709
  __splithub: 2
@@ -656,7 +727,7 @@ function holdoutExperiment(config) {
656
727
  traffic: 1,
657
728
  goal: h.goal,
658
729
  seed: h.seed,
659
- description: `Holdout: ${h.percent}% of visitors see no test at all`,
730
+ description: `Holdout: ${h.percent}% of visitors see no experiment at all`,
660
731
  match: null,
661
732
  variants: [
662
733
  { key: "holdout", weight: share },
@@ -800,11 +871,11 @@ function explainAssignment(experiment, a) {
800
871
  return;
801
872
  }
802
873
  if (a.reason === "holdout") {
803
- devNote("holdout", `This visitor is in the holdout, so every test shows its control. Open ?sh_force=${key}:${experiment.variants[1]?.key ?? "variant"} to see a variant.`);
874
+ devNote("holdout", `This visitor is in the holdout, so every experiment shows its control. Open ?sh_force=${key}:${experiment.variants[1]?.key ?? "variant"} to see a variant.`);
804
875
  return;
805
876
  }
806
877
  if (a.reason === "layer") {
807
- devNote(`${key}:layer`, `"${key}" shares layer "${experiment.layer?.key}" with other tests and this visitor's bucket belongs to another one, so they see the control.`);
878
+ devNote(`${key}:layer`, `"${key}" shares layer "${experiment.layer?.key}" with other experiments and this visitor's bucket belongs to another one, so they see the control.`);
808
879
  return;
809
880
  }
810
881
  if (a.reason !== "not_running") return;
@@ -818,6 +889,29 @@ function explainAssignment(experiment, a) {
818
889
  }
819
890
  }
820
891
 
892
+ // src/shared.ts
893
+ var REGISTRY = /* @__PURE__ */ Symbol.for("splithub.analytics");
894
+ function registry() {
895
+ if (typeof window === "undefined") return null;
896
+ const g = globalThis;
897
+ return g[REGISTRY] ?? (g[REGISTRY] = /* @__PURE__ */ new Map());
898
+ }
899
+ function claimAnalytics(key, owner) {
900
+ const r = registry();
901
+ if (!r) return true;
902
+ const held = r.get(key);
903
+ if (held && held !== owner) return false;
904
+ r.set(key, owner);
905
+ return true;
906
+ }
907
+ function releaseAnalytics(key, owner) {
908
+ const r = registry();
909
+ if (r?.get(key) === owner) r.delete(key);
910
+ }
911
+ function resetAnalyticsClaims() {
912
+ registry()?.clear();
913
+ }
914
+
821
915
  // src/ids.ts
822
916
  var ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz";
823
917
  function randomBytes(n) {
@@ -844,6 +938,38 @@ function newSessionId() {
844
938
  return newId("s_");
845
939
  }
846
940
 
941
+ // src/paths.ts
942
+ function normalizePath(path) {
943
+ return path.length > 1 && path.endsWith("/") ? path.replace(/\/+$/, "") || "/" : path;
944
+ }
945
+ function matchPath(pattern, pathname) {
946
+ if (pattern.endsWith("*")) return pathname.startsWith(pattern.slice(0, -1));
947
+ return normalizePath(pattern) === normalizePath(pathname);
948
+ }
949
+ function redirectTarget(to, currentHref) {
950
+ const current = new URL(currentHref);
951
+ const target = new URL(to, current);
952
+ const own = new Set(target.searchParams.keys());
953
+ current.searchParams.forEach((value, key) => {
954
+ if (!own.has(key)) target.searchParams.append(key, value);
955
+ });
956
+ if (!target.hash) target.hash = current.hash;
957
+ return target;
958
+ }
959
+ function referrerOrigin(referrer, siteHost) {
960
+ if (!referrer) return "";
961
+ let url;
962
+ try {
963
+ url = new URL(referrer);
964
+ } catch {
965
+ return void 0;
966
+ }
967
+ const host = url.hostname.toLowerCase().replace(/^www\./, "");
968
+ const site = (siteHost ?? "").toLowerCase().replace(/:\d+$/, "").replace(/^www\./, "");
969
+ if (!host || host === site) return void 0;
970
+ return `${url.protocol}//${url.host}`.slice(0, 300);
971
+ }
972
+
847
973
  // src/visitor.ts
848
974
  var ONE_YEAR = 60 * 60 * 24 * 365;
849
975
  var isBrowser = () => typeof window !== "undefined" && typeof document !== "undefined";
@@ -901,24 +1027,28 @@ function sessionExposureSet(key = "sh_exposed") {
901
1027
  function persistExposureSet(set, key = "sh_exposed") {
902
1028
  safeStorage("sessionStorage")?.setItem(key, JSON.stringify([...set]));
903
1029
  }
904
-
905
- // src/paths.ts
906
- function normalizePath(path) {
907
- return path.length > 1 && path.endsWith("/") ? path.replace(/\/+$/, "") || "/" : path;
1030
+ function readStored(kind, key) {
1031
+ try {
1032
+ return safeStorage(kind)?.getItem(key) ?? null;
1033
+ } catch {
1034
+ return null;
1035
+ }
908
1036
  }
909
- function matchPath(pattern, pathname) {
910
- if (pattern.endsWith("*")) return pathname.startsWith(pattern.slice(0, -1));
911
- return normalizePath(pattern) === normalizePath(pathname);
1037
+ function writeStored(kind, key, value) {
1038
+ try {
1039
+ const s = safeStorage(kind);
1040
+ if (value === null) s?.removeItem(key);
1041
+ else s?.setItem(key, value);
1042
+ } catch {
1043
+ }
912
1044
  }
913
- function redirectTarget(to, currentHref) {
914
- const current = new URL(currentHref);
915
- const target = new URL(to, current);
916
- const own = new Set(target.searchParams.keys());
917
- current.searchParams.forEach((value, key) => {
918
- if (!own.has(key)) target.searchParams.append(key, value);
919
- });
920
- if (!target.hash) target.hash = current.hash;
921
- return target;
1045
+ function sessionReferrer(key = "sh_ref") {
1046
+ if (!isBrowser()) return void 0;
1047
+ const stored = readStored("sessionStorage", key);
1048
+ if (stored !== null) return stored;
1049
+ const ref = referrerOrigin(document.referrer, location.host);
1050
+ if (ref !== void 0) writeStored("sessionStorage", key, ref);
1051
+ return ref;
922
1052
  }
923
1053
 
924
1054
  // src/redirect.ts
@@ -1149,13 +1279,22 @@ function applyRemoteOverrides(config, overrides) {
1149
1279
  const addedGoals = (overrides.goals ?? []).filter((g) => g && typeof g.key === "string" && !knownGoals.has(g.key));
1150
1280
  const holdout = !config.holdout && validHoldout(overrides.holdout) ? overrides.holdout : null;
1151
1281
  const layers = overrides.layers && typeof overrides.layers === "object" ? { ...overrides.layers, ...config.layers ?? {} } : null;
1152
- if (Object.keys(patches).length === 0 && added.length === 0 && addedGoals.length === 0 && !holdout && !layers) return config;
1282
+ const propertyPatches = overrides.properties ?? {};
1283
+ const knownProps = new Set((config.properties ?? []).map((p) => p.key));
1284
+ const addedProps = (overrides.addedProperties ?? []).filter((p) => p && typeof p.key === "string" && !knownProps.has(p.key));
1285
+ const propsChanged = Object.keys(propertyPatches).length > 0 || addedProps.length > 0;
1286
+ if (Object.keys(patches).length === 0 && added.length === 0 && addedGoals.length === 0 && !holdout && !layers && !propsChanged) return config;
1287
+ const properties = propsChanged ? [...config.properties ?? [], ...addedProps.map((p) => ({ ...p, goals: Array.isArray(p.goals) ? p.goals : [], origin: "dashboard" }))].map((p) => {
1288
+ const status = propertyPatches[p.key]?.status;
1289
+ return status === "running" || status === "paused" ? { ...p, status } : p;
1290
+ }) : config.properties;
1153
1291
  const merged = [...config.experiments, ...added.map((e) => ({ ...e, origin: "dashboard" }))];
1154
1292
  return {
1155
1293
  ...config,
1156
1294
  ...holdout ? { holdout } : {},
1157
1295
  ...layers ? { layers } : {},
1158
1296
  goals: addedGoals.length ? [...config.goals, ...addedGoals] : config.goals,
1297
+ ...properties ? { properties } : {},
1159
1298
  experiments: merged.map((e) => {
1160
1299
  const o = patches[e.key];
1161
1300
  return o ? applyToExperiment(e, o) : e;
@@ -1214,6 +1353,11 @@ var SDK_VERSION = "0.1.0";
1214
1353
  var REMOTE_WAIT_MS = 400;
1215
1354
  var DEV_NOTE = "Development sends nothing to the cloud, so your own visits never reach the results. Deployed builds send as usual.";
1216
1355
  var CLOUD_ENDPOINT = "https://go.splithub.io/v1/events";
1356
+ var PROPERTY_WAIT_MS = 5e3;
1357
+ var MAX_PROPS_BYTES = 4096;
1358
+ var MAX_ENGAGE_MS = 36e5;
1359
+ var UID_KEY = "sh_uid";
1360
+ var UID_SENT_KEY = "sh_uid_sent";
1217
1361
  function resolveEndpoint(config) {
1218
1362
  if (config.storage.mode === "self") return { endpoint: config.storage.endpoint };
1219
1363
  return { endpoint: config.storage.endpoint ?? CLOUD_ENDPOINT, key: config.storage.key };
@@ -1228,6 +1372,7 @@ function createClient(config, options = {}) {
1228
1372
  let effective = config;
1229
1373
  let geo;
1230
1374
  let waitFor = null;
1375
+ let arriving = options.remote?.arriving ?? null;
1231
1376
  if (options.remote?.overrides) {
1232
1377
  effective = applyRemoteOverrides(config, options.remote.overrides);
1233
1378
  geo = options.remote.overrides.ctx;
@@ -1245,6 +1390,7 @@ function createClient(config, options = {}) {
1245
1390
  if (fresh) writeRemoteCache(publicKey, fresh);
1246
1391
  return fresh;
1247
1392
  });
1393
+ arriving = fetched;
1248
1394
  const waitMs = options.remote?.waitMs ?? REMOTE_WAIT_MS;
1249
1395
  if (!cached && waitMs > 0 && options.remote?.overrides === void 0) waitFor = withTimeout(fetched, waitMs);
1250
1396
  else {
@@ -1258,7 +1404,7 @@ function createClient(config, options = {}) {
1258
1404
  const hadVisitor = browser && !options.visitorId ? hasVisitorId(config.visitorKey) : void 0;
1259
1405
  const visitorId = options.visitorId ?? (browser ? getOrCreateVisitorId(config.visitorKey) : "server");
1260
1406
  const noVisitor = !browser && !options.visitorId;
1261
- const sessionId = options.sessionId ?? (browser ? getOrCreateSessionId() : "server");
1407
+ const sessionId = options.sessionId ?? (browser ? getOrCreateSessionId() : options.visitorId ? `srv_${murmur3(options.visitorId).toString(36)}` : "server");
1262
1408
  const contextFor = (g) => {
1263
1409
  if (!browser) return { ...g ?? {}, ...options.context ?? {} };
1264
1410
  const forPage = g?.timezone ? { ...g, timezone: void 0 } : g;
@@ -1278,7 +1424,15 @@ function createClient(config, options = {}) {
1278
1424
  }
1279
1425
  const disabled = options.disabled ?? (!browser && !options.transport);
1280
1426
  const cloud = config.storage.mode === "cloud";
1281
- const cloudIdle = () => cloud && !config.experiments.some((e) => e.status === "running");
1427
+ const cloudIdle = () => cloud && !config.experiments.some((e) => e.status === "running") && !(config.properties ?? []).some((p) => p.status === "running");
1428
+ const wanted = typeof options.property === "string" ? options.property.trim().toLowerCase() || null : null;
1429
+ let propConfig = config;
1430
+ const known = () => wanted !== null && pickProperty(propConfig, wanted) !== null;
1431
+ const property = () => {
1432
+ if (!wanted) return null;
1433
+ const p = pickProperty(propConfig, wanted);
1434
+ return p && p.status === "running" ? p.key : null;
1435
+ };
1282
1436
  const devLocal = cloud && isDevEnvironment();
1283
1437
  const held = /* @__PURE__ */ new Set();
1284
1438
  const hold = (key, kind, message) => {
@@ -1298,6 +1452,8 @@ function createClient(config, options = {}) {
1298
1452
  });
1299
1453
  const exposed = browser ? sessionExposureSet() : /* @__PURE__ */ new Set();
1300
1454
  const currentUrl = () => browser ? location.pathname + location.search : void 0;
1455
+ const entryRef = browser ? sessionReferrer() : void 0;
1456
+ const refField = entryRef === void 0 ? {} : { ref: entryRef };
1301
1457
  const markHoldout = (ts) => {
1302
1458
  const group = holdoutGroup(config, visitorId);
1303
1459
  if (!group || noVisitor) return;
@@ -1309,7 +1465,7 @@ function createClient(config, options = {}) {
1309
1465
  }
1310
1466
  exposed.add(dedupKey);
1311
1467
  if (browser) persistExposureSet(exposed);
1312
- const event = { id: newId("e_"), type: "exposure", exp: HOLDOUT_KEY, var: group, vid: visitorId, sid: sessionId, ts, url: currentUrl() };
1468
+ const event = { id: newId("e_"), type: "exposure", exp: HOLDOUT_KEY, var: group, vid: visitorId, sid: sessionId, ts, url: currentUrl(), ...refField };
1313
1469
  debugLog("exposure", `${HOLDOUT_KEY} / ${group} recorded`, event);
1314
1470
  queue.push(event);
1315
1471
  };
@@ -1329,15 +1485,14 @@ function createClient(config, options = {}) {
1329
1485
  if (exposed.has(dedupKey)) return;
1330
1486
  exposed.add(dedupKey);
1331
1487
  if (browser) persistExposureSet(exposed);
1332
- const event = { id: newId("e_"), type: "exposure", exp: experimentKey, var: a.variant.key, vid: visitorId, sid: sessionId, ts, url: currentUrl() };
1488
+ const event = { id: newId("e_"), type: "exposure", exp: experimentKey, var: a.variant.key, vid: visitorId, sid: sessionId, ts, url: currentUrl(), ...refField };
1333
1489
  debugLog("exposure", `${experimentKey} / ${a.variant.key} recorded`, event);
1334
1490
  queue.push(event);
1335
1491
  };
1336
- const sendGoal = (goal, props, ts) => {
1492
+ const sendGoal = (name, props, ts) => {
1337
1493
  if (isBot2()) return;
1338
- if (!config.goals.some((g) => g.key === goal)) {
1339
- warn(`goal "${goal}" is not declared in splithub.config.ts; sending anyway.`);
1340
- }
1494
+ const goal = goalKeyFor(config.goals, name);
1495
+ if (!goal) return;
1341
1496
  if (typeof __SPLITHUB_LITE__ === "undefined" && devLocal) {
1342
1497
  devNote("dev-events", DEV_NOTE);
1343
1498
  hold(`g:${goal}`, "goal", `${goal} not sent: development never sends to the cloud`);
@@ -1351,21 +1506,231 @@ function createClient(config, options = {}) {
1351
1506
  debugLog("goal", `${goal}${props ? " " + JSON.stringify(props) : ""}`, event);
1352
1507
  queue.push(event);
1353
1508
  };
1509
+ let propertyFetch = null;
1510
+ const propertyWaiting = [];
1511
+ const warnUnknownProperty = () => {
1512
+ if (wanted && !known() && (isDevEnvironment() || isDebug())) {
1513
+ warn(`property "${wanted}" is not in splithub.config.ts or the dashboard, so no pageviews or events are sent. Check the id (it looks like sh-x1h78w).`);
1514
+ }
1515
+ };
1516
+ const withProperty = (send) => {
1517
+ if (!wanted) return;
1518
+ if (!known() && propertyFetch) {
1519
+ propertyWaiting.push(send);
1520
+ return;
1521
+ }
1522
+ send();
1523
+ };
1524
+ const hashRoute = () => {
1525
+ if (!browser || options.trackHash === false) return null;
1526
+ const hash = location.hash;
1527
+ const route = hash.startsWith("#/") ? hash.slice(1) : hash.startsWith("#!/") ? hash.slice(2) : null;
1528
+ if (route === null || options.trackHash !== true && location.pathname !== "/") return null;
1529
+ return route.includes("?") || !location.search ? route : route + location.search;
1530
+ };
1531
+ const pageUrl = () => hashRoute() ?? location.pathname + location.search;
1532
+ const pagePath = () => hashRoute()?.split("?")[0] ?? location.pathname;
1533
+ let engage = null;
1534
+ const pageVisible = () => typeof document === "undefined" || document.visibilityState !== "hidden";
1535
+ const scrollDepth = () => {
1536
+ if (!browser) return 0;
1537
+ const doc = document.documentElement;
1538
+ const height = Math.max(doc.scrollHeight, document.body?.scrollHeight ?? 0);
1539
+ const seen = (window.scrollY || doc.scrollTop || 0) + window.innerHeight;
1540
+ if (!height || seen >= height) return 100;
1541
+ return Math.max(0, Math.min(100, Math.round(seen / height * 100)));
1542
+ };
1543
+ const emitEngage = (final) => {
1544
+ const e = engage;
1545
+ if (!e) return false;
1546
+ const now = Date.now();
1547
+ const ms = Math.min(MAX_ENGAGE_MS, Math.round(e.ms + (e.since !== null ? now - e.since : 0)));
1548
+ e.ms = 0;
1549
+ e.since = !final && pageVisible() ? now : null;
1550
+ if (final) engage = null;
1551
+ if (ms <= 0 || isBot2()) return false;
1552
+ const event = { id: newId("n_"), type: "engage", prop: e.prop, vid: visitorId, sid: sessionId, ts: now, url: e.url, ms, scroll: e.scroll };
1553
+ debugLog("pageview", `${e.prop}: ${e.url} engaged ${Math.round(ms / 1e3)} s, scrolled ${e.scroll}%`, event);
1554
+ queue.push(event);
1555
+ return true;
1556
+ };
1557
+ let sentIdentity = browser ? readStored("sessionStorage", UID_SENT_KEY) : null;
1558
+ const sendIdentify = (uid, traits, ts) => {
1559
+ if (!wanted || isBot2() || noVisitor) return;
1560
+ const mark = `${uid}
1561
+ ${traits ? JSON.stringify(traits) : ""}`;
1562
+ withProperty(() => {
1563
+ const prop = property();
1564
+ if (!prop || isBot2() || sentIdentity === mark || browser && readStored("sessionStorage", UID_SENT_KEY) === mark) return;
1565
+ if (typeof __SPLITHUB_LITE__ === "undefined" && devLocal) {
1566
+ hold(`i:${prop}`, "pageview", `${prop}: identify not sent: development never sends to the cloud`);
1567
+ return;
1568
+ }
1569
+ sentIdentity = mark;
1570
+ if (browser) writeStored("sessionStorage", UID_SENT_KEY, mark);
1571
+ const event = { id: newId("i_"), type: "identify", prop, vid: visitorId, sid: sessionId, ts, uid, ...traits ? { traits } : {} };
1572
+ debugLog("info", `${prop}: identify ${uid}`, event);
1573
+ queue.push(event);
1574
+ });
1575
+ };
1576
+ const resendIdentity = (ts) => {
1577
+ const uid = browser ? readStored("localStorage", UID_KEY) : null;
1578
+ if (uid && !(sentIdentity ?? "").startsWith(`${uid}
1579
+ `)) sendIdentify(uid, void 0, ts);
1580
+ };
1581
+ const sendPageGoals = (path, ts) => {
1582
+ if (isBot2()) return;
1583
+ for (const goal of config.goals) {
1584
+ if (goal.type === "pageview" && goal.path && matchPath(goal.path, path)) {
1585
+ debugLog("pageview", `${path} matches goal ${goal.key}`);
1586
+ sendGoal(goal.key, void 0, ts);
1587
+ }
1588
+ }
1589
+ };
1590
+ const endpointKey = resolveEndpoint(config).endpoint;
1591
+ const owner = {};
1592
+ const claimed = /* @__PURE__ */ new Set();
1593
+ const collects = (prop) => {
1594
+ if (claimAnalytics(`${endpointKey}|${prop}`, owner)) {
1595
+ claimed.add(prop);
1596
+ return true;
1597
+ }
1598
+ if (typeof __SPLITHUB_LITE__ === "undefined") devNote(`shared:${prop}`, `Another SplitHub script on this page already collects pageviews for "${prop}", so this one leaves them to it. Keep one install per property: the SDK or sh.js.`);
1599
+ hold(`s:${prop}`, "pageview", `${prop}: pageviews left to the other SplitHub script on this page`);
1600
+ return false;
1601
+ };
1602
+ let lastPage = null;
1603
+ const sendPage = (path, ts) => {
1604
+ if (isBot2()) return;
1605
+ if (!wanted || noVisitor) {
1606
+ sendPageGoals(path, ts);
1607
+ return;
1608
+ }
1609
+ const url = browser && path === pagePath() ? pageUrl() : path;
1610
+ const title = browser && typeof document !== "undefined" ? document.title.slice(0, 200) : "";
1611
+ const ref = browser && typeof document !== "undefined" ? document.referrer.slice(0, 512) : "";
1612
+ withProperty(() => {
1613
+ const prop = property();
1614
+ if (isBot2()) return;
1615
+ if (!prop) {
1616
+ sendPageGoals(path, ts);
1617
+ return;
1618
+ }
1619
+ if (lastPage && lastPage.url === url && ts - lastPage.ts < 1e3) return;
1620
+ lastPage = { url, ts };
1621
+ if (typeof __SPLITHUB_LITE__ === "undefined" && devLocal) {
1622
+ devNote("dev-events", DEV_NOTE);
1623
+ hold(`p:${prop}`, "pageview", `${prop}: pageviews not sent: development never sends to the cloud`);
1624
+ return;
1625
+ }
1626
+ if (!collects(prop)) return;
1627
+ emitEngage(true);
1628
+ const event = { id: newId("p_"), type: "page", prop, vid: visitorId, sid: sessionId, ts, url, ...title ? { title } : {}, ...ref ? { ref } : {} };
1629
+ debugLog("pageview", `${prop}: ${url}`, event);
1630
+ queue.push(event);
1631
+ if (browser) engage = { prop, url, ms: 0, since: pageVisible() ? ts : null, scroll: scrollDepth() };
1632
+ resendIdentity(ts);
1633
+ });
1634
+ };
1635
+ const sendTracked = (name, props, ts) => {
1636
+ if (isBot2()) return;
1637
+ if (!wanted || noVisitor) {
1638
+ sendGoal(name, props, ts);
1639
+ return;
1640
+ }
1641
+ if (!EVENT_NAME_PATTERN.test(name)) {
1642
+ warn(`event name "${name}" is invalid: letters, digits, spaces and "_ . : / -", up to 64 characters.`);
1643
+ sendGoal(name, props, ts);
1644
+ return;
1645
+ }
1646
+ const url = currentUrl();
1647
+ withProperty(() => {
1648
+ const prop = property();
1649
+ if (isBot2()) return;
1650
+ if (!prop) {
1651
+ sendGoal(name, props, ts);
1652
+ return;
1653
+ }
1654
+ if (typeof __SPLITHUB_LITE__ === "undefined" && devLocal) {
1655
+ hold(`v:${prop}:${name}`, "goal", `${prop}: event ${name} not sent: development never sends to the cloud`);
1656
+ return;
1657
+ }
1658
+ const event = { id: newId("v_"), type: "event", prop, name, vid: visitorId, sid: sessionId, ts, url, ...props ? { props } : {} };
1659
+ debugLog("goal", `${prop}: event ${name}${props ? " " + JSON.stringify(props) : ""}`, event);
1660
+ queue.push(event);
1661
+ });
1662
+ };
1663
+ const emit = (name, props) => {
1664
+ if (disabled || isBot2()) return;
1665
+ const ts = Date.now();
1666
+ props = fitProps(props, `event "${name}"`);
1667
+ if (pending) void ready.then(() => sendTracked(name, props, ts));
1668
+ else sendTracked(name, props, ts);
1669
+ };
1670
+ let unwatch = null;
1671
+ const watch = () => {
1672
+ if (unwatch || !browser || options.trackNavigation === false) return;
1673
+ let last = pageUrl();
1674
+ unwatch = onNavigation(() => {
1675
+ const now = pageUrl();
1676
+ if (now === last) return;
1677
+ last = now;
1678
+ client.pageview();
1679
+ });
1680
+ };
1681
+ let unbindPage = null;
1682
+ const bindPage = () => {
1683
+ if (unbindPage || !browser || !wanted || disabled) return;
1684
+ const onScroll = () => {
1685
+ if (engage) engage.scroll = Math.max(engage.scroll, scrollDepth());
1686
+ };
1687
+ const leave = () => {
1688
+ if (emitEngage(false)) void queue.flush(true);
1689
+ if (engage) engage.since = null;
1690
+ };
1691
+ const onVisibility = () => {
1692
+ if (document.visibilityState === "hidden") leave();
1693
+ else if (engage && engage.since === null) engage.since = Date.now();
1694
+ };
1695
+ const onShow = () => {
1696
+ if (engage && engage.since === null && pageVisible()) engage.since = Date.now();
1697
+ };
1698
+ addEventListener("scroll", onScroll, { passive: true });
1699
+ document.addEventListener("visibilitychange", onVisibility);
1700
+ addEventListener("pagehide", leave);
1701
+ addEventListener("pageshow", onShow);
1702
+ unbindPage = () => {
1703
+ removeEventListener("scroll", onScroll);
1704
+ document.removeEventListener("visibilitychange", onVisibility);
1705
+ removeEventListener("pagehide", leave);
1706
+ removeEventListener("pageshow", onShow);
1707
+ };
1708
+ };
1354
1709
  const ready = waitFor ? waitFor.then((fresh) => {
1355
1710
  if (fresh) {
1356
1711
  config = applyRemoteOverrides(base, fresh);
1712
+ propConfig = config;
1357
1713
  context = contextFor(fresh.ctx);
1358
1714
  debugLog("remote", `first visit: overrides v${fresh.version} arrived, experiments decided`, { experiments: fresh.experiments });
1359
1715
  } else {
1360
1716
  debugLog("remote", "first visit: overrides did not arrive in time; experiments follow splithub.config.ts");
1361
1717
  }
1362
1718
  pending = false;
1363
- for (const w of waiting) if ("exp" in w) sendExposure(w.exp, w.ts);
1364
- for (const w of waiting) if ("goal" in w) sendGoal(w.goal, w.props, w.ts);
1719
+ for (const w of waiting) sendExposure(w.exp, w.ts);
1365
1720
  waiting.length = 0;
1366
1721
  for (const listener of [...listeners]) listener();
1367
1722
  listeners.clear();
1368
1723
  }) : Promise.resolve();
1724
+ if (wanted && !known()) {
1725
+ if (arriving) {
1726
+ propertyFetch = withTimeout(arriving, PROPERTY_WAIT_MS).then((fresh) => {
1727
+ if (fresh) propConfig = applyRemoteOverrides(base, fresh);
1728
+ propertyFetch = null;
1729
+ warnUnknownProperty();
1730
+ for (const send of propertyWaiting.splice(0)) send();
1731
+ });
1732
+ } else warnUnknownProperty();
1733
+ }
1369
1734
  const decided = /* @__PURE__ */ new Set();
1370
1735
  const client = {
1371
1736
  get config() {
@@ -1400,7 +1765,7 @@ function createClient(config, options = {}) {
1400
1765
  exposure(experimentKey) {
1401
1766
  if (disabled) return;
1402
1767
  if (pending) {
1403
- if (!waiting.some((w) => "exp" in w && w.exp === experimentKey)) waiting.push({ exp: experimentKey, ts: Date.now() });
1768
+ if (!waiting.some((w) => w.exp === experimentKey)) waiting.push({ exp: experimentKey, ts: Date.now() });
1404
1769
  return;
1405
1770
  }
1406
1771
  sendExposure(experimentKey, Date.now());
@@ -1425,28 +1790,37 @@ function createClient(config, options = {}) {
1425
1790
  client.exposure(experimentKey);
1426
1791
  return (a.variant ?? experiment.variants[0]).value;
1427
1792
  },
1428
- track(goal, props) {
1429
- if (disabled || isBot2()) return;
1430
- if (pending) waiting.push({ goal, ...props ? { props } : {}, ts: Date.now() });
1431
- else sendGoal(goal, props, Date.now());
1793
+ track(name, props) {
1794
+ emit(name, props);
1432
1795
  },
1433
1796
  pageview(path) {
1434
- const current = path ?? (browser ? location.pathname : void 0);
1797
+ const current = path ?? (browser ? pagePath() : void 0);
1435
1798
  if (!current) return;
1799
+ if (path === void 0) watch();
1800
+ bindPage();
1801
+ if (disabled) return;
1436
1802
  if (pending) {
1437
1803
  const ts = Date.now();
1438
- void ready.then(() => {
1439
- if (disabled) return;
1440
- for (const goal of config.goals) if (goal.type === "pageview" && goal.path && matchPath(goal.path, current)) sendGoal(goal.key, void 0, ts);
1441
- });
1804
+ void ready.then(() => sendPage(current, ts));
1442
1805
  return;
1443
1806
  }
1444
- for (const goal of config.goals) {
1445
- if (goal.type === "pageview" && goal.path && matchPath(goal.path, current)) {
1446
- debugLog("pageview", `${current} matches goal ${goal.key}`);
1447
- client.track(goal.key);
1448
- }
1807
+ sendPage(current, Date.now());
1808
+ },
1809
+ identify(uid, traits) {
1810
+ if (uid === null) {
1811
+ writeStored("localStorage", UID_KEY, null);
1812
+ writeStored("sessionStorage", UID_SENT_KEY, null);
1813
+ sentIdentity = null;
1814
+ return;
1449
1815
  }
1816
+ const id = typeof uid === "string" ? uid.trim() : "";
1817
+ if (!id || id.length > 128) {
1818
+ warn("identify() needs a user id of 1 to 128 characters.");
1819
+ return;
1820
+ }
1821
+ if (browser) writeStored("localStorage", UID_KEY, id);
1822
+ if (disabled || isBot2()) return;
1823
+ sendIdentify(id, cleanTraits(traits), Date.now());
1450
1824
  },
1451
1825
  autoGoals(root) {
1452
1826
  if (!browser) return () => void 0;
@@ -1469,7 +1843,15 @@ function createClient(config, options = {}) {
1469
1843
  flush: () => queue.flush(false),
1470
1844
  // Unbinds the page listeners; pending events are kept and a later event binds again,
1471
1845
  // so a provider may destroy on unmount even under StrictMode's double mount.
1472
- destroy: () => queue.destroy()
1846
+ destroy: () => {
1847
+ queue.destroy();
1848
+ unwatch?.();
1849
+ unwatch = null;
1850
+ unbindPage?.();
1851
+ unbindPage = null;
1852
+ for (const prop of claimed) releaseAnalytics(`${endpointKey}|${prop}`, owner);
1853
+ claimed.clear();
1854
+ }
1473
1855
  };
1474
1856
  if (browser && isDebug()) {
1475
1857
  window.__splithub = client;
@@ -1477,6 +1859,25 @@ function createClient(config, options = {}) {
1477
1859
  }
1478
1860
  return client;
1479
1861
  }
1862
+ var navListeners = /* @__PURE__ */ new Set();
1863
+ var historyWrapped = false;
1864
+ function onNavigation(listener) {
1865
+ if (!historyWrapped && typeof history !== "undefined") {
1866
+ historyWrapped = true;
1867
+ for (const method of ["pushState", "replaceState"]) {
1868
+ const original = history[method];
1869
+ history[method] = function(...args) {
1870
+ const out = original.apply(this, args);
1871
+ setTimeout(() => navListeners.forEach((l) => l()), 0);
1872
+ return out;
1873
+ };
1874
+ }
1875
+ addEventListener("popstate", () => navListeners.forEach((l) => l()));
1876
+ addEventListener("hashchange", () => navListeners.forEach((l) => l()));
1877
+ }
1878
+ navListeners.add(listener);
1879
+ return () => void navListeners.delete(listener);
1880
+ }
1480
1881
  function stripUndefined(o) {
1481
1882
  return Object.fromEntries(Object.entries(o).filter(([, v]) => v !== void 0));
1482
1883
  }
@@ -1495,6 +1896,53 @@ function withTimeout(p, ms) {
1495
1896
  );
1496
1897
  });
1497
1898
  }
1899
+ function fitProps(props, what) {
1900
+ if (!props || typeof props !== "object") return void 0;
1901
+ let json;
1902
+ try {
1903
+ json = JSON.stringify(props);
1904
+ } catch {
1905
+ warn(`${what}: props cannot be sent as JSON, so they were left out.`);
1906
+ return void 0;
1907
+ }
1908
+ if (json.length <= MAX_PROPS_BYTES) return props;
1909
+ const out = {};
1910
+ let size = 2;
1911
+ const entries = Object.entries(props).sort(([a], [b]) => a === "revenue" ? -1 : b === "revenue" ? 1 : 0);
1912
+ for (const [key, value] of entries) {
1913
+ if (value !== null && typeof value === "object") continue;
1914
+ const part = JSON.stringify({ [key]: value }).length - 1;
1915
+ if (size + part > MAX_PROPS_BYTES) continue;
1916
+ out[key] = value;
1917
+ size += part;
1918
+ }
1919
+ const kept = Object.keys(out);
1920
+ warn(`${what}: props are larger than 4 KB, so ${kept.length ? `only ${kept.join(", ")} went out` : "none went out"}.`);
1921
+ return kept.length ? out : void 0;
1922
+ }
1923
+ function cleanTraits(traits) {
1924
+ if (!traits || typeof traits !== "object") return void 0;
1925
+ const out = {};
1926
+ let size = 2;
1927
+ let skipped = false;
1928
+ for (const [key, value] of Object.entries(traits)) {
1929
+ const plain = typeof value === "string" || typeof value === "boolean" || typeof value === "number" && Number.isFinite(value);
1930
+ if (!plain || key.length > 64) {
1931
+ if (value !== void 0) skipped = true;
1932
+ continue;
1933
+ }
1934
+ const v = typeof value === "string" ? value.slice(0, 256) : value;
1935
+ const part = JSON.stringify({ [key]: v }).length - 1;
1936
+ if (size + part > MAX_PROPS_BYTES) {
1937
+ skipped = true;
1938
+ continue;
1939
+ }
1940
+ out[key] = v;
1941
+ size += part;
1942
+ }
1943
+ if (skipped) warn("identify(): traits keep text, numbers and true/false up to 4 KB; the rest was left out.");
1944
+ return Object.keys(out).length ? out : void 0;
1945
+ }
1498
1946
  var warned = /* @__PURE__ */ new Set();
1499
1947
  function warn(message) {
1500
1948
  if (warned.has(message)) return;
@@ -1509,6 +1957,7 @@ function warnUnknown(key) {
1509
1957
  CLOUD_ENDPOINT,
1510
1958
  ConfigError,
1511
1959
  EMPTY_OVERRIDES,
1960
+ EVENT_NAME_PATTERN,
1512
1961
  EventQueue,
1513
1962
  HOLDOUT_KEY,
1514
1963
  KEYED_FIELDS,
@@ -1516,6 +1965,7 @@ function warnUnknown(key) {
1516
1965
  MVT_MAX_COMBINATIONS,
1517
1966
  MVT_MAX_FACTORS,
1518
1967
  MVT_MAX_LEVELS,
1968
+ PROPERTY_KEY_PATTERN,
1519
1969
  REMOTE_TTL_MS,
1520
1970
  REMOTE_WAIT_MS,
1521
1971
  SDK_VERSION,
@@ -1535,11 +1985,13 @@ function warnUnknown(key) {
1535
1985
  defineConfig,
1536
1986
  devNote,
1537
1987
  evaluateCondition,
1988
+ eventKey,
1538
1989
  explainAssignment,
1539
1990
  fetchRemoteOverrides,
1540
1991
  getExperiment,
1541
1992
  getOrCreateSessionId,
1542
1993
  getOrCreateVisitorId,
1994
+ goalKeyFor,
1543
1995
  hasVisitorId,
1544
1996
  hashToUnit,
1545
1997
  holdoutExperiment,
@@ -1562,16 +2014,21 @@ function warnUnknown(key) {
1562
2014
  murmur3,
1563
2015
  mvtVariants,
1564
2016
  newId,
2017
+ newPropertyId,
1565
2018
  newSessionId,
1566
2019
  newVisitorId,
1567
2020
  normalizePath,
2021
+ normalizeProperty,
1568
2022
  onDebug,
1569
2023
  parseCookies,
1570
2024
  parseForceParam,
1571
2025
  parseUserAgent,
2026
+ pickProperty,
1572
2027
  pickVariant,
1573
2028
  readRemoteCache,
1574
2029
  redirectTarget,
2030
+ referrerOrigin,
2031
+ resetAnalyticsClaims,
1575
2032
  resetDevNotes,
1576
2033
  resolveOverridesUrl,
1577
2034
  runFlow,