@intlayer/analytics 9.3.0 → 9.3.2

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/README.md CHANGED
@@ -47,27 +47,27 @@ With **per-locale content files**, **TypeScript autocompletion**, **tree-shakabl
47
47
 
48
48
  ## Keys benefits of Intlayer:
49
49
 
50
- | Feature | Description |
51
- | --------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
52
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/frameworks.png?raw=true" alt="Feature" width="700"> | **Cross-Frameworks Support**<br><br>Intlayer is compatible with all major frameworks and libraries, including Next.js, React, Vite, Vue.js, Nuxt, Preact, Express, and more. |
53
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/javascript_content_management.jpg?raw=true" alt="Feature" width="700"> | **JavaScript-Powered Content Management**<br><br>Harness the flexibility of JavaScript to define and manage your content efficiently. <br><br> - [Content declaration](https://intlayer.org/doc/concept/content) |
54
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/per_locale_content_declaration_file.png?raw=true" alt="Feature" width="700"> | **Per-Locale Content Declaration File**<br><br>Speed up your development by declaring your content once, before auto generation.<br><br> - [Per-Locale Content Declaration File](https://intlayer.org/doc/concept/per-locale-file) |
55
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/compiler.jpg?raw=true" alt="Feature" width="700"> | **Compiler**<br><br>The Intlayer Compiler extract automatically the content from the components and generate the dictionary files.<br><br> - [Compiler](https://intlayer.org/doc/compiler) |
56
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png?raw=true" alt="Feature" width="700"> | **Type-Safe Environment**<br><br>Leverage TypeScript to ensure your content definitions and code are error-free, while also benefiting from IDE autocompletion.<br><br> - [TypeScript configuration](https://intlayer.org/doc/environment/vite-and-react#configure-typescript) |
57
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/config_file.png?raw=true" alt="Feature" width="700"> | **Simplified Setup**<br><br>Get up and running quickly with minimal configuration. Adjust settings for internationalization, routing, AI, build, and content handling with ease. <br><br> - [Explore Next.js integration](https://intlayer.org/doc/environment/nextjs) |
58
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/content_retrieval.png?raw=true" alt="Feature" width="700"> | **Simplified Content Retrieval**<br><br>No need to call your `t` function for each piece of content. Retrieve all your content directly using a single hook.<br><br> - [React integration](https://intlayer.org/doc/environment/create-react-app) |
59
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/server_component.png?raw=true" alt="Feature" width="700"> | **Consistent Server Component Implementation**<br><br>Perfectly suited for Next.js server components, use the same implementation for both client and server components, no need to pass your `t` function across each server component. <br><br> - [Server Components](https://intlayer.org/doc/environment/nextjs#step-7-utilize-content-in-your-code) |
60
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/file_tree.png?raw=true" alt="Feature" width="700"> | **Organized Codebase**<br><br>Keep your codebase more organized: 1 component = 1 dictionary in the same folder. Translations close to their respective components, enhance maintainability and clarity. <br><br> - [How Intlayer works](https://intlayer.org/doc/concept/how-works-intlayer) |
61
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/url_routing.png?raw=true" alt="Feature" width="700"> | **Enhanced Routing**<br><br>Full support of app routing, adapting seamlessly to complex application structures, for Next.js, React, Vite, Vue.js, etc.<br><br> - [Explore Next.js integration](https://intlayer.org/doc/environment/nextjs) |
62
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/markdown.png?raw=true" alt="Feature" width="700"> | **Markdown Support**<br><br>Import and interpret, locale files and remote Markdown for multilingual content like privacy policies, documentation, etc. Interpret and make Markdown metadata accessible in your code.<br><br> - [Content files](https://intlayer.org/doc/concept/content/file) |
63
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/visual_editor.png?raw=true" alt="Feature" width="700"> | **Free Visual Editor & CMS**<br><br>A free visual editor and CMS are available for content writers, removing the need for a localization platform. Keep your content synchronized using Git, or externalize it totally or partially with the CMS.<br><br> - [Intlayer Editor](https://intlayer.org/doc/concept/editor) <br> - [Intlayer CMS](https://intlayer.org/doc/concept/cms) |
64
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/bundle.png?raw=true" alt="Feature" width="700"> | **Tree-shakable Content**<br><br>Tree-shakable content, reducing the size of the final bundle. Loads content per component, excluding any unused content from your bundle. Supports lazy loading to enhance app loading efficiency. <br><br> - [App build optimization](https://intlayer.org/doc/concept/how-works-intlayer#app-build-optimization) |
65
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/static_rendering.png?raw=true" alt="Feature" width="700"> | **Static Rendering**<br><br>Doesn't block Static Rendering. <br><br> - [Next.js integration](https://intlayer.org/doc/environment/nextjs) |
66
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/AI_translation.png?raw=true" alt="Feature" width="700"> | **AI-Powered Translation**<br><br>Transform your website into 231 languages with just one click using Intlayer's advanced AI-powered translation tools using your own AI provider / API key. <br><br> - [CI/CD integration](https://intlayer.org/doc/concept/ci-cd) <br> - [Intlayer CLI](https://intlayer.org/doc/concept/cli) <br> - [Auto fill](https://intlayer.org/doc/concept/auto-fill) |
67
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/mcp.png?raw=true" alt="Feature" width="700"> | **MCP Server Integration**<br><br>Provides an MCP (Model Context Protocol) server for IDE automation, enabling seamless content management and i18n workflows directly within your development environment. <br><br> - [MCP Server](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/mcp_server.md) |
68
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/vscode_extension.png?raw=true" alt="Feature" width="700"> | **VSCode Extension**<br><br>Intlayer provides a VSCode extension to help you manage your content and translations, building your dictionaries, translating your content, and more. <br><br> - [VSCode Extension](https://intlayer.org/doc/vs-code-extension) |
69
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/interoperability.png?raw=true" alt="Feature" width="700"> | **Interoperability**<br><br>Allow interoperability with react-i18next, next-i18next, next-intl, react-intl, vue-i18n. <br><br> - [Intlayer and react-intl](https://intlayer.org/blog/intlayer-with-react-intl) <br> - [Intlayer and next-intl](https://intlayer.org/blog/intlayer-with-next-intl) <br> - [Intlayer and next-i18next](https://intlayer.org/blog/intlayer-with-next-i18next) <br> - [Intlayer and vue-i18n](https://intlayer.org/blog/intlayer-with-vue-i18n) |
70
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/benchmark.png?raw=true" alt="Feature" width="700"> | **Performances & Benchmark**<br><br>Uses advanced tree-shaking and dynamic loading to boost performances and keep the solution as light as possible. <br><br> - [Performances & Benchmark](https://intlayer.org/doc/benchmark) |
50
+ | Feature | Description |
51
+ | --------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
52
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/frameworks.png?raw=true" alt="Feature" width="700"> | **Cross-Frameworks Support**<br><br>Intlayer is compatible with all major frameworks and libraries, including Next.js, React, Vite, Vue.js, Nuxt, Preact, Express, and more. |
53
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/javascript_content_management.jpg?raw=true" alt="Feature" width="700"> | **JavaScript-Powered Content Management**<br><br>Harness the flexibility of JavaScript to define and manage your content efficiently. <br><br> - [Content declaration](https://intlayer.org/doc/concept/content) |
54
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/per_locale_content_declaration_file.png?raw=true" alt="Feature" width="700"> | **Per-Locale Content Declaration File**<br><br>Speed up your development by declaring your content once, before auto generation.<br><br> - [Per-Locale Content Declaration File](https://intlayer.org/doc/concept/per-locale-file) |
55
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/compiler.jpg?raw=true" alt="Feature" width="700"> | **Compiler**<br><br>The Intlayer Compiler extract automatically the content from the components and generate the dictionary files.<br><br> - [Compiler](https://intlayer.org/doc/compiler) |
56
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png?raw=true" alt="Feature" width="700"> | **Type-Safe Environment**<br><br>Leverage TypeScript to ensure your content definitions and code are error-free, while also benefiting from IDE autocompletion.<br><br> - [TypeScript configuration](https://intlayer.org/doc/environment/vite-and-react#configure-typescript) |
57
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/config_file.png?raw=true" alt="Feature" width="700"> | **Simplified Setup**<br><br>Get up and running quickly with minimal configuration. Adjust settings for internationalization, routing, AI, build, and content handling with ease. <br><br> - [Explore Next.js integration](https://intlayer.org/doc/environment/nextjs) |
58
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/content_retrieval.png?raw=true" alt="Feature" width="700"> | **Simplified Content Retrieval**<br><br>No need to call your `t` function for each piece of content. Retrieve all your content directly using a single hook.<br><br> - [React integration](https://intlayer.org/doc/environment/create-react-app) |
59
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/server_component.png?raw=true" alt="Feature" width="700"> | **Consistent Server Component Implementation**<br><br>Perfectly suited for Next.js server components, use the same implementation for both client and server components, no need to pass your `t` function across each server component. <br><br> - [Server Components](https://intlayer.org/doc/environment/nextjs#step-7-utilize-content-in-your-code) |
60
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/file_tree.png?raw=true" alt="Feature" width="700"> | **Organized Codebase**<br><br>Keep your codebase more organized: 1 component = 1 dictionary in the same folder. Translations close to their respective components, enhance maintainability and clarity. <br><br> - [How Intlayer works](https://intlayer.org/doc/concept/how-works-intlayer) |
61
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/url_routing.png?raw=true" alt="Feature" width="700"> | **Enhanced Routing**<br><br>Full support of app routing, adapting seamlessly to complex application structures, for Next.js, React, Vite, Vue.js, etc.<br><br> - [Explore Next.js integration](https://intlayer.org/doc/environment/nextjs) |
62
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/markdown.png?raw=true" alt="Feature" width="700"> | **Markdown Support**<br><br>Import and interpret, locale files and remote Markdown for multilingual content like privacy policies, documentation, etc. Interpret and make Markdown metadata accessible in your code.<br><br> - [Content files](https://intlayer.org/doc/concept/content/file) |
63
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/visual_editor.png?raw=true" alt="Feature" width="700"> | **Free Visual Editor & CMS**<br><br>A free visual editor and CMS are available for content writers, removing the need for a localization platform. Keep your content synchronized using Git, or externalize it totally or partially with the CMS.<br><br> - [Intlayer Editor](https://intlayer.org/doc/concept/editor) <br> - [Intlayer CMS](https://intlayer.org/doc/concept/cms) |
64
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/bundle.png?raw=true" alt="Feature" width="700"> | **Tree-shakable Content**<br><br>Tree-shakable content, reducing the size of the final bundle. Loads content per component, excluding any unused content from your bundle. Supports lazy loading to enhance app loading efficiency. <br><br> - [App build optimization](https://intlayer.org/doc/concept/how-works-intlayer#app-build-optimization) |
65
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/static_rendering.png?raw=true" alt="Feature" width="700"> | **Static Rendering**<br><br>Doesn't block Static Rendering. <br><br> - [Next.js integration](https://intlayer.org/doc/environment/nextjs) |
66
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/AI_translation.png?raw=true" alt="Feature" width="700"> | **AI-Powered Translation**<br><br>Transform your website into 231 languages with just one click using Intlayer's advanced AI-powered translation tools using your own AI provider / API key. <br><br> - [CI/CD integration](https://intlayer.org/doc/concept/ci-cd) <br> - [Intlayer CLI](https://intlayer.org/doc/concept/cli) <br> - [Auto fill](https://intlayer.org/doc/concept/auto-fill) |
67
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/mcp.png?raw=true" alt="Feature" width="700"> | **MCP Server Integration**<br><br>Provides an MCP (Model Context Protocol) server for IDE automation, enabling seamless content management and i18n workflows directly within your development environment. <br><br> - [MCP Server](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/mcp_server.md) |
68
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/vscode_extension.png?raw=true" alt="Feature" width="700"> | **VSCode Extension**<br><br>Intlayer provides a VSCode extension to help you manage your content and translations, building your dictionaries, translating your content, and more. <br><br> - [VSCode Extension](https://intlayer.org/doc/vs-code-extension) |
69
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/interoperability.png?raw=true" alt="Feature" width="700"> | **Interoperability**<br><br>Allow interoperability with react-i18next, next-i18next, next-intl, react-intl, vue-i18n. <br><br> - [Intlayer and react-intl](https://intlayer.org/blog/intlayer-with-react-intl) <br> - [Intlayer and next-intl](https://intlayer.org/blog/intlayer-with-next-intl) <br> - [Intlayer and next-i18next](https://intlayer.org/blog/intlayer-with-next-i18next) <br> - [Intlayer and vue-i18n](https://intlayer.org/blog/intlayer-with-vue-i18n) <br> - [Intlayer compat adapters](https://intlayer.org/doc/compatibility) |
70
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/benchmark.png?raw=true" alt="Feature" width="700"> | **Performances & Benchmark**<br><br>Uses advanced tree-shaking and dynamic loading to boost performances and keep the solution as light as possible. <br><br> - [Performances & Benchmark](https://intlayer.org/doc/benchmark) |
71
71
 
72
72
  ---
73
73
 
@@ -162,7 +162,7 @@ Explore our comprehensive documentation to get started with Intlayer and learn h
162
162
  <li><a href="https://intlayer.org/doc/concept/cms" rel=''>Intlayer CMS</a></li>
163
163
  <li><a href="https://intlayer.org/doc/concept/content" rel=''>Dictionary</a>
164
164
  <ul>
165
- <li><a href="https://intlayer.org/doc/concept/content/per-locale-file" rel=''>Per-Locale Content Declaration File</a></li>
165
+ <li><a href="https://intlayer.org/doc/concept/per-locale-file" rel=''>Per-Locale Content Declaration File</a></li>
166
166
  <li><a href="https://intlayer.org/doc/concept/content/translation" rel=''>Translation</a></li>
167
167
  <li><a href="https://intlayer.org/doc/concept/content/enumeration" rel=''>Enumeration</a></li>
168
168
  <li><a href="https://intlayer.org/doc/concept/content/condition" rel=''>Condition</a></li>
@@ -183,7 +183,7 @@ Explore our comprehensive documentation to get started with Intlayer and learn h
183
183
  <ul>
184
184
  <li><a href="https://intlayer.org/doc/environment/nextjs/15" rel=''>Next.js 15</a></li>
185
185
  <li><a href="https://intlayer.org/doc/environment/nextjs/14" rel=''>Next.js 14 (App Router)</a></li>
186
- <li><a href="https://intlayer.org/doc/environment/nextjs/next-with-Page-Router" rel=''>Next.js Page Router</a></li>
186
+ <li><a href="https://intlayer.org/doc/environment/nextjs/next-with-page-router" rel=''>Next.js Page Router</a></li>
187
187
  <li><a href="https://intlayer.org/doc/environment/nextjs/compiler" rel=''>Next.js using Compiler</a></li>
188
188
  </ul>
189
189
  </li>
@@ -212,7 +212,7 @@ Explore our comprehensive documentation to get started with Intlayer and learn h
212
212
  <li><a href="https://intlayer.org/doc/environment/sveltekit" rel=''>SvelteKit</a></li>
213
213
  <li><a href="https://intlayer.org/doc/environment/vite-and-preact" rel=''>Vite + Preact</a></li>
214
214
  <li><a href="https://intlayer.org/doc/environment/vite-and-vue" rel=''>Vite + Vue</a></li>
215
- <li><a href="https://intlayer.org/doc/environment/vite-and-nuxt" rel=''>Vite + Nuxt</a></li>
215
+ <li><a href="https://intlayer.org/doc/environment/nuxt-and-vue" rel=''>Vite + Nuxt</a></li>
216
216
  <li><a href="https://intlayer.org/doc/environment/vite-and-solid" rel=''>Vite + Solid</a></li>
217
217
  <li><a href="https://intlayer.org/doc/environment/angular" rel=''>Angular</a></li>
218
218
  <li>
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
3
2
  //#region src/core/eventBuffer.ts
4
3
  /** Field separator for coalescing keys — never present in content keys. */
5
4
  const KEY_SEPARATOR = "";
@@ -1 +1 @@
1
- {"version":3,"file":"eventBuffer.cjs","names":[],"sources":["../../../src/core/eventBuffer.ts"],"sourcesContent":["import type { AnalyticsEvent, ContentExposureEvent } from './types';\n\n/** Field separator for coalescing keys — never present in content keys. */\nconst KEY_SEPARATOR = '\u0001';\n\n/**\n * Builds the coalescing key for a content-exposure event. Two exposures of the\n * same node, page, locale, experiment, and variant collapse into one event with\n * an incremented `count`.\n */\nconst exposureKey = (event: ContentExposureEvent): string =>\n [\n event.url,\n event.dictionaryKey,\n event.keyPath,\n event.locale,\n event.experimentKey ?? '',\n event.variant ?? '',\n ].join(KEY_SEPARATOR);\n\n/**\n * A bounded, coalescing in-memory buffer for analytics events.\n *\n * - `page_view` and `conversion` events are appended verbatim (they are rare\n * and valuable — they are never evicted while exposures remain).\n * - `content_exposure` events are deduplicated by page/node/locale/variant with\n * a running `count`, keeping the highest-volume signal cheap.\n * - When the total number of stored events exceeds `max`, the **oldest\n * exposures** are evicted first (analytics is lossy by design; exposures are\n * the expendable signal). Discrete events are only dropped once no exposures\n * remain.\n */\nexport type EventBuffer = {\n /** Adds an event, coalescing content exposures. Returns the current size. */\n push: (event: AnalyticsEvent) => number;\n /** Removes and returns every buffered event. */\n drain: () => AnalyticsEvent[];\n /** Current number of distinct buffered events. */\n size: () => number;\n};\n\n/**\n * Creates an {@link EventBuffer}.\n *\n * @param options - Buffer options.\n * @param options.max - Maximum number of distinct events to retain.\n * @returns A new buffer instance.\n */\nexport const createEventBuffer = ({ max }: { max: number }): EventBuffer => {\n // Insertion-ordered list of non-coalesced events (page views, conversions).\n let discreteEvents: AnalyticsEvent[] = [];\n // Coalesced content exposures keyed by page/node/locale/variant.\n const exposures = new Map<string, ContentExposureEvent>();\n\n const size = (): number => discreteEvents.length + exposures.size;\n\n /** Evicts oldest exposures first, then oldest discrete events. */\n const enforceCap = (): void => {\n while (size() > max && exposures.size > 0) {\n // Map iteration follows insertion order — the first key is the oldest.\n const oldestKey = exposures.keys().next().value as string;\n exposures.delete(oldestKey);\n }\n if (size() > max) {\n discreteEvents = discreteEvents.slice(size() - max);\n }\n };\n\n const push = (event: AnalyticsEvent): number => {\n if (event.type === 'content_exposure') {\n const key = exposureKey(event);\n const existing = exposures.get(key);\n\n if (existing) {\n existing.count = (existing.count ?? 1) + (event.count ?? 1);\n existing.t = event.t; // keep the most recent timestamp\n } else {\n exposures.set(key, { ...event, count: event.count ?? 1 });\n }\n } else {\n discreteEvents.push(event);\n }\n\n enforceCap();\n\n return size();\n };\n\n const drain = (): AnalyticsEvent[] => {\n const drained: AnalyticsEvent[] = [\n ...discreteEvents,\n ...exposures.values(),\n ];\n discreteEvents = [];\n exposures.clear();\n return drained;\n };\n\n return { push, drain, size };\n};\n"],"mappings":";;;;AAGA,MAAM,gBAAgB;;;;;;AAOtB,MAAM,eAAe,UACnB;CACE,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM,iBAAiB;CACvB,MAAM,WAAW;AACnB,CAAC,CAAC,KAAK,aAAa;;;;;;;;AA8BtB,MAAa,qBAAqB,EAAE,UAAwC;CAE1E,IAAI,iBAAmC,CAAC;CAExC,MAAM,4BAAY,IAAI,IAAkC;CAExD,MAAM,aAAqB,eAAe,SAAS,UAAU;;CAG7D,MAAM,mBAAyB;EAC7B,OAAO,KAAK,IAAI,OAAO,UAAU,OAAO,GAAG;GAEzC,MAAM,YAAY,UAAU,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC;GAC1C,UAAU,OAAO,SAAS;EAC5B;EACA,IAAI,KAAK,IAAI,KACX,iBAAiB,eAAe,MAAM,KAAK,IAAI,GAAG;CAEtD;CAEA,MAAM,QAAQ,UAAkC;EAC9C,IAAI,MAAM,SAAS,oBAAoB;GACrC,MAAM,MAAM,YAAY,KAAK;GAC7B,MAAM,WAAW,UAAU,IAAI,GAAG;GAElC,IAAI,UAAU;IACZ,SAAS,SAAS,SAAS,SAAS,MAAM,MAAM,SAAS;IACzD,SAAS,IAAI,MAAM;GACrB,OACE,UAAU,IAAI,KAAK;IAAE,GAAG;IAAO,OAAO,MAAM,SAAS;GAAE,CAAC;EAE5D,OACE,eAAe,KAAK,KAAK;EAG3B,WAAW;EAEX,OAAO,KAAK;CACd;CAEA,MAAM,cAAgC;EACpC,MAAM,UAA4B,CAChC,GAAG,gBACH,GAAG,UAAU,OAAO,CACtB;EACA,iBAAiB,CAAC;EAClB,UAAU,MAAM;EAChB,OAAO;CACT;CAEA,OAAO;EAAE;EAAM;EAAO;CAAK;AAC7B"}
1
+ {"version":3,"file":"eventBuffer.cjs","names":[],"sources":["../../../src/core/eventBuffer.ts"],"sourcesContent":["import type { AnalyticsEvent, ContentExposureEvent } from './types';\n\n/** Field separator for coalescing keys — never present in content keys. */\nconst KEY_SEPARATOR = '\u0001';\n\n/**\n * Builds the coalescing key for a content-exposure event. Two exposures of the\n * same node, page, locale, experiment, and variant collapse into one event with\n * an incremented `count`.\n */\nconst exposureKey = (event: ContentExposureEvent): string =>\n [\n event.url,\n event.dictionaryKey,\n event.keyPath,\n event.locale,\n event.experimentKey ?? '',\n event.variant ?? '',\n ].join(KEY_SEPARATOR);\n\n/**\n * A bounded, coalescing in-memory buffer for analytics events.\n *\n * - `page_view` and `conversion` events are appended verbatim (they are rare\n * and valuable — they are never evicted while exposures remain).\n * - `content_exposure` events are deduplicated by page/node/locale/variant with\n * a running `count`, keeping the highest-volume signal cheap.\n * - When the total number of stored events exceeds `max`, the **oldest\n * exposures** are evicted first (analytics is lossy by design; exposures are\n * the expendable signal). Discrete events are only dropped once no exposures\n * remain.\n */\nexport type EventBuffer = {\n /** Adds an event, coalescing content exposures. Returns the current size. */\n push: (event: AnalyticsEvent) => number;\n /** Removes and returns every buffered event. */\n drain: () => AnalyticsEvent[];\n /** Current number of distinct buffered events. */\n size: () => number;\n};\n\n/**\n * Creates an {@link EventBuffer}.\n *\n * @param options - Buffer options.\n * @param options.max - Maximum number of distinct events to retain.\n * @returns A new buffer instance.\n */\nexport const createEventBuffer = ({ max }: { max: number }): EventBuffer => {\n // Insertion-ordered list of non-coalesced events (page views, conversions).\n let discreteEvents: AnalyticsEvent[] = [];\n // Coalesced content exposures keyed by page/node/locale/variant.\n const exposures = new Map<string, ContentExposureEvent>();\n\n const size = (): number => discreteEvents.length + exposures.size;\n\n /** Evicts oldest exposures first, then oldest discrete events. */\n const enforceCap = (): void => {\n while (size() > max && exposures.size > 0) {\n // Map iteration follows insertion order — the first key is the oldest.\n const oldestKey = exposures.keys().next().value as string;\n exposures.delete(oldestKey);\n }\n if (size() > max) {\n discreteEvents = discreteEvents.slice(size() - max);\n }\n };\n\n const push = (event: AnalyticsEvent): number => {\n if (event.type === 'content_exposure') {\n const key = exposureKey(event);\n const existing = exposures.get(key);\n\n if (existing) {\n existing.count = (existing.count ?? 1) + (event.count ?? 1);\n existing.t = event.t; // keep the most recent timestamp\n } else {\n exposures.set(key, { ...event, count: event.count ?? 1 });\n }\n } else {\n discreteEvents.push(event);\n }\n\n enforceCap();\n\n return size();\n };\n\n const drain = (): AnalyticsEvent[] => {\n const drained: AnalyticsEvent[] = [\n ...discreteEvents,\n ...exposures.values(),\n ];\n discreteEvents = [];\n exposures.clear();\n return drained;\n };\n\n return { push, drain, size };\n};\n"],"mappings":";;;AAGA,MAAM,gBAAgB;;;;;;AAOtB,MAAM,eAAe,UACnB;CACE,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM,iBAAiB;CACvB,MAAM,WAAW;AACnB,CAAC,CAAC,KAAK,aAAa;;;;;;;;AA8BtB,MAAa,qBAAqB,EAAE,UAAwC;CAE1E,IAAI,iBAAmC,CAAC;CAExC,MAAM,4BAAY,IAAI,IAAkC;CAExD,MAAM,aAAqB,eAAe,SAAS,UAAU;;CAG7D,MAAM,mBAAyB;EAC7B,OAAO,KAAK,IAAI,OAAO,UAAU,OAAO,GAAG;GAEzC,MAAM,YAAY,UAAU,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC;GAC1C,UAAU,OAAO,SAAS;EAC5B;EACA,IAAI,KAAK,IAAI,KACX,iBAAiB,eAAe,MAAM,KAAK,IAAI,GAAG;CAEtD;CAEA,MAAM,QAAQ,UAAkC;EAC9C,IAAI,MAAM,SAAS,oBAAoB;GACrC,MAAM,MAAM,YAAY,KAAK;GAC7B,MAAM,WAAW,UAAU,IAAI,GAAG;GAElC,IAAI,UAAU;IACZ,SAAS,SAAS,SAAS,SAAS,MAAM,MAAM,SAAS;IACzD,SAAS,IAAI,MAAM;GACrB,OACE,UAAU,IAAI,KAAK;IAAE,GAAG;IAAO,OAAO,MAAM,SAAS;GAAE,CAAC;EAE5D,OACE,eAAe,KAAK,KAAK;EAG3B,WAAW;EAEX,OAAO,KAAK;CACd;CAEA,MAAM,cAAgC;EACpC,MAAM,UAA4B,CAChC,GAAG,gBACH,GAAG,UAAU,OAAO,CACtB;EACA,iBAAiB,CAAC;EAClB,UAAU,MAAM;EAChB,OAAO;CACT;CAEA,OAAO;EAAE;EAAM;EAAO;CAAK;AAC7B"}
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
3
2
  //#region src/core/globalManager.ts
4
3
  /**
5
4
  * Key on `window` used to share the client singleton across multiple module
@@ -1 +1 @@
1
- {"version":3,"file":"globalManager.cjs","names":[],"sources":["../../../src/core/globalManager.ts"],"sourcesContent":["import type { AnalyticsClient } from './AnalyticsClient';\n\n/**\n * Key on `window` used to share the client singleton across multiple module\n * instances. When bundlers include `@intlayer/analytics` more than once (e.g.\n * a framework package plus the app), each copy has its own module-level\n * variables; storing the client on `window` ensures they all share one buffer\n * and one flush timer.\n */\nconst CLIENT_KEY = '__intlayer_analytics_client__';\n\n/**\n * Key on `window` holding the provider reference count. It lives next to the\n * client (rather than in module scope) for the same reason the client does:\n * duplicated module instances must share one count, otherwise one copy's\n * `stopAnalyticsClient` could stop a client another copy still uses.\n */\nconst REF_COUNT_KEY = '__intlayer_analytics_ref_count__';\n\ntype WindowWithAnalyticsGlobals = typeof window & {\n [CLIENT_KEY]?: AnalyticsClient | null;\n [REF_COUNT_KEY]?: number;\n};\n\n/**\n * Returns the global analytics client, or `null` in SSR or before init.\n */\nexport const getGlobalAnalyticsClient = (): AnalyticsClient | null => {\n if (typeof window === 'undefined') return null;\n return (window as WindowWithAnalyticsGlobals)[CLIENT_KEY] ?? null;\n};\n\n/**\n * Sets (or clears) the global analytics client singleton.\n *\n * @param client - The client to store globally, or `null` to clear it.\n */\nexport const setGlobalAnalyticsClient = (\n client: AnalyticsClient | null\n): void => {\n if (typeof window === 'undefined') return;\n (window as WindowWithAnalyticsGlobals)[CLIENT_KEY] = client;\n};\n\n/**\n * Increments the shared provider reference count.\n *\n * @returns The count after incrementing (`0` in SSR, where nothing is stored).\n */\nexport const incrementAnalyticsClientRefCount = (): number => {\n if (typeof window === 'undefined') return 0;\n const globals = window as WindowWithAnalyticsGlobals;\n globals[REF_COUNT_KEY] = (globals[REF_COUNT_KEY] ?? 0) + 1;\n return globals[REF_COUNT_KEY];\n};\n\n/**\n * Decrements the shared provider reference count, clamping at zero.\n *\n * @returns The count after decrementing (`0` in SSR, where nothing is stored).\n */\nexport const decrementAnalyticsClientRefCount = (): number => {\n if (typeof window === 'undefined') return 0;\n const globals = window as WindowWithAnalyticsGlobals;\n globals[REF_COUNT_KEY] = Math.max(0, (globals[REF_COUNT_KEY] ?? 0) - 1);\n return globals[REF_COUNT_KEY];\n};\n"],"mappings":";;;;;;;;;;AASA,MAAM,aAAa;;;;;;;AAQnB,MAAM,gBAAgB;;;;AAUtB,MAAa,iCAAyD;CACpE,IAAI,OAAO,WAAW,aAAa,OAAO;CAC1C,OAAQ,OAAsC,eAAe;AAC/D;;;;;;AAOA,MAAa,4BACX,WACS;CACT,IAAI,OAAO,WAAW,aAAa;CACnC,AAAC,OAAsC,cAAc;AACvD;;;;;;AAOA,MAAa,yCAAiD;CAC5D,IAAI,OAAO,WAAW,aAAa,OAAO;CAC1C,MAAM,UAAU;CAChB,QAAQ,kBAAkB,QAAQ,kBAAkB,KAAK;CACzD,OAAO,QAAQ;AACjB;;;;;;AAOA,MAAa,yCAAiD;CAC5D,IAAI,OAAO,WAAW,aAAa,OAAO;CAC1C,MAAM,UAAU;CAChB,QAAQ,iBAAiB,KAAK,IAAI,IAAI,QAAQ,kBAAkB,KAAK,CAAC;CACtE,OAAO,QAAQ;AACjB"}
1
+ {"version":3,"file":"globalManager.cjs","names":[],"sources":["../../../src/core/globalManager.ts"],"sourcesContent":["import type { AnalyticsClient } from './AnalyticsClient';\n\n/**\n * Key on `window` used to share the client singleton across multiple module\n * instances. When bundlers include `@intlayer/analytics` more than once (e.g.\n * a framework package plus the app), each copy has its own module-level\n * variables; storing the client on `window` ensures they all share one buffer\n * and one flush timer.\n */\nconst CLIENT_KEY = '__intlayer_analytics_client__';\n\n/**\n * Key on `window` holding the provider reference count. It lives next to the\n * client (rather than in module scope) for the same reason the client does:\n * duplicated module instances must share one count, otherwise one copy's\n * `stopAnalyticsClient` could stop a client another copy still uses.\n */\nconst REF_COUNT_KEY = '__intlayer_analytics_ref_count__';\n\ntype WindowWithAnalyticsGlobals = typeof window & {\n [CLIENT_KEY]?: AnalyticsClient | null;\n [REF_COUNT_KEY]?: number;\n};\n\n/**\n * Returns the global analytics client, or `null` in SSR or before init.\n */\nexport const getGlobalAnalyticsClient = (): AnalyticsClient | null => {\n if (typeof window === 'undefined') return null;\n return (window as WindowWithAnalyticsGlobals)[CLIENT_KEY] ?? null;\n};\n\n/**\n * Sets (or clears) the global analytics client singleton.\n *\n * @param client - The client to store globally, or `null` to clear it.\n */\nexport const setGlobalAnalyticsClient = (\n client: AnalyticsClient | null\n): void => {\n if (typeof window === 'undefined') return;\n (window as WindowWithAnalyticsGlobals)[CLIENT_KEY] = client;\n};\n\n/**\n * Increments the shared provider reference count.\n *\n * @returns The count after incrementing (`0` in SSR, where nothing is stored).\n */\nexport const incrementAnalyticsClientRefCount = (): number => {\n if (typeof window === 'undefined') return 0;\n const globals = window as WindowWithAnalyticsGlobals;\n globals[REF_COUNT_KEY] = (globals[REF_COUNT_KEY] ?? 0) + 1;\n return globals[REF_COUNT_KEY];\n};\n\n/**\n * Decrements the shared provider reference count, clamping at zero.\n *\n * @returns The count after decrementing (`0` in SSR, where nothing is stored).\n */\nexport const decrementAnalyticsClientRefCount = (): number => {\n if (typeof window === 'undefined') return 0;\n const globals = window as WindowWithAnalyticsGlobals;\n globals[REF_COUNT_KEY] = Math.max(0, (globals[REF_COUNT_KEY] ?? 0) - 1);\n return globals[REF_COUNT_KEY];\n};\n"],"mappings":";;;;;;;;;AASA,MAAM,aAAa;;;;;;;AAQnB,MAAM,gBAAgB;;;;AAUtB,MAAa,iCAAyD;CACpE,IAAI,OAAO,WAAW,aAAa,OAAO;CAC1C,OAAQ,OAAsC,eAAe;AAC/D;;;;;;AAOA,MAAa,4BACX,WACS;CACT,IAAI,OAAO,WAAW,aAAa;CACnC,AAAC,OAAsC,cAAc;AACvD;;;;;;AAOA,MAAa,yCAAiD;CAC5D,IAAI,OAAO,WAAW,aAAa,OAAO;CAC1C,MAAM,UAAU;CAChB,QAAQ,kBAAkB,QAAQ,kBAAkB,KAAK;CACzD,OAAO,QAAQ;AACjB;;;;;;AAOA,MAAa,yCAAiD;CAC5D,IAAI,OAAO,WAAW,aAAa,OAAO;CAC1C,MAAM,UAAU;CAChB,QAAQ,iBAAiB,KAAK,IAAI,IAAI,QAAQ,kBAAkB,KAAK,CAAC;CACtE,OAAO,QAAQ;AACjB"}
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
3
2
  //#region src/core/session.ts
4
3
  /**
5
4
  * Anonymous, per-tab session identity. Stored in `sessionStorage` so it is
@@ -1 +1 @@
1
- {"version":3,"file":"session.cjs","names":[],"sources":["../../../src/core/session.ts"],"sourcesContent":["/**\n * Anonymous, per-tab session identity. Stored in `sessionStorage` so it is\n * cleared when the tab closes and is never shared across sites — no durable\n * cookie, no cross-site tracking, no PII.\n */\n\nconst SESSION_STORAGE_KEY = '__intlayer_analytics_sid__';\n\n/**\n * Generates a random, opaque session identifier.\n *\n * @returns A URL-safe random string.\n */\nconst generateSessionId = (): string => {\n const cryptoObj =\n typeof globalThis !== 'undefined'\n ? (globalThis.crypto as Crypto | undefined)\n : undefined;\n\n if (cryptoObj?.randomUUID) {\n return cryptoObj.randomUUID();\n }\n\n // Fallback for environments without crypto.randomUUID (older RN/Lynx)\n return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;\n};\n\n/**\n * Returns the current session id, creating and persisting one on first access.\n * Degrades gracefully to an in-memory id when `sessionStorage` is unavailable\n * (private mode, native runtimes).\n *\n * @returns The stable session id for the lifetime of the tab.\n */\nexport const getSessionId = (): string => {\n if (typeof window === 'undefined' || !window.sessionStorage) {\n return generateSessionId();\n }\n\n try {\n const existing = window.sessionStorage.getItem(SESSION_STORAGE_KEY);\n if (existing) return existing;\n\n const created = generateSessionId();\n window.sessionStorage.setItem(SESSION_STORAGE_KEY, created);\n return created;\n } catch {\n // sessionStorage can throw (Safari private mode, quota) — never break the app\n return generateSessionId();\n }\n};\n"],"mappings":";;;;;;;;AAMA,MAAM,sBAAsB;;;;;;AAO5B,MAAM,0BAAkC;CACtC,MAAM,YACJ,OAAO,eAAe,cACjB,WAAW,SACZ;CAEN,IAAI,WAAW,YACb,OAAO,UAAU,WAAW;CAI9B,OAAO,GAAG,KAAK,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,GAAG,KAAK,OAAO,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,MAAM,GAAG,EAAE;AAC7E;;;;;;;;AASA,MAAa,qBAA6B;CACxC,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,gBAC3C,OAAO,kBAAkB;CAG3B,IAAI;EACF,MAAM,WAAW,OAAO,eAAe,QAAQ,mBAAmB;EAClE,IAAI,UAAU,OAAO;EAErB,MAAM,UAAU,kBAAkB;EAClC,OAAO,eAAe,QAAQ,qBAAqB,OAAO;EAC1D,OAAO;CACT,QAAQ;EAEN,OAAO,kBAAkB;CAC3B;AACF"}
1
+ {"version":3,"file":"session.cjs","names":[],"sources":["../../../src/core/session.ts"],"sourcesContent":["/**\n * Anonymous, per-tab session identity. Stored in `sessionStorage` so it is\n * cleared when the tab closes and is never shared across sites — no durable\n * cookie, no cross-site tracking, no PII.\n */\n\nconst SESSION_STORAGE_KEY = '__intlayer_analytics_sid__';\n\n/**\n * Generates a random, opaque session identifier.\n *\n * @returns A URL-safe random string.\n */\nconst generateSessionId = (): string => {\n const cryptoObj =\n typeof globalThis !== 'undefined'\n ? (globalThis.crypto as Crypto | undefined)\n : undefined;\n\n if (cryptoObj?.randomUUID) {\n return cryptoObj.randomUUID();\n }\n\n // Fallback for environments without crypto.randomUUID (older RN/Lynx)\n return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;\n};\n\n/**\n * Returns the current session id, creating and persisting one on first access.\n * Degrades gracefully to an in-memory id when `sessionStorage` is unavailable\n * (private mode, native runtimes).\n *\n * @returns The stable session id for the lifetime of the tab.\n */\nexport const getSessionId = (): string => {\n if (typeof window === 'undefined' || !window.sessionStorage) {\n return generateSessionId();\n }\n\n try {\n const existing = window.sessionStorage.getItem(SESSION_STORAGE_KEY);\n if (existing) return existing;\n\n const created = generateSessionId();\n window.sessionStorage.setItem(SESSION_STORAGE_KEY, created);\n return created;\n } catch {\n // sessionStorage can throw (Safari private mode, quota) — never break the app\n return generateSessionId();\n }\n};\n"],"mappings":";;;;;;;AAMA,MAAM,sBAAsB;;;;;;AAO5B,MAAM,0BAAkC;CACtC,MAAM,YACJ,OAAO,eAAe,cACjB,WAAW,SACZ;CAEN,IAAI,WAAW,YACb,OAAO,UAAU,WAAW;CAI9B,OAAO,GAAG,KAAK,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,GAAG,KAAK,OAAO,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,MAAM,GAAG,EAAE;AAC7E;;;;;;;;AASA,MAAa,qBAA6B;CACxC,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,gBAC3C,OAAO,kBAAkB;CAG3B,IAAI;EACF,MAAM,WAAW,OAAO,eAAe,QAAQ,mBAAmB;EAClE,IAAI,UAAU,OAAO;EAErB,MAAM,UAAU,kBAAkB;EAClC,OAAO,eAAe,QAAQ,qBAAqB,OAAO;EAC1D,OAAO;CACT,QAAQ;EAEN,OAAO,kBAAkB;CAC3B;AACF"}
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
3
2
  //#region src/core/transport.ts
4
3
  /**
5
4
  * Sends a batch of events to the backend. Every path is non-blocking and
@@ -1 +1 @@
1
- {"version":3,"file":"transport.cjs","names":[],"sources":["../../../src/core/transport.ts"],"sourcesContent":["import type { AnalyticsIngestBody } from './types';\n\n/**\n * Sends a batch of events to the backend. Every path is non-blocking and\n * no-throw — analytics must never break, slow, or delay the host application.\n *\n * Strategy:\n * 1. `navigator.sendBeacon` for the flush-on-hide path — survives page unload\n * and never blocks navigation. The payload is sent as `text/plain` (a\n * CORS-safelisted content type): a JSON `Blob` would require a CORS\n * preflight that browsers handle inconsistently during unload, silently\n * dropping the beacon. The backend parses `text/plain` bodies as JSON.\n * 2. `fetch(..., { keepalive: true })` for interval flushes — survives short\n * navigations without holding the main thread.\n * 3. Plain `fetch` fallback for runtimes without `keepalive` (older RN/Lynx).\n *\n * @param endpoint - Fully-qualified ingestion URL.\n * @param body - The batched payload.\n * @param options - Transport options.\n * @param options.useBeacon - Prefer `sendBeacon` (used when the page is hiding).\n * @returns `true` when a send was dispatched, `false` otherwise.\n */\nexport const sendEvents = (\n endpoint: string,\n body: AnalyticsIngestBody,\n { useBeacon = false }: { useBeacon?: boolean } = {}\n): boolean => {\n try {\n const payload = JSON.stringify(body);\n\n if (\n useBeacon &&\n typeof navigator !== 'undefined' &&\n typeof navigator.sendBeacon === 'function'\n ) {\n // Note: unlike the fetch path below, sendBeacon always includes\n // credentials; the ingest endpoint ignores them.\n return navigator.sendBeacon(endpoint, payload);\n }\n\n if (typeof fetch === 'function') {\n // keepalive lets the request outlive a same-tab navigation.\n void fetch(endpoint, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: payload,\n keepalive: true,\n // Analytics is best-effort; never send credentials.\n credentials: 'omit',\n mode: 'cors',\n }).catch(() => {\n /* swallow — best-effort delivery */\n });\n return true;\n }\n\n return false;\n } catch {\n // JSON serialization failed — drop the batch silently.\n return false;\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAa,cACX,UACA,MACA,EAAE,YAAY,UAAmC,CAAC,MACtC;CACZ,IAAI;EACF,MAAM,UAAU,KAAK,UAAU,IAAI;EAEnC,IACE,aACA,OAAO,cAAc,eACrB,OAAO,UAAU,eAAe,YAIhC,OAAO,UAAU,WAAW,UAAU,OAAO;EAG/C,IAAI,OAAO,UAAU,YAAY;GAE/B,AAAK,MAAM,UAAU;IACnB,QAAQ;IACR,SAAS,EAAE,gBAAgB,mBAAmB;IAC9C,MAAM;IACN,WAAW;IAEX,aAAa;IACb,MAAM;GACR,CAAC,CAAC,CAAC,YAAY,CAEf,CAAC;GACD,OAAO;EACT;EAEA,OAAO;CACT,QAAQ;EAEN,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"transport.cjs","names":[],"sources":["../../../src/core/transport.ts"],"sourcesContent":["import type { AnalyticsIngestBody } from './types';\n\n/**\n * Sends a batch of events to the backend. Every path is non-blocking and\n * no-throw — analytics must never break, slow, or delay the host application.\n *\n * Strategy:\n * 1. `navigator.sendBeacon` for the flush-on-hide path — survives page unload\n * and never blocks navigation. The payload is sent as `text/plain` (a\n * CORS-safelisted content type): a JSON `Blob` would require a CORS\n * preflight that browsers handle inconsistently during unload, silently\n * dropping the beacon. The backend parses `text/plain` bodies as JSON.\n * 2. `fetch(..., { keepalive: true })` for interval flushes — survives short\n * navigations without holding the main thread.\n * 3. Plain `fetch` fallback for runtimes without `keepalive` (older RN/Lynx).\n *\n * @param endpoint - Fully-qualified ingestion URL.\n * @param body - The batched payload.\n * @param options - Transport options.\n * @param options.useBeacon - Prefer `sendBeacon` (used when the page is hiding).\n * @returns `true` when a send was dispatched, `false` otherwise.\n */\nexport const sendEvents = (\n endpoint: string,\n body: AnalyticsIngestBody,\n { useBeacon = false }: { useBeacon?: boolean } = {}\n): boolean => {\n try {\n const payload = JSON.stringify(body);\n\n if (\n useBeacon &&\n typeof navigator !== 'undefined' &&\n typeof navigator.sendBeacon === 'function'\n ) {\n // Note: unlike the fetch path below, sendBeacon always includes\n // credentials; the ingest endpoint ignores them.\n return navigator.sendBeacon(endpoint, payload);\n }\n\n if (typeof fetch === 'function') {\n // keepalive lets the request outlive a same-tab navigation.\n void fetch(endpoint, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: payload,\n keepalive: true,\n // Analytics is best-effort; never send credentials.\n credentials: 'omit',\n mode: 'cors',\n }).catch(() => {\n /* swallow — best-effort delivery */\n });\n return true;\n }\n\n return false;\n } catch {\n // JSON serialization failed — drop the batch silently.\n return false;\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAa,cACX,UACA,MACA,EAAE,YAAY,UAAmC,CAAC,MACtC;CACZ,IAAI;EACF,MAAM,UAAU,KAAK,UAAU,IAAI;EAEnC,IACE,aACA,OAAO,cAAc,eACrB,OAAO,UAAU,eAAe,YAIhC,OAAO,UAAU,WAAW,UAAU,OAAO;EAG/C,IAAI,OAAO,UAAU,YAAY;GAE/B,AAAK,MAAM,UAAU;IACnB,QAAQ;IACR,SAAS,EAAE,gBAAgB,mBAAmB;IAC9C,MAAM;IACN,WAAW;IAEX,aAAa;IACb,MAAM;GACR,CAAC,CAAC,CAAC,YAAY,CAEf,CAAC;GACD,OAAO;EACT;EAEA,OAAO;CACT,QAAQ;EAEN,OAAO;CACT;AACF"}
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
3
2
  //#region src/events/contentExposure.ts
4
3
  /**
5
4
  * Serializes a `KeyPath[]` into a compact, stable string used both as the
@@ -1 +1 @@
1
- {"version":3,"file":"contentExposure.cjs","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,GAAG,CAAE,CAAC,CACzE,KAAK,GAAG;;;;;;;;;AAUb,MAAa,wBAAwB,YAOsB;CACzD,eAAe,OAAO;CACtB,SAAS,iBAAiB,OAAO,OAAO;CAExC,QAAQ,OAAO;CACf,UAAU,OAAO;CACjB,eAAe,OAAO;CACtB,SAAS,OAAO;AAClB"}
1
+ {"version":3,"file":"contentExposure.cjs","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,GAAG,CAAE,CAAC,CACzE,KAAK,GAAG;;;;;;;;;AAUb,MAAa,wBAAwB,YAOsB;CACzD,eAAe,OAAO;CACtB,SAAS,iBAAiB,OAAO,OAAO;CAExC,QAAQ,OAAO;CACf,UAAU,OAAO;CACjB,eAAe,OAAO;CACtB,SAAS,OAAO;AAClB"}
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
3
2
  //#region src/utils/hash.ts
4
3
  /**
5
4
  * FNV-1a 32-bit string hash. Small, fast, dependency-free, and stable across
@@ -1 +1 @@
1
- {"version":3,"file":"hash.cjs","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;CAEX,KAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,QAAQ,SAAS;EACjD,QAAQ,MAAM,WAAW,KAAK;EAE9B,OAAO,KAAK,KAAK,MAAM,QAAU;CACnC;CAGA,OAAO,SAAS;AAClB"}
1
+ {"version":3,"file":"hash.cjs","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;CAEX,KAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,QAAQ,SAAS;EACjD,QAAQ,MAAM,WAAW,KAAK;EAE9B,OAAO,KAAK,KAAK,MAAM,QAAU;CACnC;CAGA,OAAO,SAAS;AAClB"}
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
3
2
  //#region src/utils/idle.ts
4
3
  /**
5
4
  * Runs a callback when the browser is idle, without blocking first render.
@@ -1 +1 @@
1
- {"version":3,"file":"idle.cjs","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;CACpD,IAAI,OAAO,WAAW,aAAa;CAEnC,MAAM,cACJ,OAGA;CAEF,IAAI,OAAO,gBAAgB,YAAY;EACrC,kBAAkB,SAAS,CAAC;EAC5B;CACF;CAEA,WAAW,UAAU,CAAC;AACxB"}
1
+ {"version":3,"file":"idle.cjs","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;CACpD,IAAI,OAAO,WAAW,aAAa;CAEnC,MAAM,cACJ,OAGA;CAEF,IAAI,OAAO,gBAAgB,YAAY;EACrC,kBAAkB,SAAS,CAAC;EAC5B;CACF;CAEA,WAAW,UAAU,CAAC;AACxB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/analytics",
3
- "version": "9.3.0",
3
+ "version": "9.3.2",
4
4
  "private": false,
5
5
  "description": "Collects which Intlayer content is shown (page/locale + node-level) and powers content A/B testing. Optional, lazily-imported companion to @intlayer/editor.",
6
6
  "keywords": [
@@ -80,9 +80,9 @@
80
80
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
81
81
  },
82
82
  "dependencies": {
83
- "@intlayer/config": "9.3.0",
84
- "@intlayer/core": "9.3.0",
85
- "@intlayer/types": "9.3.0"
83
+ "@intlayer/config": "9.3.2",
84
+ "@intlayer/core": "9.3.2",
85
+ "@intlayer/types": "9.3.2"
86
86
  },
87
87
  "devDependencies": {
88
88
  "@types/node": "26.2.0",