@intlayer/analytics 9.0.0-canary.16

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.
Files changed (84) hide show
  1. package/README.md +330 -0
  2. package/dist/cjs/core/AnalyticsClient.cjs +182 -0
  3. package/dist/cjs/core/AnalyticsClient.cjs.map +1 -0
  4. package/dist/cjs/core/abTesting.cjs +44 -0
  5. package/dist/cjs/core/abTesting.cjs.map +1 -0
  6. package/dist/cjs/core/eventBuffer.cjs +68 -0
  7. package/dist/cjs/core/eventBuffer.cjs.map +1 -0
  8. package/dist/cjs/core/globalManager.cjs +63 -0
  9. package/dist/cjs/core/globalManager.cjs.map +1 -0
  10. package/dist/cjs/core/index.cjs +26 -0
  11. package/dist/cjs/core/initAnalyticsClient.cjs +51 -0
  12. package/dist/cjs/core/initAnalyticsClient.cjs.map +1 -0
  13. package/dist/cjs/core/sampling.cjs +28 -0
  14. package/dist/cjs/core/sampling.cjs.map +1 -0
  15. package/dist/cjs/core/session.cjs +42 -0
  16. package/dist/cjs/core/session.cjs.map +1 -0
  17. package/dist/cjs/core/transport.cjs +47 -0
  18. package/dist/cjs/core/transport.cjs.map +1 -0
  19. package/dist/cjs/core/types.cjs +0 -0
  20. package/dist/cjs/events/contentExposure.cjs +39 -0
  21. package/dist/cjs/events/contentExposure.cjs.map +1 -0
  22. package/dist/cjs/index.cjs +29 -0
  23. package/dist/cjs/isEnabled.cjs +29 -0
  24. package/dist/cjs/isEnabled.cjs.map +1 -0
  25. package/dist/cjs/utils/hash.cjs +26 -0
  26. package/dist/cjs/utils/hash.cjs.map +1 -0
  27. package/dist/cjs/utils/idle.cjs +26 -0
  28. package/dist/cjs/utils/idle.cjs.map +1 -0
  29. package/dist/esm/core/AnalyticsClient.mjs +177 -0
  30. package/dist/esm/core/AnalyticsClient.mjs.map +1 -0
  31. package/dist/esm/core/abTesting.mjs +43 -0
  32. package/dist/esm/core/abTesting.mjs.map +1 -0
  33. package/dist/esm/core/eventBuffer.mjs +66 -0
  34. package/dist/esm/core/eventBuffer.mjs.map +1 -0
  35. package/dist/esm/core/globalManager.mjs +58 -0
  36. package/dist/esm/core/globalManager.mjs.map +1 -0
  37. package/dist/esm/core/index.mjs +10 -0
  38. package/dist/esm/core/initAnalyticsClient.mjs +49 -0
  39. package/dist/esm/core/initAnalyticsClient.mjs.map +1 -0
  40. package/dist/esm/core/sampling.mjs +27 -0
  41. package/dist/esm/core/sampling.mjs.map +1 -0
  42. package/dist/esm/core/session.mjs +40 -0
  43. package/dist/esm/core/session.mjs.map +1 -0
  44. package/dist/esm/core/transport.mjs +45 -0
  45. package/dist/esm/core/transport.mjs.map +1 -0
  46. package/dist/esm/core/types.mjs +0 -0
  47. package/dist/esm/events/contentExposure.mjs +36 -0
  48. package/dist/esm/events/contentExposure.mjs.map +1 -0
  49. package/dist/esm/index.mjs +11 -0
  50. package/dist/esm/isEnabled.mjs +28 -0
  51. package/dist/esm/isEnabled.mjs.map +1 -0
  52. package/dist/esm/utils/hash.mjs +24 -0
  53. package/dist/esm/utils/hash.mjs.map +1 -0
  54. package/dist/esm/utils/idle.mjs +24 -0
  55. package/dist/esm/utils/idle.mjs.map +1 -0
  56. package/dist/types/core/AnalyticsClient.d.ts +51 -0
  57. package/dist/types/core/AnalyticsClient.d.ts.map +1 -0
  58. package/dist/types/core/abTesting.d.ts +23 -0
  59. package/dist/types/core/abTesting.d.ts.map +1 -0
  60. package/dist/types/core/eventBuffer.d.ts +35 -0
  61. package/dist/types/core/eventBuffer.d.ts.map +1 -0
  62. package/dist/types/core/globalManager.d.ts +28 -0
  63. package/dist/types/core/globalManager.d.ts.map +1 -0
  64. package/dist/types/core/index.d.ts +10 -0
  65. package/dist/types/core/initAnalyticsClient.d.ts +28 -0
  66. package/dist/types/core/initAnalyticsClient.d.ts.map +1 -0
  67. package/dist/types/core/sampling.d.ts +20 -0
  68. package/dist/types/core/sampling.d.ts.map +1 -0
  69. package/dist/types/core/session.d.ts +17 -0
  70. package/dist/types/core/session.d.ts.map +1 -0
  71. package/dist/types/core/transport.d.ts +31 -0
  72. package/dist/types/core/transport.d.ts.map +1 -0
  73. package/dist/types/core/types.d.ts +87 -0
  74. package/dist/types/core/types.d.ts.map +1 -0
  75. package/dist/types/events/contentExposure.d.ts +38 -0
  76. package/dist/types/events/contentExposure.d.ts.map +1 -0
  77. package/dist/types/index.d.ts +11 -0
  78. package/dist/types/isEnabled.d.ts +18 -0
  79. package/dist/types/isEnabled.d.ts.map +1 -0
  80. package/dist/types/utils/hash.d.ts +16 -0
  81. package/dist/types/utils/hash.d.ts.map +1 -0
  82. package/dist/types/utils/idle.d.ts +15 -0
  83. package/dist/types/utils/idle.d.ts.map +1 -0
  84. package/package.json +100 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contentExposure.mjs","names":[],"sources":["../../../src/events/contentExposure.ts"],"sourcesContent":["import type { KeyPath } from '@intlayer/types/keyPath';\nimport type { ContentExposureEvent, TrackableEvent } from '../core/types';\n\n/**\n * Serializes a `KeyPath[]` into a compact, stable string used both as the\n * coalescing key in the buffer and as the stored `keyPath` on the wire.\n *\n * Only the `key` of each segment is kept (types are implied by the dictionary\n * shape), producing paths like `\"faq.items.2.answer\"`.\n *\n * @param keyPath - The interpreter key path locating a node.\n * @returns A dot-joined, stable path string.\n *\n * @example\n * serializeKeyPath([{ type: 'object', key: 'faq' }, { type: 'array', key: 2 }]);\n * // \"faq.2\"\n */\nexport const serializeKeyPath = (keyPath: KeyPath[]): string =>\n keyPath\n .map((segment) => (segment.key === undefined ? '*' : String(segment.key)))\n .join('.');\n\n/**\n * Builds a content-exposure payload from interpreter node metadata. Shared by\n * every framework binding's analytics node plugin so the wire shape stays\n * identical across React, Vue, Svelte, Angular, etc.\n *\n * @param params - Node metadata available on `NodeProps`.\n * @returns A trackable content-exposure event (minus buffer-stamped fields).\n */\nexport const buildContentExposure = (params: {\n dictionaryKey: string;\n keyPath: KeyPath[];\n locale?: string;\n nodeType?: string;\n experimentKey?: string;\n variant?: string;\n}): Omit<TrackableEvent<ContentExposureEvent>, 'type'> => ({\n dictionaryKey: params.dictionaryKey,\n keyPath: serializeKeyPath(params.keyPath),\n // Left undefined when unknown so the client stamps its ambient locale.\n locale: params.locale,\n nodeType: params.nodeType,\n experimentKey: params.experimentKey,\n variant: params.variant,\n});\n"],"mappings":";;;;;;;;;;;;;;;AAiBA,MAAa,oBAAoB,YAC/B,QACG,KAAK,YAAa,QAAQ,QAAQ,SAAY,MAAM,OAAO,QAAQ,IAAI,CAAE,CACzE,KAAK,IAAI;;;;;;;;;AAUd,MAAa,wBAAwB,YAOsB;CACzD,eAAe,OAAO;CACtB,SAAS,iBAAiB,OAAO,QAAQ;CAEzC,QAAQ,OAAO;CACf,UAAU,OAAO;CACjB,eAAe,OAAO;CACtB,SAAS,OAAO;CACjB"}
@@ -0,0 +1,11 @@
1
+ import { assignVariant } from "./core/abTesting.mjs";
2
+ import { createEventBuffer } from "./core/eventBuffer.mjs";
3
+ import { isSampledIn } from "./core/sampling.mjs";
4
+ import { getSessionId } from "./core/session.mjs";
5
+ import { sendEvents } from "./core/transport.mjs";
6
+ import { DEFAULT_FLUSH_INTERVAL, DEFAULT_MAX_BUFFER_SIZE, DEFAULT_SAMPLE_RATE, MAX_EVENTS_PER_SEND, createAnalyticsClient } from "./core/AnalyticsClient.mjs";
7
+ import { decrementAnalyticsClientRefCount, getGlobalAnalyticsClient, incrementAnalyticsClientRefCount, setGlobalAnalyticsClient } from "./core/globalManager.mjs";
8
+ import { initAnalyticsClient, stopAnalyticsClient } from "./core/initAnalyticsClient.mjs";
9
+ import { buildContentExposure, serializeKeyPath } from "./events/contentExposure.mjs";
10
+
11
+ export { DEFAULT_FLUSH_INTERVAL, DEFAULT_MAX_BUFFER_SIZE, DEFAULT_SAMPLE_RATE, MAX_EVENTS_PER_SEND, assignVariant, buildContentExposure, createAnalyticsClient, createEventBuffer, decrementAnalyticsClientRefCount, getGlobalAnalyticsClient, getSessionId, incrementAnalyticsClientRefCount, initAnalyticsClient, isSampledIn, sendEvents, serializeKeyPath, setGlobalAnalyticsClient, stopAnalyticsClient };
@@ -0,0 +1,28 @@
1
+ import { analytics, editor } from "@intlayer/config/built";
2
+
3
+ //#region src/isEnabled.ts
4
+ /**
5
+ * Compile-time kill switch. Bundlers replace `process.env.INTLAYER_ANALYTICS_ENABLED`
6
+ * (set to `'false'` by `@intlayer/config` unless `analytics.enabled` is `true`
7
+ * AND an `editor.clientId` is configured) so the whole analytics integration is
8
+ * dead-code-eliminated for apps that don't opt in.
9
+ */
10
+ const TREE_SHAKE_ANALYTICS = process.env.INTLAYER_ANALYTICS_ENABLED === "false";
11
+ /**
12
+ * Runtime guard mirroring `@intlayer/editor`'s `isEnabled`, but inverted with
13
+ * respect to the iframe: analytics runs for real end users on the **top**
14
+ * window and stays off inside the editor/CMS preview iframe so editor sessions
15
+ * are never counted as traffic.
16
+ *
17
+ * Enabled when:
18
+ * - the bundler did not tree-shake analytics away, and
19
+ * - the user opted in (`analytics.enabled === true`), and
20
+ * - a project key is configured (`editor.clientId`), and
21
+ * - we are on the client, and
22
+ * - we are the top window (not embedded in the editor).
23
+ */
24
+ const isEnabled = !TREE_SHAKE_ANALYTICS && analytics?.enabled === true && Boolean(editor?.clientId) && typeof window !== "undefined" && window.self === window.top;
25
+
26
+ //#endregion
27
+ export { isEnabled };
28
+ //# sourceMappingURL=isEnabled.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isEnabled.mjs","names":[],"sources":["../../src/isEnabled.ts"],"sourcesContent":["import { analytics, editor } from '@intlayer/config/built';\n\n/**\n * Compile-time kill switch. Bundlers replace `process.env.INTLAYER_ANALYTICS_ENABLED`\n * (set to `'false'` by `@intlayer/config` unless `analytics.enabled` is `true`\n * AND an `editor.clientId` is configured) so the whole analytics integration is\n * dead-code-eliminated for apps that don't opt in.\n */\nconst TREE_SHAKE_ANALYTICS = process.env.INTLAYER_ANALYTICS_ENABLED === 'false';\n\n/**\n * Runtime guard mirroring `@intlayer/editor`'s `isEnabled`, but inverted with\n * respect to the iframe: analytics runs for real end users on the **top**\n * window and stays off inside the editor/CMS preview iframe so editor sessions\n * are never counted as traffic.\n *\n * Enabled when:\n * - the bundler did not tree-shake analytics away, and\n * - the user opted in (`analytics.enabled === true`), and\n * - a project key is configured (`editor.clientId`), and\n * - we are on the client, and\n * - we are the top window (not embedded in the editor).\n */\nexport const isEnabled =\n !TREE_SHAKE_ANALYTICS &&\n analytics?.enabled === true &&\n Boolean(editor?.clientId) &&\n typeof window !== 'undefined' &&\n window.self === window.top;\n"],"mappings":";;;;;;;;;AAQA,MAAM,uBAAuB,QAAQ,IAAI,+BAA+B;;;;;;;;;;;;;;AAexE,MAAa,YACX,CAAC,wBACD,WAAW,YAAY,QACvB,QAAQ,QAAQ,SAAS,IACzB,OAAO,WAAW,eAClB,OAAO,SAAS,OAAO"}
@@ -0,0 +1,24 @@
1
+ //#region src/utils/hash.ts
2
+ /**
3
+ * FNV-1a 32-bit string hash. Small, fast, dependency-free, and stable across
4
+ * runtimes — good enough for deterministic A/B bucketing and session seeding
5
+ * (not for cryptographic use).
6
+ *
7
+ * @param input - The string to hash.
8
+ * @returns An unsigned 32-bit integer hash.
9
+ *
10
+ * @example
11
+ * hashString('session-1:homepage-hero'); // 3039336720
12
+ */
13
+ const hashString = (input) => {
14
+ let hash = 2166136261;
15
+ for (let index = 0; index < input.length; index++) {
16
+ hash ^= input.charCodeAt(index);
17
+ hash = Math.imul(hash, 16777619);
18
+ }
19
+ return hash >>> 0;
20
+ };
21
+
22
+ //#endregion
23
+ export { hashString };
24
+ //# sourceMappingURL=hash.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash.mjs","names":[],"sources":["../../../src/utils/hash.ts"],"sourcesContent":["/**\n * FNV-1a 32-bit string hash. Small, fast, dependency-free, and stable across\n * runtimes — good enough for deterministic A/B bucketing and session seeding\n * (not for cryptographic use).\n *\n * @param input - The string to hash.\n * @returns An unsigned 32-bit integer hash.\n *\n * @example\n * hashString('session-1:homepage-hero'); // 3039336720\n */\nexport const hashString = (input: string): number => {\n let hash = 0x811c9dc5; // FNV offset basis\n\n for (let index = 0; index < input.length; index++) {\n hash ^= input.charCodeAt(index);\n // 32-bit FNV prime multiplication via shifts to stay within Number safe range\n hash = Math.imul(hash, 0x01000193);\n }\n\n // Coerce to unsigned 32-bit\n return hash >>> 0;\n};\n"],"mappings":";;;;;;;;;;;;AAWA,MAAa,cAAc,UAA0B;CACnD,IAAI,OAAO;AAEX,MAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,QAAQ,SAAS;AACjD,UAAQ,MAAM,WAAW,MAAM;AAE/B,SAAO,KAAK,KAAK,MAAM,SAAW;;AAIpC,QAAO,SAAS"}
@@ -0,0 +1,24 @@
1
+ //#region src/utils/idle.ts
2
+ /**
3
+ * Runs a callback when the browser is idle, without blocking first render.
4
+ * Falls back to a short `setTimeout` where `requestIdleCallback` is unavailable
5
+ * (Safari, React Native, Lynx).
6
+ *
7
+ * @param callback - Work to run once the main thread is free.
8
+ *
9
+ * @example
10
+ * onIdle(() => attachVisibilityListeners());
11
+ */
12
+ const onIdle = (callback) => {
13
+ if (typeof window === "undefined") return;
14
+ const requestIdle = window.requestIdleCallback;
15
+ if (typeof requestIdle === "function") {
16
+ requestIdle(() => callback());
17
+ return;
18
+ }
19
+ setTimeout(callback, 1);
20
+ };
21
+
22
+ //#endregion
23
+ export { onIdle };
24
+ //# sourceMappingURL=idle.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"idle.mjs","names":[],"sources":["../../../src/utils/idle.ts"],"sourcesContent":["/**\n * Runs a callback when the browser is idle, without blocking first render.\n * Falls back to a short `setTimeout` where `requestIdleCallback` is unavailable\n * (Safari, React Native, Lynx).\n *\n * @param callback - Work to run once the main thread is free.\n *\n * @example\n * onIdle(() => attachVisibilityListeners());\n */\nexport const onIdle = (callback: () => void): void => {\n if (typeof window === 'undefined') return;\n\n const requestIdle = (\n window as Window & {\n requestIdleCallback?: (cb: () => void) => number;\n }\n ).requestIdleCallback;\n\n if (typeof requestIdle === 'function') {\n requestIdle(() => callback());\n return;\n }\n\n setTimeout(callback, 1);\n};\n"],"mappings":";;;;;;;;;;;AAUA,MAAa,UAAU,aAA+B;AACpD,KAAI,OAAO,WAAW,YAAa;CAEnC,MAAM,cACJ,OAGA;AAEF,KAAI,OAAO,gBAAgB,YAAY;AACrC,oBAAkB,UAAU,CAAC;AAC7B;;AAGF,YAAW,UAAU,EAAE"}
@@ -0,0 +1,51 @@
1
+ import { AnalyticsClientConfig, ContentExposureEvent, ConversionEvent, PageViewEvent, TrackableEvent } from "./types.js";
2
+
3
+ //#region src/core/AnalyticsClient.d.ts
4
+ /**
5
+ * Caller-supplied fields for a page view. Everything is optional — the client
6
+ * fills `url`, `locale`, viewport, and referrer from the environment when omitted.
7
+ */
8
+ type PageViewInput = {
9
+ /** Explicit pathname / screen name (native runtimes have no `location`). */url?: string; /** Explicit locale; falls back to the client's ambient locale. */
10
+ locale?: string; /** Referrer host override. */
11
+ ref?: string; /** Viewport width override. */
12
+ vw?: number; /** Viewport height override. */
13
+ vh?: number; /** Why the view was recorded. */
14
+ reason?: PageViewEvent['reason'];
15
+ };
16
+ /** Default flush cadence — one network request per 20 seconds. */
17
+ declare const DEFAULT_FLUSH_INTERVAL = 20000;
18
+ /** Default cap on distinct buffered events before an early flush. */
19
+ declare const DEFAULT_MAX_BUFFER_SIZE = 500;
20
+ /** Default sampling — keep every session. */
21
+ declare const DEFAULT_SAMPLE_RATE = 1;
22
+ /**
23
+ * Maximum events per network request. `sendBeacon` and `fetch(keepalive)`
24
+ * reject bodies over ~64KB, so large batches are split into multiple sends.
25
+ */
26
+ declare const MAX_EVENTS_PER_SEND = 200;
27
+ /**
28
+ * The public surface of the analytics client singleton. Framework bindings hold
29
+ * a reference to this and forward provider/node/conversion signals into it.
30
+ */
31
+ type AnalyticsClient = {
32
+ /** Sets the ambient locale stamped onto subsequent events. */setLocale: (locale: string) => void; /** Records a page/locale view (provider level). */
33
+ trackPageView: (event?: PageViewInput) => void; /** Records a content exposure (node level). Sampled + deduped per page view. */
34
+ trackContentExposure: (event: Omit<TrackableEvent<ContentExposureEvent>, 'type'>) => void; /** Records a conversion tied to an experiment variant. */
35
+ trackConversion: (event: Omit<TrackableEvent<ConversionEvent>, 'type'>) => void; /** Deterministically resolves this session's variant for an experiment. */
36
+ getVariant: (experimentKey: string, variants: string[], weights?: number[]) => string; /** Sends the buffered batch now. */
37
+ flush: (useBeacon?: boolean) => void; /** Starts the flush loop and lifecycle listeners (idempotent). */
38
+ start: () => void; /** Stops timers/listeners and flushes any remaining events. */
39
+ stop: () => void;
40
+ };
41
+ /**
42
+ * Creates an analytics client. Prefer {@link initAnalyticsClient} in application
43
+ * code — it manages a shared singleton so there is only ever one flush timer.
44
+ *
45
+ * @param config - Resolved client configuration.
46
+ * @returns A started-on-demand {@link AnalyticsClient}.
47
+ */
48
+ declare const createAnalyticsClient: (config: AnalyticsClientConfig) => AnalyticsClient;
49
+ //#endregion
50
+ export { AnalyticsClient, DEFAULT_FLUSH_INTERVAL, DEFAULT_MAX_BUFFER_SIZE, DEFAULT_SAMPLE_RATE, MAX_EVENTS_PER_SEND, PageViewInput, createAnalyticsClient };
51
+ //# sourceMappingURL=AnalyticsClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnalyticsClient.d.ts","names":[],"sources":["../../../src/core/AnalyticsClient.ts"],"mappings":";;;;;AAmBA;;KAAY,aAAA;EAYY,4EAVtB,GAAA,WAEA;EAAA,MAAA,WAIA;EAFA,GAAA,WAMA;EAJA,EAAA,WAIsB;EAFtB,EAAA,WAMW;EAJX,MAAA,GAAS,aAAA;AAAA;;cAIE,sBAAA;AAEb;AAAA,cAAa,uBAAA;;cAEA,mBAAA;;AAAb;;;cAKa,mBAAA;;AAAb;;;KAQY,eAAA;EARoB,8DAU9B,SAAA,GAAY,MAAA,mBAFa;EAIzB,aAAA,GAAgB,KAAA,GAAQ,aAAA,WAAA;EAExB,oBAAA,GACE,KAAA,EAAO,IAAA,CAAK,cAAA,CAAe,oBAAA,qBAAf;EAGd,eAAA,GACE,KAAA,EAAO,IAAA,CAAK,cAAA,CAAe,eAAA,qBAAA;EAG7B,UAAA,GACE,aAAA,UACA,QAAA,YACA,OAAA,wBANO;EAST,KAAA,GAAQ,SAAA,qBATK;EAWb,KAAA,cApBY;EAsBZ,IAAA;AAAA;;;;;;;;cA+BW,qBAAA,GACX,MAAA,EAAQ,qBAAA,KACP,eAAA"}
@@ -0,0 +1,23 @@
1
+ //#region src/core/abTesting.d.ts
2
+ /**
3
+ * Deterministically assigns a variant to a session for a given experiment.
4
+ *
5
+ * The assignment is a pure function of `sessionId` + `experimentKey`, so it is
6
+ * stable for the whole session and requires **no** server round-trip before the
7
+ * first render — avoiding layout shift / content flicker. Optional `weights`
8
+ * bias the split (e.g. `[0.9, 0.1]` for a 90/10 rollout).
9
+ *
10
+ * @param sessionId - The current anonymous session id.
11
+ * @param experimentKey - Unique key identifying the experiment.
12
+ * @param variants - The candidate variant names (at least one).
13
+ * @param weights - Optional relative weights, one per variant.
14
+ * @returns The variant assigned to this session.
15
+ *
16
+ * @example
17
+ * assignVariant('sid-1', 'homepage-hero', ['a', 'b']); // stable 'a' | 'b'
18
+ * assignVariant('sid-1', 'homepage-hero', ['a', 'b'], [9, 1]); // ~90% 'a'
19
+ */
20
+ declare const assignVariant: (sessionId: string, experimentKey: string, variants: string[], weights?: number[]) => string;
21
+ //#endregion
22
+ export { assignVariant };
23
+ //# sourceMappingURL=abTesting.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abTesting.d.ts","names":[],"sources":["../../../src/core/abTesting.ts"],"mappings":";;AAoBA;;;;;;;;;;;;;;;;;cAAa,aAAA,GACX,SAAA,UACA,aAAA,UACA,QAAA,YACA,OAAA"}
@@ -0,0 +1,35 @@
1
+ import { AnalyticsEvent } from "./types.js";
2
+
3
+ //#region src/core/eventBuffer.d.ts
4
+ /**
5
+ * A bounded, coalescing in-memory buffer for analytics events.
6
+ *
7
+ * - `page_view` and `conversion` events are appended verbatim (they are rare
8
+ * and valuable — they are never evicted while exposures remain).
9
+ * - `content_exposure` events are deduplicated by page/node/locale/variant with
10
+ * a running `count`, keeping the highest-volume signal cheap.
11
+ * - When the total number of stored events exceeds `max`, the **oldest
12
+ * exposures** are evicted first (analytics is lossy by design; exposures are
13
+ * the expendable signal). Discrete events are only dropped once no exposures
14
+ * remain.
15
+ */
16
+ type EventBuffer = {
17
+ /** Adds an event, coalescing content exposures. Returns the current size. */push: (event: AnalyticsEvent) => number; /** Removes and returns every buffered event. */
18
+ drain: () => AnalyticsEvent[]; /** Current number of distinct buffered events. */
19
+ size: () => number;
20
+ };
21
+ /**
22
+ * Creates an {@link EventBuffer}.
23
+ *
24
+ * @param options - Buffer options.
25
+ * @param options.max - Maximum number of distinct events to retain.
26
+ * @returns A new buffer instance.
27
+ */
28
+ declare const createEventBuffer: ({
29
+ max
30
+ }: {
31
+ max: number;
32
+ }) => EventBuffer;
33
+ //#endregion
34
+ export { EventBuffer, createEventBuffer };
35
+ //# sourceMappingURL=eventBuffer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eventBuffer.d.ts","names":[],"sources":["../../../src/core/eventBuffer.ts"],"mappings":";;;;;AAgCA;;;;;;;;;;KAAY,WAAA;EAMN,6EAJJ,IAAA,GAAO,KAAA,EAAO,cAAA,aAiEf;EA/DC,KAAA,QAAa,cAAA,IA+Dd;EA7DC,IAAA;AAAA;;;;;;;;cAUW,iBAAA;EAAqB;AAAA;EAAW,GAAA;AAAA,MAAgB,WAAA"}
@@ -0,0 +1,28 @@
1
+ import { AnalyticsClient } from "./AnalyticsClient.js";
2
+
3
+ //#region src/core/globalManager.d.ts
4
+ /**
5
+ * Returns the global analytics client, or `null` in SSR or before init.
6
+ */
7
+ declare const getGlobalAnalyticsClient: () => AnalyticsClient | null;
8
+ /**
9
+ * Sets (or clears) the global analytics client singleton.
10
+ *
11
+ * @param client - The client to store globally, or `null` to clear it.
12
+ */
13
+ declare const setGlobalAnalyticsClient: (client: AnalyticsClient | null) => void;
14
+ /**
15
+ * Increments the shared provider reference count.
16
+ *
17
+ * @returns The count after incrementing (`0` in SSR, where nothing is stored).
18
+ */
19
+ declare const incrementAnalyticsClientRefCount: () => number;
20
+ /**
21
+ * Decrements the shared provider reference count, clamping at zero.
22
+ *
23
+ * @returns The count after decrementing (`0` in SSR, where nothing is stored).
24
+ */
25
+ declare const decrementAnalyticsClientRefCount: () => number;
26
+ //#endregion
27
+ export { decrementAnalyticsClientRefCount, getGlobalAnalyticsClient, incrementAnalyticsClientRefCount, setGlobalAnalyticsClient };
28
+ //# sourceMappingURL=globalManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globalManager.d.ts","names":[],"sources":["../../../src/core/globalManager.ts"],"mappings":";;;;;AA2BA;cAAa,wBAAA,QAA+B,eAAA;;;;AAU5C;;cAAa,wBAAA,GACX,MAAA,EAAQ,eAAA;;;AAWV;;;cAAa,gCAAA;;AAYb;;;;cAAa,gCAAA"}
@@ -0,0 +1,10 @@
1
+ import { AnalyticsClientConfig, AnalyticsEvent, AnalyticsEventType, AnalyticsIngestBody, BaseAnalyticsEvent, ContentExposureEvent, ConversionEvent, PageViewEvent, TrackableEvent } from "./types.js";
2
+ import { AnalyticsClient, DEFAULT_FLUSH_INTERVAL, DEFAULT_MAX_BUFFER_SIZE, DEFAULT_SAMPLE_RATE, MAX_EVENTS_PER_SEND, PageViewInput, createAnalyticsClient } from "./AnalyticsClient.js";
3
+ import { assignVariant } from "./abTesting.js";
4
+ import { EventBuffer, createEventBuffer } from "./eventBuffer.js";
5
+ import { decrementAnalyticsClientRefCount, getGlobalAnalyticsClient, incrementAnalyticsClientRefCount, setGlobalAnalyticsClient } from "./globalManager.js";
6
+ import { initAnalyticsClient, stopAnalyticsClient } from "./initAnalyticsClient.js";
7
+ import { isSampledIn } from "./sampling.js";
8
+ import { getSessionId } from "./session.js";
9
+ import { sendEvents } from "./transport.js";
10
+ export { AnalyticsClient, AnalyticsClientConfig, AnalyticsEvent, AnalyticsEventType, AnalyticsIngestBody, BaseAnalyticsEvent, ContentExposureEvent, ConversionEvent, DEFAULT_FLUSH_INTERVAL, DEFAULT_MAX_BUFFER_SIZE, DEFAULT_SAMPLE_RATE, EventBuffer, MAX_EVENTS_PER_SEND, PageViewEvent, PageViewInput, TrackableEvent, assignVariant, createAnalyticsClient, createEventBuffer, decrementAnalyticsClientRefCount, getGlobalAnalyticsClient, getSessionId, incrementAnalyticsClientRefCount, initAnalyticsClient, isSampledIn, sendEvents, setGlobalAnalyticsClient, stopAnalyticsClient };
@@ -0,0 +1,28 @@
1
+ import { AnalyticsClient } from "./AnalyticsClient.js";
2
+
3
+ //#region src/core/initAnalyticsClient.d.ts
4
+ /**
5
+ * Initializes the Intlayer analytics client singleton.
6
+ *
7
+ * Behavior comes from the `analytics` config block (`flushInterval`,
8
+ * `sampleRate`); attribution reuses the existing `editor` config
9
+ * (`editor.backendURL` for the endpoint, `editor.clientId` for the project).
10
+ *
11
+ * Safe to call multiple times: returns the existing client and increments a
12
+ * `window`-shared reference count so nested providers (or duplicated module
13
+ * instances) don't stop the client prematurely.
14
+ *
15
+ * @returns The started analytics client singleton.
16
+ */
17
+ declare const initAnalyticsClient: () => AnalyticsClient;
18
+ /**
19
+ * Decrements the shared reference count and stops the global analytics client
20
+ * only when the last provider unmounts (flushing any remaining events).
21
+ *
22
+ * Callers must pair each `stopAnalyticsClient` with a prior
23
+ * `initAnalyticsClient` — never call it when init was skipped or cancelled.
24
+ */
25
+ declare const stopAnalyticsClient: () => void;
26
+ //#endregion
27
+ export { initAnalyticsClient, stopAnalyticsClient };
28
+ //# sourceMappingURL=initAnalyticsClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initAnalyticsClient.d.ts","names":[],"sources":["../../../src/core/initAnalyticsClient.ts"],"mappings":";;;;;AA4BA;;;;;AA2BA;;;;;;cA3Ba,mBAAA,QAA0B,eAAA;;;;;;;;cA2B1B,mBAAA"}
@@ -0,0 +1,20 @@
1
+ //#region src/core/sampling.d.ts
2
+ /**
3
+ * Deterministic per-session sampling gate. Using the session id (rather than a
4
+ * fresh random draw per event) means a sampled-in session reports *all* of its
5
+ * content exposures, keeping per-session funnels consistent instead of leaving
6
+ * holes.
7
+ *
8
+ * @param sessionId - The current anonymous session id.
9
+ * @param sampleRate - Fraction of sessions to keep, from 0 (none) to 1 (all).
10
+ * @returns `true` when this session's events should be recorded.
11
+ *
12
+ * @example
13
+ * isSampledIn('abc', 1); // always true
14
+ * isSampledIn('abc', 0); // always false
15
+ * isSampledIn('abc', 0.5); // stable per session
16
+ */
17
+ declare const isSampledIn: (sessionId: string, sampleRate: number) => boolean;
18
+ //#endregion
19
+ export { isSampledIn };
20
+ //# sourceMappingURL=sampling.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sampling.d.ts","names":[],"sources":["../../../src/core/sampling.ts"],"mappings":";;AAiBA;;;;;;;;;;;;;;cAAa,WAAA,GAAe,SAAA,UAAmB,UAAA"}
@@ -0,0 +1,17 @@
1
+ //#region src/core/session.d.ts
2
+ /**
3
+ * Anonymous, per-tab session identity. Stored in `sessionStorage` so it is
4
+ * cleared when the tab closes and is never shared across sites — no durable
5
+ * cookie, no cross-site tracking, no PII.
6
+ */
7
+ /**
8
+ * Returns the current session id, creating and persisting one on first access.
9
+ * Degrades gracefully to an in-memory id when `sessionStorage` is unavailable
10
+ * (private mode, native runtimes).
11
+ *
12
+ * @returns The stable session id for the lifetime of the tab.
13
+ */
14
+ declare const getSessionId: () => string;
15
+ //#endregion
16
+ export { getSessionId };
17
+ //# sourceMappingURL=session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.d.ts","names":[],"sources":["../../../src/core/session.ts"],"mappings":";;AAkCA;;;;;;;;;;;cAAa,YAAA"}
@@ -0,0 +1,31 @@
1
+ import { AnalyticsIngestBody } from "./types.js";
2
+
3
+ //#region src/core/transport.d.ts
4
+ /**
5
+ * Sends a batch of events to the backend. Every path is non-blocking and
6
+ * no-throw — analytics must never break, slow, or delay the host application.
7
+ *
8
+ * Strategy:
9
+ * 1. `navigator.sendBeacon` for the flush-on-hide path — survives page unload
10
+ * and never blocks navigation. The payload is sent as `text/plain` (a
11
+ * CORS-safelisted content type): a JSON `Blob` would require a CORS
12
+ * preflight that browsers handle inconsistently during unload, silently
13
+ * dropping the beacon. The backend parses `text/plain` bodies as JSON.
14
+ * 2. `fetch(..., { keepalive: true })` for interval flushes — survives short
15
+ * navigations without holding the main thread.
16
+ * 3. Plain `fetch` fallback for runtimes without `keepalive` (older RN/Lynx).
17
+ *
18
+ * @param endpoint - Fully-qualified ingestion URL.
19
+ * @param body - The batched payload.
20
+ * @param options - Transport options.
21
+ * @param options.useBeacon - Prefer `sendBeacon` (used when the page is hiding).
22
+ * @returns `true` when a send was dispatched, `false` otherwise.
23
+ */
24
+ declare const sendEvents: (endpoint: string, body: AnalyticsIngestBody, {
25
+ useBeacon
26
+ }?: {
27
+ useBeacon?: boolean;
28
+ }) => boolean;
29
+ //#endregion
30
+ export { sendEvents };
31
+ //# sourceMappingURL=transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.d.ts","names":[],"sources":["../../../src/core/transport.ts"],"mappings":";;;;;AAsBA;;;;;;;;;;;;;;;;;;cAAa,UAAA,GACX,QAAA,UACA,IAAA,EAAM,mBAAA;EACN;AAAA;EAAyB,SAAA;AAAA"}
@@ -0,0 +1,87 @@
1
+ //#region src/core/types.d.ts
2
+ /**
3
+ * Wire contract shared between the analytics client, `@intlayer/api`, and the
4
+ * backend ingestion endpoint. Keys are intentionally short to keep the batched
5
+ * payload small on the network.
6
+ */
7
+ /**
8
+ * The kind of signal an event carries.
9
+ */
10
+ type AnalyticsEventType = 'page_view' | 'content_exposure' | 'conversion';
11
+ /**
12
+ * Fields present on every event regardless of its type.
13
+ */
14
+ type BaseAnalyticsEvent = {
15
+ /** Client timestamp in milliseconds since epoch. */t: number; /** Current locale being displayed when the event was captured. */
16
+ locale: string; /** Pathname of the page (search params excluded by default for privacy). */
17
+ url: string;
18
+ };
19
+ /**
20
+ * A page/locale level event, emitted at the provider level on first mount,
21
+ * on client-side navigation, and on locale change.
22
+ */
23
+ type PageViewEvent = BaseAnalyticsEvent & {
24
+ type: 'page_view'; /** Referrer host only (never the full URL) — omitted when unavailable. */
25
+ ref?: string; /** Viewport width in CSS pixels. */
26
+ vw?: number; /** Viewport height in CSS pixels. */
27
+ vh?: number; /** Why the view was recorded (initial load vs. locale switch vs. route change). */
28
+ reason?: 'initial' | 'locale_change' | 'route_change';
29
+ };
30
+ /**
31
+ * A node level event, emitted when a specific piece of dictionary content is
32
+ * resolved for display. Coalesced by the buffer so repeated exposures of the
33
+ * same node within a flush window collapse into a single event with a `count`.
34
+ */
35
+ type ContentExposureEvent = BaseAnalyticsEvent & {
36
+ type: 'content_exposure'; /** The dictionary the resolved node belongs to. */
37
+ dictionaryKey: string; /** Stable-serialized `KeyPath[]` locating the node inside the dictionary. */
38
+ keyPath: string; /** The interpreter node type (translation, enumeration, markdown, …). */
39
+ nodeType?: string; /** The experiment this exposure belongs to, when part of an experiment. */
40
+ experimentKey?: string; /** A/B variant that produced this exposure, when part of an experiment. */
41
+ variant?: string; /** Number of coalesced exposures represented by this event. */
42
+ count?: number;
43
+ };
44
+ /**
45
+ * A conversion event tying a goal to the A/B variant the session was exposed to.
46
+ */
47
+ type ConversionEvent = BaseAnalyticsEvent & {
48
+ type: 'conversion'; /** The experiment this conversion is attributed to. */
49
+ experimentKey: string; /** The variant the session was assigned. */
50
+ variant: string; /** The goal that was reached (e.g. `"signup"`, `"cta_click"`). */
51
+ goal: string; /** Optional numeric value associated with the conversion (e.g. revenue). */
52
+ value?: number;
53
+ };
54
+ /**
55
+ * The union of every event the client can emit.
56
+ */
57
+ type AnalyticsEvent = PageViewEvent | ContentExposureEvent | ConversionEvent;
58
+ /**
59
+ * An event as it is handed to the client trackers, before the buffer stamps the
60
+ * shared `BaseAnalyticsEvent` fields (`t`, `url`, and the ambient `locale`).
61
+ */
62
+ type TrackableEvent<E extends AnalyticsEvent = AnalyticsEvent> = Omit<E, 't' | 'url' | 'locale'> & {
63
+ /** Optional explicit locale; falls back to the client's ambient locale. */locale?: string;
64
+ };
65
+ /**
66
+ * The batched request body sent to `POST /api/analytics/events`.
67
+ */
68
+ type AnalyticsIngestBody = {
69
+ /** Public project key — reused from `editor.clientId`. */clientId?: string; /** Anonymous per-tab session identifier (new tab ⇒ new id; never durable). */
70
+ sessionId: string; /** Version of the analytics SDK that produced the batch. */
71
+ sdkVersion: string; /** The events collected during the flush window. */
72
+ events: AnalyticsEvent[];
73
+ };
74
+ /**
75
+ * Resolved runtime options for the analytics client. All values have safe
76
+ * defaults so the client can run with only a `backendURL`.
77
+ */
78
+ type AnalyticsClientConfig = {
79
+ /** Base URL of the Intlayer backend — reused from `editor.backendURL`. */backendURL: string; /** Public project key — reused from `editor.clientId`. */
80
+ clientId?: string; /** Milliseconds between automatic flushes. Defaults to 20000. */
81
+ flushInterval: number; /** Maximum number of buffered events before an early flush. Defaults to 500. */
82
+ maxBufferSize: number; /** Fraction of content-exposure events to keep, 0..1. Defaults to 1. */
83
+ sampleRate: number;
84
+ };
85
+ //#endregion
86
+ export { AnalyticsClientConfig, AnalyticsEvent, AnalyticsEventType, AnalyticsIngestBody, BaseAnalyticsEvent, ContentExposureEvent, ConversionEvent, PageViewEvent, TrackableEvent };
87
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/core/types.ts"],"mappings":";;AASA;;;;;AAQA;;KARY,kBAAA;;;;KAQA,kBAAA;EAMP,oDAJH,CAAA,UAWU;EATV,MAAA;EAEA,GAAA;AAAA;;;;;KAOU,aAAA,GAAgB,kBAAA;EAC1B,IAAA,eAQM;EANN,GAAA,WAc8B;EAZ9B,EAAA,WAYmD;EAVnD,EAAA,WAWA;EATA,MAAA;AAAA;;;;;;KAQU,oBAAA,GAAuB,kBAAA;EACjC,IAAA,sBAkByB;EAhBzB,aAAA,UAgB8C;EAd9C,OAAA,UAeA;EAbA,QAAA,WAiBA;EAfA,aAAA,WAmBA;EAjBA,OAAA,WAiBK;EAfL,KAAA;AAAA;;;;KAMU,eAAA,GAAkB,kBAAA;EAC5B,IAAA,gBAiBiB;EAfjB,aAAA,UAcE;EAZF,OAAA,UAaiB;EAXjB,IAAA,UAiBU;EAfV,KAAA;AAAA;;;;KAMU,cAAA,GACR,aAAA,GACA,oBAAA,GACA,eAAA;;;;;KAMQ,cAAA,WAAyB,cAAA,GAAiB,cAAA,IAAkB,IAAA,CACtE,CAAA;EADsE,2EAKtE,MAAA;AAAA;;;AAMF;KAAY,mBAAA;4DAEV,QAAA;EAEA,SAAA,UAEA;EAAA,UAAA,UAEQ;EAAR,MAAA,EAAQ,cAAA;AAAA;AAOV;;;;AAAA,KAAY,qBAAA;EAIV,0EAFA,UAAA,UAMA;EAJA,QAAA,WAMU;EAJV,aAAA;EAEA,aAAA;EAEA,UAAA;AAAA"}
@@ -0,0 +1,38 @@
1
+ import { ContentExposureEvent, TrackableEvent } from "../core/types.js";
2
+ import { KeyPath } from "@intlayer/types/keyPath";
3
+
4
+ //#region src/events/contentExposure.d.ts
5
+ /**
6
+ * Serializes a `KeyPath[]` into a compact, stable string used both as the
7
+ * coalescing key in the buffer and as the stored `keyPath` on the wire.
8
+ *
9
+ * Only the `key` of each segment is kept (types are implied by the dictionary
10
+ * shape), producing paths like `"faq.items.2.answer"`.
11
+ *
12
+ * @param keyPath - The interpreter key path locating a node.
13
+ * @returns A dot-joined, stable path string.
14
+ *
15
+ * @example
16
+ * serializeKeyPath([{ type: 'object', key: 'faq' }, { type: 'array', key: 2 }]);
17
+ * // "faq.2"
18
+ */
19
+ declare const serializeKeyPath: (keyPath: KeyPath[]) => string;
20
+ /**
21
+ * Builds a content-exposure payload from interpreter node metadata. Shared by
22
+ * every framework binding's analytics node plugin so the wire shape stays
23
+ * identical across React, Vue, Svelte, Angular, etc.
24
+ *
25
+ * @param params - Node metadata available on `NodeProps`.
26
+ * @returns A trackable content-exposure event (minus buffer-stamped fields).
27
+ */
28
+ declare const buildContentExposure: (params: {
29
+ dictionaryKey: string;
30
+ keyPath: KeyPath[];
31
+ locale?: string;
32
+ nodeType?: string;
33
+ experimentKey?: string;
34
+ variant?: string;
35
+ }) => Omit<TrackableEvent<ContentExposureEvent>, "type">;
36
+ //#endregion
37
+ export { buildContentExposure, serializeKeyPath };
38
+ //# sourceMappingURL=contentExposure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contentExposure.d.ts","names":[],"sources":["../../../src/events/contentExposure.ts"],"mappings":";;;;;;AAiBA;;;;;AAaA;;;;;;;cAba,gBAAA,GAAoB,OAAA,EAAS,OAAA;;;;;;;;;cAa7B,oBAAA,GAAwB,MAAA;EACnC,aAAA;EACA,OAAA,EAAS,OAAA;EACT,MAAA;EACA,QAAA;EACA,aAAA;EACA,OAAA;AAAA,MACE,IAAA,CAAK,cAAA,CAAe,oBAAA"}
@@ -0,0 +1,11 @@
1
+ import { AnalyticsClientConfig, AnalyticsEvent, AnalyticsEventType, AnalyticsIngestBody, BaseAnalyticsEvent, ContentExposureEvent, ConversionEvent, PageViewEvent, TrackableEvent } from "./core/types.js";
2
+ import { AnalyticsClient, DEFAULT_FLUSH_INTERVAL, DEFAULT_MAX_BUFFER_SIZE, DEFAULT_SAMPLE_RATE, MAX_EVENTS_PER_SEND, PageViewInput, createAnalyticsClient } from "./core/AnalyticsClient.js";
3
+ import { assignVariant } from "./core/abTesting.js";
4
+ import { EventBuffer, createEventBuffer } from "./core/eventBuffer.js";
5
+ import { decrementAnalyticsClientRefCount, getGlobalAnalyticsClient, incrementAnalyticsClientRefCount, setGlobalAnalyticsClient } from "./core/globalManager.js";
6
+ import { initAnalyticsClient, stopAnalyticsClient } from "./core/initAnalyticsClient.js";
7
+ import { isSampledIn } from "./core/sampling.js";
8
+ import { getSessionId } from "./core/session.js";
9
+ import { sendEvents } from "./core/transport.js";
10
+ import { buildContentExposure, serializeKeyPath } from "./events/contentExposure.js";
11
+ export { AnalyticsClient, AnalyticsClientConfig, AnalyticsEvent, AnalyticsEventType, AnalyticsIngestBody, BaseAnalyticsEvent, ContentExposureEvent, ConversionEvent, DEFAULT_FLUSH_INTERVAL, DEFAULT_MAX_BUFFER_SIZE, DEFAULT_SAMPLE_RATE, EventBuffer, MAX_EVENTS_PER_SEND, PageViewEvent, PageViewInput, TrackableEvent, assignVariant, buildContentExposure, createAnalyticsClient, createEventBuffer, decrementAnalyticsClientRefCount, getGlobalAnalyticsClient, getSessionId, incrementAnalyticsClientRefCount, initAnalyticsClient, isSampledIn, sendEvents, serializeKeyPath, setGlobalAnalyticsClient, stopAnalyticsClient };
@@ -0,0 +1,18 @@
1
+ //#region src/isEnabled.d.ts
2
+ /**
3
+ * Runtime guard mirroring `@intlayer/editor`'s `isEnabled`, but inverted with
4
+ * respect to the iframe: analytics runs for real end users on the **top**
5
+ * window and stays off inside the editor/CMS preview iframe so editor sessions
6
+ * are never counted as traffic.
7
+ *
8
+ * Enabled when:
9
+ * - the bundler did not tree-shake analytics away, and
10
+ * - the user opted in (`analytics.enabled === true`), and
11
+ * - a project key is configured (`editor.clientId`), and
12
+ * - we are on the client, and
13
+ * - we are the top window (not embedded in the editor).
14
+ */
15
+ declare const isEnabled: boolean;
16
+ //#endregion
17
+ export { isEnabled };
18
+ //# sourceMappingURL=isEnabled.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isEnabled.d.ts","names":[],"sources":["../../src/isEnabled.ts"],"mappings":";;AAuBA;;;;;;;;;;;;cAAa,SAAA"}
@@ -0,0 +1,16 @@
1
+ //#region src/utils/hash.d.ts
2
+ /**
3
+ * FNV-1a 32-bit string hash. Small, fast, dependency-free, and stable across
4
+ * runtimes — good enough for deterministic A/B bucketing and session seeding
5
+ * (not for cryptographic use).
6
+ *
7
+ * @param input - The string to hash.
8
+ * @returns An unsigned 32-bit integer hash.
9
+ *
10
+ * @example
11
+ * hashString('session-1:homepage-hero'); // 3039336720
12
+ */
13
+ declare const hashString: (input: string) => number;
14
+ //#endregion
15
+ export { hashString };
16
+ //# sourceMappingURL=hash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash.d.ts","names":[],"sources":["../../../src/utils/hash.ts"],"mappings":";;AAWA;;;;;;;;;;cAAa,UAAA,GAAc,KAAA"}
@@ -0,0 +1,15 @@
1
+ //#region src/utils/idle.d.ts
2
+ /**
3
+ * Runs a callback when the browser is idle, without blocking first render.
4
+ * Falls back to a short `setTimeout` where `requestIdleCallback` is unavailable
5
+ * (Safari, React Native, Lynx).
6
+ *
7
+ * @param callback - Work to run once the main thread is free.
8
+ *
9
+ * @example
10
+ * onIdle(() => attachVisibilityListeners());
11
+ */
12
+ declare const onIdle: (callback: () => void) => void;
13
+ //#endregion
14
+ export { onIdle };
15
+ //# sourceMappingURL=idle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"idle.d.ts","names":[],"sources":["../../../src/utils/idle.ts"],"mappings":";;AAUA;;;;;;;;;cAAa,MAAA,GAAU,QAAA"}