@founderhq/journeys 0.8.1 → 1.0.0

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
@@ -90,6 +90,111 @@ var init_motion_features = __esm({
90
90
  motion_features_default = react.domMax;
91
91
  }
92
92
  });
93
+
94
+ // src/lib/web-fonts.ts
95
+ var FONT_VARIABLE = "--jy-font-family";
96
+ var BUILT_IN_FAMILIES = /* @__PURE__ */ new Set([
97
+ "inter",
98
+ "inter variable",
99
+ "lora",
100
+ "lora variable",
101
+ "google sans",
102
+ "product sans",
103
+ "serif",
104
+ "sans-serif",
105
+ "monospace",
106
+ "cursive",
107
+ "fantasy",
108
+ "system-ui",
109
+ "ui-serif",
110
+ "ui-sans-serif",
111
+ "ui-monospace",
112
+ "ui-rounded",
113
+ "math",
114
+ "emoji",
115
+ "inherit",
116
+ "initial",
117
+ "unset",
118
+ "georgia",
119
+ "times new roman",
120
+ "arial",
121
+ "helvetica",
122
+ "helvetica neue",
123
+ "courier new",
124
+ "segoe ui",
125
+ "sf pro text",
126
+ "blinkmacsystemfont",
127
+ "-apple-system"
128
+ ]);
129
+ var FAMILY_NAME = /^[A-Za-z0-9][A-Za-z0-9 ]{0,62}$/;
130
+ function firstFontFamily(stack) {
131
+ var _a;
132
+ const first = (_a = stack == null ? void 0 : stack.split(",", 1)[0]) == null ? void 0 : _a.trim();
133
+ if (!first) return void 0;
134
+ const name = first.replace(/^(['"])(.*)\1$/, "$2").trim();
135
+ return name || void 0;
136
+ }
137
+ function isWebFontFamily(family) {
138
+ if (!family) return false;
139
+ if (!FAMILY_NAME.test(family)) return false;
140
+ return !BUILT_IN_FAMILIES.has(family.toLowerCase());
141
+ }
142
+ function collectFontFamilies(value, found) {
143
+ if (Array.isArray(value)) {
144
+ for (const item of value) collectFontFamilies(item, found);
145
+ return;
146
+ }
147
+ if (!value || typeof value !== "object") return;
148
+ for (const [key, child] of Object.entries(value)) {
149
+ if (key === "fontFamily" && typeof child === "string") {
150
+ const family = firstFontFamily(child);
151
+ if (isWebFontFamily(family)) found.add(family);
152
+ } else {
153
+ collectFontFamilies(child, found);
154
+ }
155
+ }
156
+ }
157
+ function getJourneyWebFontFamilies(config) {
158
+ var _a;
159
+ const found = /* @__PURE__ */ new Set();
160
+ const journeyFont = firstFontFamily((_a = config.themeVariables) == null ? void 0 : _a[FONT_VARIABLE]);
161
+ if (isWebFontFamily(journeyFont)) found.add(journeyFont);
162
+ collectFontFamilies(config.steps, found);
163
+ const byName = /* @__PURE__ */ new Map();
164
+ for (const family of found) {
165
+ const key = family.toLowerCase();
166
+ if (!byName.has(key)) byName.set(key, family);
167
+ }
168
+ return [...byName.values()].sort((a, b) => a.localeCompare(b));
169
+ }
170
+ function getWebFontStylesheetUrl(family) {
171
+ const name = family.trim().toLowerCase().replace(/\s+/g, "-");
172
+ return `https://fonts.bunny.net/css?family=${encodeURIComponent(name)}:300,300i,400,400i,500,500i,600,600i,700,700i,800,900&display=swap`;
173
+ }
174
+
175
+ // src/engine/use-journey-web-fonts.ts
176
+ var LINK_MARK = "data-journey-web-font";
177
+ function useJourneyWebFonts(config) {
178
+ const families = React.useMemo(() => getJourneyWebFontFamilies(config), [config]);
179
+ const signature = families.join("|");
180
+ React.useEffect(() => {
181
+ var _a;
182
+ if (typeof document === "undefined" || !signature) return;
183
+ for (const family of signature.split("|")) {
184
+ const key = family.toLowerCase();
185
+ if (document.head.querySelector(`link[${LINK_MARK}="${key}"]`)) continue;
186
+ const onPage = [...(_a = document.fonts) != null ? _a : []].some(
187
+ (face) => face.family.replace(/^(['"])(.*)\1$/, "$2").toLowerCase() === key
188
+ );
189
+ if (onPage) continue;
190
+ const link = document.createElement("link");
191
+ link.rel = "stylesheet";
192
+ link.href = getWebFontStylesheetUrl(family);
193
+ link.setAttribute(LINK_MARK, key);
194
+ document.head.append(link);
195
+ }
196
+ }, [signature]);
197
+ }
93
198
  var JourneyPresentationContext = React.createContext(true);
94
199
  function useJourneyPresented() {
95
200
  return React.useContext(JourneyPresentationContext);
@@ -2739,6 +2844,7 @@ function useJourneyProviderRuntime({
2739
2844
  () => getComputedVariableIds(config.computedVariables),
2740
2845
  [config.computedVariables]
2741
2846
  );
2847
+ useJourneyWebFonts(config);
2742
2848
  const providerThemeStyle = React.useMemo(() => {
2743
2849
  const themeVariables = config.themeVariables ? Object.fromEntries(
2744
2850
  Object.entries(config.themeVariables).filter(
@@ -4715,7 +4821,7 @@ function resolveJourneyFontFamily(fontFamily) {
4715
4821
  case "google sans":
4716
4822
  return GOOGLE_SANS_STACK;
4717
4823
  default:
4718
- return value;
4824
+ return value.includes(",") ? value : `"${value.replace(/^(['"])(.*)\1$/, "$2")}", ${INTER_STACK}`;
4719
4825
  }
4720
4826
  }
4721
4827
 
@@ -12442,6 +12548,190 @@ function JourneyShell({
12442
12548
  }
12443
12549
  );
12444
12550
  }
12551
+
12552
+ // src/engine/events-identity.ts
12553
+ var NO_IDENTITY = { source: "none" };
12554
+ function eventsStorageKey(apiKey) {
12555
+ return `founderhq:events:v2:${apiKey.trim().slice(0, 16)}`;
12556
+ }
12557
+ function eventsConsentCookieName(apiKey) {
12558
+ return `fhq_consent_${writeKeyFingerprint(apiKey.trim())}`;
12559
+ }
12560
+ function eventsIdentityCookieName(apiKey) {
12561
+ return `fhq_id_${apiKey.trim().replace(/[^a-zA-Z0-9]/g, "").slice(0, 16)}`;
12562
+ }
12563
+ function writeKeyFingerprint(apiKey) {
12564
+ let hash = 2166136261;
12565
+ for (let index = 0; index < apiKey.length; index++) {
12566
+ hash ^= apiKey.charCodeAt(index);
12567
+ hash = Math.imul(hash, 16777619);
12568
+ }
12569
+ return (hash >>> 0).toString(36).padStart(7, "0");
12570
+ }
12571
+ function readEventsConsent(apiKey) {
12572
+ const value = readCookie(eventsConsentCookieName(apiKey));
12573
+ if (value === "v1.g") return "granted";
12574
+ if (value === "v1.d") return "denied";
12575
+ if (value === "v1.o") return "off";
12576
+ return null;
12577
+ }
12578
+ function findGlobalEventsClient() {
12579
+ const candidate = globalThis.founderhq;
12580
+ return isEventsClient(candidate) ? candidate : null;
12581
+ }
12582
+ function isEventsClient(value) {
12583
+ return Boolean(value) && typeof value === "object" && typeof value.getDistinctId === "function" && typeof value.checkoutMetadata === "function";
12584
+ }
12585
+ function resolveJourneyIdentity(options, storage, now = Date.now) {
12586
+ var _a, _b;
12587
+ const client = options.eventsClient === false ? null : (_a = options.eventsClient) != null ? _a : findGlobalEventsClient();
12588
+ const answer = client ? askEventsClient(client) : "absent";
12589
+ if (typeof answer === "object") return answer;
12590
+ const remembered = readEventsConsent(options.apiKey);
12591
+ if (remembered === "denied" || remembered === "off") return NO_IDENTITY;
12592
+ const key = eventsStorageKey(options.apiKey);
12593
+ if (answer === "silent") {
12594
+ const state2 = readEventsIdentity(options.apiKey, storage, key);
12595
+ return state2 && !state2.opted_out ? identityFromState(state2) : NO_IDENTITY;
12596
+ }
12597
+ const consent = (_b = remembered != null ? remembered : options.consentDefault) != null ? _b : "granted";
12598
+ if (consent !== "granted") return NO_IDENTITY;
12599
+ const state = readOrMintEventsState(options.apiKey, key, storage, now);
12600
+ return state ? identityFromState(state) : NO_IDENTITY;
12601
+ }
12602
+ function askEventsClient(client) {
12603
+ var _a;
12604
+ try {
12605
+ const metadata = client.checkoutMetadata();
12606
+ const anonymousId = cleanId(metadata.fhq_anonymous_id);
12607
+ if (!anonymousId) return "silent";
12608
+ return {
12609
+ anonymousId,
12610
+ distinctId: (_a = cleanId(client.getDistinctId())) != null ? _a : anonymousId,
12611
+ sessionId: cleanId(metadata.fhq_session_id),
12612
+ source: "events"
12613
+ };
12614
+ } catch (e) {
12615
+ return "absent";
12616
+ }
12617
+ }
12618
+ function identityFromState(state) {
12619
+ return {
12620
+ anonymousId: state.anonymous_id,
12621
+ distinctId: state.distinct_id,
12622
+ source: "storage"
12623
+ };
12624
+ }
12625
+ var memoryState = /* @__PURE__ */ new Map();
12626
+ function readOrMintEventsState(apiKey, key, storage, now) {
12627
+ var _a;
12628
+ const existing = (_a = readEventsIdentity(apiKey, storage, key)) != null ? _a : memoryState.get(key);
12629
+ if (existing) return existing.opted_out ? null : existing;
12630
+ const id = createUuid();
12631
+ const state = {
12632
+ anonymous_id: id,
12633
+ anonymous_created_at: now(),
12634
+ distinct_id: id,
12635
+ identified: false,
12636
+ registered: {},
12637
+ pending_set: {},
12638
+ pending_set_once: {},
12639
+ opted_out: false,
12640
+ queue: []
12641
+ };
12642
+ try {
12643
+ storage == null ? void 0 : storage.setItem(key, JSON.stringify(state));
12644
+ } catch (e) {
12645
+ }
12646
+ memoryState.set(key, state);
12647
+ return state;
12648
+ }
12649
+ function readEventsIdentity(apiKey, storage, key) {
12650
+ const stored = readEventsState(storage, key);
12651
+ const cookie = readEventsIdentityCookie(apiKey);
12652
+ if (!cookie) return stored;
12653
+ if (!stored) return cookie;
12654
+ return __spreadProps(__spreadValues({}, stored), {
12655
+ anonymous_id: cookie.anonymous_id,
12656
+ anonymous_created_at: cookie.anonymous_created_at,
12657
+ distinct_id: cookie.distinct_id,
12658
+ identified: cookie.identified,
12659
+ opted_out: stored.opted_out || cookie.opted_out
12660
+ });
12661
+ }
12662
+ function readEventsIdentityCookie(apiKey) {
12663
+ const raw = readCookie(eventsIdentityCookieName(apiKey));
12664
+ if (!raw) return null;
12665
+ try {
12666
+ const value = JSON.parse(raw);
12667
+ if (typeof value.a !== "string" || !value.a) return null;
12668
+ return {
12669
+ anonymous_id: value.a,
12670
+ anonymous_created_at: typeof value.c === "number" ? value.c : 0,
12671
+ distinct_id: typeof value.d === "string" && value.d ? value.d : value.a,
12672
+ identified: value.i === 1,
12673
+ registered: {},
12674
+ pending_set: {},
12675
+ pending_set_once: {},
12676
+ opted_out: value.o === 1,
12677
+ queue: []
12678
+ };
12679
+ } catch (e) {
12680
+ return null;
12681
+ }
12682
+ }
12683
+ function readEventsState(storage, key) {
12684
+ var _a, _b, _c;
12685
+ try {
12686
+ const raw = storage == null ? void 0 : storage.getItem(key);
12687
+ if (!raw) return null;
12688
+ const parsed = JSON.parse(raw);
12689
+ if (typeof parsed.anonymous_id !== "string" || !parsed.anonymous_id) {
12690
+ return null;
12691
+ }
12692
+ return {
12693
+ anonymous_id: parsed.anonymous_id,
12694
+ anonymous_created_at: typeof parsed.anonymous_created_at === "number" ? parsed.anonymous_created_at : 0,
12695
+ distinct_id: typeof parsed.distinct_id === "string" && parsed.distinct_id ? parsed.distinct_id : parsed.anonymous_id,
12696
+ identified: parsed.identified === true,
12697
+ registered: (_a = parsed.registered) != null ? _a : {},
12698
+ pending_set: (_b = parsed.pending_set) != null ? _b : {},
12699
+ pending_set_once: (_c = parsed.pending_set_once) != null ? _c : {},
12700
+ opted_out: parsed.opted_out === true,
12701
+ queue: Array.isArray(parsed.queue) ? parsed.queue : []
12702
+ };
12703
+ } catch (e) {
12704
+ return null;
12705
+ }
12706
+ }
12707
+ function cleanId(value) {
12708
+ const clean = value == null ? void 0 : value.trim();
12709
+ return clean || void 0;
12710
+ }
12711
+ function readCookie(name) {
12712
+ if (typeof document === "undefined") return null;
12713
+ try {
12714
+ const prefix = `${name}=`;
12715
+ for (const part of document.cookie.split(";")) {
12716
+ const trimmed = part.trim();
12717
+ if (trimmed.startsWith(prefix)) {
12718
+ return decodeURIComponent(trimmed.slice(prefix.length));
12719
+ }
12720
+ }
12721
+ } catch (e) {
12722
+ }
12723
+ return null;
12724
+ }
12725
+ function createUuid() {
12726
+ var _a, _b;
12727
+ const cryptoRef = globalThis.crypto;
12728
+ if (cryptoRef == null ? void 0 : cryptoRef.randomUUID) return cryptoRef.randomUUID();
12729
+ const bytes = (_b = (_a = cryptoRef == null ? void 0 : cryptoRef.getRandomValues) == null ? void 0 : _a.call(cryptoRef, new Uint8Array(16))) != null ? _b : Uint8Array.from({ length: 16 }, () => Math.floor(Math.random() * 256));
12730
+ bytes[6] = bytes[6] & 15 | 64;
12731
+ bytes[8] = bytes[8] & 63 | 128;
12732
+ const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
12733
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
12734
+ }
12445
12735
  var FOUNDERHQ_BASE_URL = "https://app.getfounderhq.com";
12446
12736
  function resolveJourneyBaseUrl(baseUrl) {
12447
12737
  if (!baseUrl) return FOUNDERHQ_BASE_URL;
@@ -12534,7 +12824,7 @@ function useJourneyConfig({
12534
12824
 
12535
12825
  // src/engine/journey-capture.ts
12536
12826
  var JOURNEY_LIBRARY_NAME = "@founderhq/journeys";
12537
- var JOURNEY_LIBRARY_VERSION = "0.8.0";
12827
+ var JOURNEY_LIBRARY_VERSION = "1.0.0";
12538
12828
  var DEFAULT_QUEUE_TTL_MS = 24 * 60 * 60 * 1e3;
12539
12829
  var MAX_QUEUED_CAPTURE_EVENTS = 100;
12540
12830
  var MAX_BEACON_BYTES = 60 * 1024;
@@ -12566,7 +12856,8 @@ function safeBrowserStorage(name) {
12566
12856
  function isQueuedCaptureEvent(value) {
12567
12857
  if (!isRecord2(value)) return false;
12568
12858
  const event = value.event;
12569
- return isRecord2(event) && typeof event.id === "string" && typeof event.type === "string" && typeof event.occurredAt === "string" && typeof value.attempts === "number" && typeof value.createdAt === "number";
12859
+ const envelope = value.envelope;
12860
+ return isRecord2(event) && typeof event.id === "string" && typeof event.type === "string" && typeof event.occurredAt === "string" && isRecord2(envelope) && typeof envelope.clientSessionId === "string" && isRecord2(envelope.context) && typeof value.attempts === "number" && typeof value.createdAt === "number";
12570
12861
  }
12571
12862
  function pruneQueuedEvents(queue, now = Date.now(), ttlMs = DEFAULT_QUEUE_TTL_MS) {
12572
12863
  const cutoff = now - ttlMs;
@@ -12578,25 +12869,12 @@ function readPersistedCaptureQueue(storage, key) {
12578
12869
  const raw = storage.getItem(key);
12579
12870
  if (!raw) return null;
12580
12871
  const parsed = JSON.parse(raw);
12581
- if (typeof parsed.visitorId !== "string" || typeof parsed.clientSessionId !== "string") {
12582
- return null;
12583
- }
12872
+ if (typeof parsed.clientSessionId !== "string") return null;
12584
12873
  const queue = Array.isArray(parsed.queue) ? pruneQueuedEvents(parsed.queue.filter(isQueuedCaptureEvent)) : [];
12585
12874
  return {
12586
- visitorId: parsed.visitorId,
12587
12875
  clientSessionId: parsed.clientSessionId,
12588
12876
  updatedAt: typeof parsed.updatedAt === "number" ? parsed.updatedAt : Date.now(),
12589
- queue: queue.map((item) => {
12590
- var _a;
12591
- return __spreadProps(__spreadValues({}, item), {
12592
- // Legacy persisted headers belong to the original batch, never the new presentation.
12593
- envelope: (_a = item.envelope) != null ? _a : {
12594
- visitorId: parsed.visitorId,
12595
- clientSessionId: parsed.clientSessionId,
12596
- context: {}
12597
- }
12598
- });
12599
- })
12877
+ queue
12600
12878
  };
12601
12879
  } catch (e) {
12602
12880
  return null;
@@ -12613,7 +12891,6 @@ function persistCaptureQueue(storage, runtime, queue) {
12613
12891
  storage.setItem(
12614
12892
  runtime.queueKey,
12615
12893
  JSON.stringify({
12616
- visitorId: runtime.visitorId,
12617
12894
  clientSessionId: runtime.clientSessionId,
12618
12895
  updatedAt: Date.now(),
12619
12896
  queue: pruned
@@ -12712,7 +12989,17 @@ function pageContext(redactUrlParams) {
12712
12989
  campaign
12713
12990
  });
12714
12991
  }
12715
- function captureContext(capture, runtime) {
12992
+ function currentIdentity(capture) {
12993
+ return resolveJourneyIdentity(
12994
+ {
12995
+ apiKey: capture.apiKey,
12996
+ eventsClient: capture.eventsClient,
12997
+ consentDefault: capture.consentDefault
12998
+ },
12999
+ safeBrowserStorage("localStorage")
13000
+ );
13001
+ }
13002
+ function captureContext(capture, identity) {
12716
13003
  var _a, _b;
12717
13004
  const customContext = cleanObject(__spreadValues(__spreadValues({}, (_a = capture.context) != null ? _a : {}), (_b = safeContextFactory(capture.contextFactory)) != null ? _b : {}));
12718
13005
  if (capture.captureContext === false) {
@@ -12727,8 +13014,13 @@ function captureContext(capture, runtime) {
12727
13014
  name: JOURNEY_LIBRARY_NAME,
12728
13015
  version: JOURNEY_LIBRARY_VERSION
12729
13016
  },
12730
- anonymousId: runtime.visitorId,
12731
- sessionId: runtime.clientSessionId,
13017
+ // The same ids the events SDK sends, so the server joins this session
13018
+ // to the visitor's contact the way it joins an event. Absent when the
13019
+ // visit is cookieless.
13020
+ anonymousId: identity.anonymousId,
13021
+ distinctId: identity.distinctId,
13022
+ sessionId: identity.sessionId,
13023
+ identitySource: identity.source,
12732
13024
  locale: navigatorRef == null ? void 0 : navigatorRef.language,
12733
13025
  timezone: safeTimezone(),
12734
13026
  userAgent: navigatorRef == null ? void 0 : navigatorRef.userAgent,
@@ -12758,12 +13050,7 @@ function safeSendBeacon() {
12758
13050
  }
12759
13051
  async function sendCaptureBatch(capture, runtime, batch, options = {}) {
12760
13052
  var _a, _b;
12761
- const payload = __spreadProps(__spreadValues(__spreadValues({}, !capture.transport && options.preferBeacon ? { apiKey: capture.apiKey } : {}), (_b = (_a = batch[0]) == null ? void 0 : _a.envelope) != null ? _b : {
12762
- clientSessionId: runtime.clientSessionId,
12763
- visitorId: runtime.visitorId,
12764
- revisionId: capture.revisionId,
12765
- context: captureContext(capture, runtime)
12766
- }), {
13053
+ const payload = __spreadProps(__spreadValues(__spreadValues({}, !capture.transport && options.preferBeacon ? { apiKey: capture.apiKey } : {}), (_b = (_a = batch[0]) == null ? void 0 : _a.envelope) != null ? _b : buildEnvelope(capture, runtime)), {
12767
13054
  events: batch.map((item) => item.event)
12768
13055
  });
12769
13056
  const url = captureUrl(capture);
@@ -12813,6 +13100,15 @@ async function sendCaptureBatch(capture, runtime, batch, options = {}) {
12813
13100
  return "failed";
12814
13101
  }
12815
13102
  }
13103
+ function buildEnvelope(capture, runtime) {
13104
+ const identity = currentIdentity(capture);
13105
+ return {
13106
+ visitorId: identity.anonymousId,
13107
+ clientSessionId: runtime.clientSessionId,
13108
+ revisionId: capture.revisionId,
13109
+ context: captureContext(capture, identity)
13110
+ };
13111
+ }
12816
13112
  function finiteRetryDelay(value) {
12817
13113
  return typeof value === "number" && Number.isFinite(value) ? Math.max(0, value) : 0;
12818
13114
  }
@@ -12975,13 +13271,13 @@ function useJourneyCaptureRuntime(params) {
12975
13271
  );
12976
13272
  }, []);
12977
13273
  const ensureRuntime = React.useCallback((capture) => {
12978
- var _a, _b, _c, _d, _e;
13274
+ var _a, _b, _c, _d;
12979
13275
  if (typeof window === "undefined") return null;
12980
13276
  const queueKey = `fhq_journey_queue:v2:${capture.apiKey.slice(
12981
13277
  0,
12982
13278
  16
12983
13279
  )}:${capture.journeyId}`;
12984
- const presentationKey = `${(_a = capture.clientSessionId) != null ? _a : "legacy"}:${(_b = capture.revisionId) != null ? _b : ""}`;
13280
+ const presentationKey = `${(_a = capture.clientSessionId) != null ? _a : "runtime"}:${(_b = capture.revisionId) != null ? _b : ""}`;
12985
13281
  const existing = runtimeRef.current;
12986
13282
  if ((existing == null ? void 0 : existing.queueKey) === queueKey && existing.presentationKey === presentationKey) {
12987
13283
  return existing;
@@ -12990,22 +13286,20 @@ function useJourneyCaptureRuntime(params) {
12990
13286
  const session = safeBrowserStorage("sessionStorage");
12991
13287
  if (existing) persistCaptureQueue(local, existing, queueRef.current);
12992
13288
  const persisted = readPersistedCaptureQueue(local, queueKey);
12993
- const visitorId = (_c = persisted == null ? void 0 : persisted.visitorId) != null ? _c : local ? getStoredId(local, "fhq_journey_visitor_id", "fhqv") : randomId("fhqv");
12994
13289
  const sessionKey = `fhq_journey_session:${capture.journeyId}`;
12995
- const clientSessionId = (_d = capture.clientSessionId) != null ? _d : session ? getStoredId(session, sessionKey, "fhqs") : randomId("fhqs");
13290
+ const clientSessionId = (_c = capture.clientSessionId) != null ? _c : session ? getStoredId(session, sessionKey, "fhqs") : randomId("fhqs");
12996
13291
  try {
12997
13292
  session == null ? void 0 : session.setItem(sessionKey, clientSessionId);
12998
13293
  } catch (e) {
12999
13294
  }
13000
13295
  const runtime = {
13001
13296
  journeyId: capture.journeyId,
13002
- visitorId,
13003
13297
  clientSessionId,
13004
13298
  queueKey,
13005
13299
  presentationKey
13006
13300
  };
13007
13301
  runtimeRef.current = runtime;
13008
- queueRef.current = (_e = persisted == null ? void 0 : persisted.queue) != null ? _e : [];
13302
+ queueRef.current = (_d = persisted == null ? void 0 : persisted.queue) != null ? _d : [];
13009
13303
  return runtime;
13010
13304
  }, []);
13011
13305
  const flush = React.useCallback(
@@ -13022,10 +13316,7 @@ function useJourneyCaptureRuntime(params) {
13022
13316
  if (first && ((_b = first.retryAt) != null ? _b : 0) > Date.now()) return;
13023
13317
  const envelope = first == null ? void 0 : first.envelope;
13024
13318
  const batch = queueRef.current.filter(
13025
- (item) => {
13026
- var _a2, _b2;
13027
- return ((_a2 = item.envelope) == null ? void 0 : _a2.clientSessionId) === (envelope == null ? void 0 : envelope.clientSessionId) && ((_b2 = item.envelope) == null ? void 0 : _b2.revisionId) === (envelope == null ? void 0 : envelope.revisionId);
13028
- }
13319
+ (item) => item.envelope.clientSessionId === (envelope == null ? void 0 : envelope.clientSessionId) && item.envelope.revisionId === (envelope == null ? void 0 : envelope.revisionId)
13029
13320
  ).slice(0, options.preferBeacon ? Math.min(batchSize, 5) : batchSize);
13030
13321
  if (batch.length === 0) {
13031
13322
  persistQueue();
@@ -13107,12 +13398,7 @@ function useJourneyCaptureRuntime(params) {
13107
13398
  if (!runtime) return;
13108
13399
  sequenceRef.current += 1;
13109
13400
  queueRef.current.push({
13110
- envelope: {
13111
- visitorId: runtime.visitorId,
13112
- clientSessionId: runtime.clientSessionId,
13113
- revisionId: capture.revisionId,
13114
- context: captureContext(capture, runtime)
13115
- },
13401
+ envelope: buildEnvelope(capture, runtime),
13116
13402
  event: toCaptureEvent(
13117
13403
  config,
13118
13404
  event,
@@ -13282,13 +13568,18 @@ exports.createStepTypeChangePatch = createStepTypeChangePatch;
13282
13568
  exports.createStepTypeDefaults = createStepTypeDefaults;
13283
13569
  exports.createVariableName = createVariableName;
13284
13570
  exports.evaluateCondition = evaluateCondition;
13571
+ exports.eventsStorageKey = eventsStorageKey;
13572
+ exports.firstFontFamily = firstFontFamily;
13573
+ exports.getJourneyWebFontFamilies = getJourneyWebFontFamilies;
13285
13574
  exports.getScreenNameError = getScreenNameError;
13286
13575
  exports.getStableItemEntries = getStableItemEntries;
13287
13576
  exports.getStepVariable = getStepVariable;
13288
13577
  exports.getVariableNameError = getVariableNameError;
13578
+ exports.getWebFontStylesheetUrl = getWebFontStylesheetUrl;
13289
13579
  exports.hasVisibleProgress = hasVisibleProgress;
13290
13580
  exports.isValidScreenName = isValidScreenName;
13291
13581
  exports.isValidVariableName = isValidVariableName;
13582
+ exports.isWebFontFamily = isWebFontFamily;
13292
13583
  exports.normalizeBlockConfig = normalizeBlockConfig;
13293
13584
  exports.normalizeBlockConfigs = normalizeBlockConfigs;
13294
13585
  exports.normalizeJourneyConfig = normalizeJourneyConfig;
@@ -13301,9 +13592,11 @@ exports.resolveComputedVariableValues = resolveComputedVariableValues;
13301
13592
  exports.resolveComputedVariables = resolveComputedVariables;
13302
13593
  exports.resolveJourneyBlobDefaultSize = resolveJourneyBlobDefaultSize;
13303
13594
  exports.resolveJourneyFontFamily = resolveJourneyFontFamily;
13595
+ exports.resolveJourneyIdentity = resolveJourneyIdentity;
13304
13596
  exports.resolveStepBackgroundMode = resolveStepBackgroundMode;
13305
13597
  exports.useJourneyActions = useJourneyActions;
13306
13598
  exports.useJourneyCaptureRuntime = useJourneyCaptureRuntime;
13307
13599
  exports.useJourneyConfig = useJourneyConfig;
13308
13600
  exports.useJourneyState = useJourneyState;
13601
+ exports.useJourneyWebFonts = useJourneyWebFonts;
13309
13602
  exports.withDeterministicItemIds = withDeterministicItemIds;
package/dist/index.d.cts CHANGED
@@ -9,6 +9,11 @@ export { JourneyCaptureTransport } from './_tsup-dts-rollup.cjs';
9
9
  export { JourneyCaptureTransportRequest } from './_tsup-dts-rollup.cjs';
10
10
  export { JourneyIdentity } from './_tsup-dts-rollup.cjs';
11
11
  export { useJourneyCaptureRuntime } from './_tsup-dts-rollup.cjs';
12
+ export { JourneyCaptureIdentity } from './_tsup-dts-rollup.cjs';
13
+ export { JourneyEventsClient } from './_tsup-dts-rollup.cjs';
14
+ export { JourneyEventsConsent } from './_tsup-dts-rollup.cjs';
15
+ export { eventsStorageKey } from './_tsup-dts-rollup.cjs';
16
+ export { resolveJourneyIdentity } from './_tsup-dts-rollup.cjs';
12
17
  export { JourneyHapticContext } from './_tsup-dts-rollup.cjs';
13
18
  export { JourneyHapticHandler } from './_tsup-dts-rollup.cjs';
14
19
  export { JourneyHapticType } from './_tsup-dts-rollup.cjs';
@@ -58,6 +63,11 @@ export { isValidVariableName } from './_tsup-dts-rollup.cjs';
58
63
  export { normalizeScreenName } from './_tsup-dts-rollup.cjs';
59
64
  export { renameAnswerVariableReferences } from './_tsup-dts-rollup.cjs';
60
65
  export { renameVariableInExpression } from './_tsup-dts-rollup.cjs';
66
+ export { useJourneyWebFonts } from './_tsup-dts-rollup.cjs';
67
+ export { firstFontFamily } from './_tsup-dts-rollup.cjs';
68
+ export { getJourneyWebFontFamilies } from './_tsup-dts-rollup.cjs';
69
+ export { getWebFontStylesheetUrl } from './_tsup-dts-rollup.cjs';
70
+ export { isWebFontFamily } from './_tsup-dts-rollup.cjs';
61
71
  export { resolveComputedVariables } from './_tsup-dts-rollup.cjs';
62
72
  export { resolveComputedVariableValues } from './_tsup-dts-rollup.cjs';
63
73
  export { GravityBin } from './_tsup-dts-rollup.cjs';
package/dist/index.d.ts CHANGED
@@ -9,6 +9,11 @@ export { JourneyCaptureTransport } from './_tsup-dts-rollup.js';
9
9
  export { JourneyCaptureTransportRequest } from './_tsup-dts-rollup.js';
10
10
  export { JourneyIdentity } from './_tsup-dts-rollup.js';
11
11
  export { useJourneyCaptureRuntime } from './_tsup-dts-rollup.js';
12
+ export { JourneyCaptureIdentity } from './_tsup-dts-rollup.js';
13
+ export { JourneyEventsClient } from './_tsup-dts-rollup.js';
14
+ export { JourneyEventsConsent } from './_tsup-dts-rollup.js';
15
+ export { eventsStorageKey } from './_tsup-dts-rollup.js';
16
+ export { resolveJourneyIdentity } from './_tsup-dts-rollup.js';
12
17
  export { JourneyHapticContext } from './_tsup-dts-rollup.js';
13
18
  export { JourneyHapticHandler } from './_tsup-dts-rollup.js';
14
19
  export { JourneyHapticType } from './_tsup-dts-rollup.js';
@@ -58,6 +63,11 @@ export { isValidVariableName } from './_tsup-dts-rollup.js';
58
63
  export { normalizeScreenName } from './_tsup-dts-rollup.js';
59
64
  export { renameAnswerVariableReferences } from './_tsup-dts-rollup.js';
60
65
  export { renameVariableInExpression } from './_tsup-dts-rollup.js';
66
+ export { useJourneyWebFonts } from './_tsup-dts-rollup.js';
67
+ export { firstFontFamily } from './_tsup-dts-rollup.js';
68
+ export { getJourneyWebFontFamilies } from './_tsup-dts-rollup.js';
69
+ export { getWebFontStylesheetUrl } from './_tsup-dts-rollup.js';
70
+ export { isWebFontFamily } from './_tsup-dts-rollup.js';
61
71
  export { resolveComputedVariables } from './_tsup-dts-rollup.js';
62
72
  export { resolveComputedVariableValues } from './_tsup-dts-rollup.js';
63
73
  export { GravityBin } from './_tsup-dts-rollup.js';