fimo-analytics 2.7.0-experimental.1 → 2.8.0-staging.11

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
@@ -8,13 +8,30 @@ that contains it; source presence is not evidence of publication. The package
8
8
  releases with the Fimo package group, but the standalone API has no dependency
9
9
  on the Fimo CLI or a hosting adapter.
10
10
 
11
- ## Connection
11
+ ## Install
12
12
 
13
13
  ```sh
14
14
  pnpm add fimo-analytics
15
15
  ```
16
16
 
17
- Configure the complete ingestion URL, including `/e/p`, for your project and
17
+ On a site Fimo hosts, framework components need no configuration: mount
18
+ `<Analytics />` once. They read the tenant API URL and the on/off flag that Fimo
19
+ hosting injects at build time. Fimo turns tracking on for published sites and off
20
+ for previews. Without the flag, as in local development, tracking is off and the
21
+ browser console says why.
22
+
23
+ | Framework | Flag |
24
+ | ------------------------------------------ | ----------------------------------- |
25
+ | Vite, React Router, Svelte, SvelteKit, Vue | `VITE_ENABLE_ANALYTICS` |
26
+ | Next.js | `NEXT_PUBLIC_FIMO_ENABLE_ANALYTICS` |
27
+ | Astro | `PUBLIC_FIMO_ENABLE_ANALYTICS` |
28
+ | Nuxt | `NUXT_PUBLIC_FIMO_ENABLE_ANALYTICS` |
29
+
30
+ Props override both: `endpoint` sends through a proxy, `enabled` is your own switch.
31
+
32
+ ## Core
33
+
34
+ The core has no build-time variables. Configure the complete ingestion URL, including `/e/p`, for your project and
18
35
  branch. Use the tenant API base URL supplied by your Fimo connection and append
19
36
  `/e/p`; do not substitute your site's public URL or guess a tenant hostname.
20
37
  An origin-relative endpoint such as `/analytics-proxy/e/p` requires a proxy you
@@ -38,8 +55,8 @@ network effects. Invalid active configuration throws before sending.
38
55
 
39
56
  ## Framework adapters
40
57
 
41
- Install only the peers for your framework. Every component accepts `endpoint`
42
- and `enabled`, renders no visible UI, and cleans up when removed. Put it in a
58
+ Install only the peers for your framework. Every component works without props,
59
+ accepts optional `endpoint` and `enabled` overrides, renders no visible UI, and cleans up when removed. Put it in a
43
60
  persistent application root. Generic React, Svelte and Vue observe browser
44
61
  history. Framework router adapters emit after committed navigation.
45
62
 
@@ -49,16 +66,14 @@ history. Framework router adapters emit after committed navigation.
49
66
  import { Analytics } from 'fimo-analytics/react';
50
67
  // React Router: import { Analytics } from 'fimo-analytics/react-router';
51
68
 
52
- <Analytics endpoint={endpoint} enabled={isProduction} />;
69
+ <Analytics />;
53
70
  ```
54
71
 
55
72
  The React Router component goes inside the router. It also accepts an optional
56
73
  `pageName`. It reads the router location, including virtual HashRouter paths.
57
74
 
58
- The upgraded `fimo-react-router` still exposes `Pageview({ routes })` and
59
- `FimoProviders` still mounts it. They retain `VITE_API_URL`,
60
- `VITE_ENABLE_ANALYTICS=true`, route-name matching and preview guards. No extra
61
- component is needed when that integration already tracks your application.
75
+ From 2.8.0, `fimo-react-router` no longer tracks from `FimoProviders`; mount
76
+ this component instead.
62
77
 
63
78
  ### Next.js App and Pages routers
64
79
 
@@ -67,7 +82,7 @@ import { Analytics } from 'fimo-analytics/next';
67
82
 
68
83
  // App Router: include this in app/layout.tsx, inside <body>.
69
84
  // Pages Router: include it in pages/_app.tsx beside <Component {...pageProps} />.
70
- <Analytics endpoint={endpoint} enabled={isProduction} />;
85
+ <Analytics />;
71
86
  ```
72
87
 
73
88
  The adapter owns the client boundary and Suspense boundary for static App
@@ -85,12 +100,11 @@ in the tested redirect journey.
85
100
  ```astro
86
101
  ---
87
102
  import Analytics from 'fimo-analytics/astro';
88
- const endpoint = 'https://YOUR-TENANT-API-HOST/e/p';
89
103
  ---
90
104
  <html>
91
105
  <body>
92
106
  <slot />
93
- <Analytics endpoint={endpoint} enabled={import.meta.env.PROD} />
107
+ <Analytics />
94
108
  </body>
95
109
  </html>
96
110
  ```
@@ -104,10 +118,9 @@ Ordinary documents and Astro ClientRouter navigation are supported.
104
118
  <script>
105
119
  import Analytics from 'fimo-analytics/svelte';
106
120
  // SvelteKit: import Analytics from 'fimo-analytics/sveltekit';
107
- const endpoint = 'https://YOUR-TENANT-API-HOST/e/p';
108
121
  </script>
109
122
 
110
- <Analytics {endpoint} enabled={import.meta.env.PROD} />
123
+ <Analytics />
111
124
  ```
112
125
 
113
126
  Use the root component, or `src/routes/+layout.svelte` in SvelteKit.
@@ -118,14 +131,13 @@ The SvelteKit adapter uses `afterNavigate` and does not emit during SSR.
118
131
  ```vue
119
132
  <script setup>
120
133
  import { Analytics } from 'fimo-analytics/vue';
121
- const endpoint = 'https://YOUR-TENANT-API-HOST/e/p';
122
134
  </script>
123
135
 
124
- <template><Analytics :endpoint="endpoint" /></template>
136
+ <template><Analytics /></template>
125
137
  ```
126
138
 
127
- For Vue Router, use the manual core in your root component instead of mounting
128
- the generic history component. Wait for the initial router navigation before
139
+ For Vue Router, use the manual core, with its explicit `endpoint`, in your root
140
+ component instead of mounting the generic history component. Wait for the initial router navigation before
129
141
  mounting the application, as in `await router.isReady()`.
130
142
 
131
143
  ```ts
@@ -161,10 +173,6 @@ pnpm add -D @nuxt/kit
161
173
  // nuxt.config.ts
162
174
  export default defineNuxtConfig({
163
175
  modules: ['fimo-analytics/nuxt'],
164
- analytics: {
165
- endpoint: 'https://YOUR-TENANT-API-HOST/e/p',
166
- enabled: process.env.NODE_ENV === 'production',
167
- },
168
176
  });
169
177
  ```
170
178
 
@@ -182,7 +190,8 @@ then reference that file. Keep the copied asset pinned to the installed package.
182
190
  ```
183
191
 
184
192
  This is a classic script, not a module script. It uses its own `data-endpoint`
185
- and the same core. Use `data-enabled="false"` for disabled builds. No CDN or
193
+ and the same core, and tracks only when `data-enabled="true"`. In a Vite site,
194
+ use `data-endpoint="%VITE_API_URL%/e/p"` and `data-enabled="%VITE_ENABLE_ANALYTICS%"`. No CDN or
186
195
  server-response injection is configured automatically.
187
196
 
188
197
  ## Manual navigation and lifetime
@@ -1,7 +1,13 @@
1
1
  ---
2
2
  import type { AnalyticsProps } from '../dist/index.js';
3
+ import { fimoOptions } from '../dist/internal.js';
3
4
  interface Props extends AnalyticsProps {}
4
- const { endpoint, enabled = true } = Astro.props;
5
+ // Fimo hosting provides these while the site builds.
6
+ const { endpoint, enabled } = fimoOptions(Astro.props, {
7
+ apiUrl: import.meta.env.PUBLIC_FIMO_API_URL,
8
+ enabled: import.meta.env.PUBLIC_FIMO_ENABLE_ANALYTICS,
9
+ flag: 'PUBLIC_FIMO_ENABLE_ANALYTICS',
10
+ });
5
11
  ---
6
12
  <fimo-analytics data-endpoint={endpoint} data-enabled={String(enabled)} hidden></fimo-analytics>
7
13
  <script>
@@ -1,9 +1,9 @@
1
1
  <script lang="ts">
2
2
  import { type AnalyticsProps } from '../dist/index.js';
3
- import { initOrWarn } from '../dist/internal.js';
4
- let { endpoint, enabled = true }: AnalyticsProps = $props();
3
+ import { fimoOptions, initOrWarn, viteEnv } from '../dist/internal.js';
4
+ let { endpoint, enabled }: AnalyticsProps = $props();
5
5
  $effect(() => {
6
- const tracker = initOrWarn({ endpoint, enabled });
6
+ const tracker = initOrWarn(fimoOptions({ endpoint, enabled }, viteEnv()));
7
7
  return () => tracker.destroy();
8
8
  });
9
9
  </script>
@@ -2,10 +2,10 @@
2
2
  import { page } from '$app/state';
3
3
 
4
4
  import { type AnalyticsProps } from '../dist/index.js';
5
- import { initOrWarn } from '../dist/internal.js';
6
- let { endpoint, enabled = true }: AnalyticsProps = $props();
5
+ import { fimoOptions, initOrWarn, viteEnv } from '../dist/internal.js';
6
+ let { endpoint, enabled }: AnalyticsProps = $props();
7
7
  $effect(() => {
8
- const tracker = initOrWarn({ endpoint, enabled, routing: 'manual' });
8
+ const tracker = initOrWarn({ ...fimoOptions({ endpoint, enabled }, viteEnv()), routing: 'manual' });
9
9
  $effect(() => {
10
10
  // FIMO-2558: Shallow back/forward updates page.url without running afterNavigate.
11
11
  const url = page.url;
package/dist/browser.js CHANGED
@@ -1 +1 @@
1
- "use strict";(()=>{var g=Symbol.for("fimo.analytics.registry.v1"),m=()=>({pageview(){},destroy(){}}),P=()=>window.location.pathname+window.location.search,S=()=>new URLSearchParams(window.location.search).has("bl_preview_token");function b(t){if(typeof t!="string"||!t||t.trim()!==t||/[\\\s]/.test(t)||!(t.startsWith("/")&&!t.startsWith("//")||/^https?:\/\//i.test(t)))throw new TypeError("fimo-analytics requires an HTTP(S) endpoint or an origin-relative URL");let n=new URL(t,window.location.origin);if(!/^https?:$/.test(n.protocol)||n.username||n.password||n.hash)throw new TypeError("fimo-analytics endpoint must not contain credentials or a fragment");return n.href}var p={p:2048,n:512,r:2048,u:1024},w=(t,n)=>{if(t.length<=n)return t;let s=t.slice(0,n),a=s.charCodeAt(n-1);return a>=55296&&a<=56319?s.slice(0,-1):s},A=t=>t.length>=8&&t.length<=128;function y(t,n){let s;try{s=window[t];let e=s.getItem(n);if(e&&A(e))return e}catch{}let a=window.crypto?.randomUUID?.()??`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`;try{s?.setItem(n,a)}catch{}return a}function E(t){let n=!0,s=()=>{if(n)for(let i of t.destinations.values())i.routing==="history"&&i.handles.values().next().value?.pageview()},a=["pushState","replaceState"].map(i=>{let o=window.history[i],r=function(...c){let d=o.apply(this,c);return s(),d};return window.history[i]=r,()=>{window.history[i]===r&&(window.history[i]=o)}}),e=i=>{if(i.persisted)for(let o of t.destinations.values()){let r=o.handles.values().next().value;!r||!o.lastPage||(o.lastPath=void 0,r.pageview(o.routing==="manual"?o.lastPage:void 0))}};return window.addEventListener("popstate",s),window.addEventListener("pageshow",e),()=>{n=!1,a.forEach(i=>i()),window.removeEventListener("popstate",s),window.removeEventListener("pageshow",e)}}function v(t){if(typeof window>"u"||typeof document>"u"||t.enabled===!1)return m();let n=b(t.endpoint),s=t.routing??"history";if(s!=="history"&&s!=="manual")throw new TypeError("Invalid analytics routing mode");let a=window,e=a[g]??(a[g]={destinations:new Map}),i=e.destinations.get(n);if(i?.handles.size&&i.routing!==s)throw new TypeError("Conflicting active analytics routing modes for the same endpoint");i||(i={routing:s,handles:new Set},e.destinations.set(n,i)),i.routing=s;let o=i,r=!1,c={pageview(d={}){if(r||S())return;let l=w((d.path??P()).split("#")[0]||"/",p.p);if(o.lastPath===l)return;let h=d.pageName??(l.split("?")[0].replace(/\/+$/,"")||"/");o.lastPath=l,o.lastPage={path:l,pageName:h},e.visitor??(e.visitor=y("localStorage","fimo.analytics.visitor-id")),e.session??(e.session=y("sessionStorage","fimo.analytics.session-id"));let u=new URLSearchParams({p:l,n:w(h,p.n),v:e.visitor,s:e.session});document.referrer&&u.set("r",w(document.referrer,p.r)),window.navigator.userAgent&&u.set("u",w(window.navigator.userAgent,p.u));try{window.fetch(n,{method:"POST",body:u,keepalive:!0,mode:"cors",credentials:"omit"}).catch(()=>{})}catch{}},destroy(){r||(r=!0,o.handles.delete(c),[...e.destinations.values()].some(d=>d.handles.size)||(e.stop?.(),e.stop=void 0))}};return o.handles.add(c),e.stop??(e.stop=E(e)),s==="history"&&c.pageview(),c}var f=document.currentScript;if(f)try{v({endpoint:f.dataset.endpoint,enabled:f.dataset.enabled!=="false"})}catch(t){console.warn("[fimo-analytics]",t)}})();
1
+ "use strict";(()=>{var g=Symbol.for("fimo.analytics.registry.v1"),m=()=>({pageview(){},destroy(){}}),P=()=>window.location.pathname+window.location.search,S=()=>new URLSearchParams(window.location.search).has("bl_preview_token");function b(t){if(typeof t!="string"||!t||t.trim()!==t||/[\\\s]/.test(t)||!(t.startsWith("/")&&!t.startsWith("//")||/^https?:\/\//i.test(t)))throw new TypeError("fimo-analytics requires an HTTP(S) endpoint or an origin-relative URL");let n=new URL(t,window.location.origin);if(!/^https?:$/.test(n.protocol)||n.username||n.password||n.hash)throw new TypeError("fimo-analytics endpoint must not contain credentials or a fragment");return n.href}var p={p:2048,n:512,r:2048,u:1024},u=(t,n)=>{if(t.length<=n)return t;let s=t.slice(0,n),a=s.charCodeAt(n-1);return a>=55296&&a<=56319?s.slice(0,-1):s},A=t=>t.length>=8&&t.length<=128;function y(t,n){let s;try{s=window[t];let e=s.getItem(n);if(e&&A(e))return e}catch{}let a=window.crypto?.randomUUID?.()??`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`;try{s?.setItem(n,a)}catch{}return a}function E(t){let n=!0,s=()=>{if(n)for(let i of t.destinations.values())i.routing==="history"&&i.handles.values().next().value?.pageview()},a=["pushState","replaceState"].map(i=>{let o=window.history[i],r=function(...c){let d=o.apply(this,c);return s(),d};return window.history[i]=r,()=>{window.history[i]===r&&(window.history[i]=o)}}),e=i=>{if(i.persisted)for(let o of t.destinations.values()){let r=o.handles.values().next().value;!r||!o.lastPage||(o.lastPath=void 0,r.pageview(o.routing==="manual"?o.lastPage:void 0))}};return window.addEventListener("popstate",s),window.addEventListener("pageshow",e),()=>{n=!1,a.forEach(i=>i()),window.removeEventListener("popstate",s),window.removeEventListener("pageshow",e)}}function v(t){if(typeof window>"u"||typeof document>"u"||t.enabled===!1)return m();let n=b(t.endpoint),s=t.routing??"history";if(s!=="history"&&s!=="manual")throw new TypeError("Invalid analytics routing mode");let a=window,e=a[g]??(a[g]={destinations:new Map}),i=e.destinations.get(n);if(i?.handles.size&&i.routing!==s)throw new TypeError("Conflicting active analytics routing modes for the same endpoint");i||(i={routing:s,handles:new Set},e.destinations.set(n,i)),i.routing=s;let o=i,r=!1,c={pageview(d={}){if(r||S())return;let l=u((d.path??P()).split("#")[0]||"/",p.p);if(o.lastPath===l)return;let h=d.pageName??(l.split("?")[0].replace(/\/+$/,"")||"/");o.lastPath=l,o.lastPage={path:l,pageName:h},e.visitor??(e.visitor=y("localStorage","fimo.analytics.visitor-id")),e.session??(e.session=y("sessionStorage","fimo.analytics.session-id"));let w=new URLSearchParams({p:l,n:u(h,p.n),v:e.visitor,s:e.session});document.referrer&&w.set("r",u(document.referrer,p.r)),window.navigator.userAgent&&w.set("u",u(window.navigator.userAgent,p.u));try{window.fetch(n,{method:"POST",body:w,keepalive:!0,mode:"cors",credentials:"omit"}).catch(()=>{})}catch{}},destroy(){r||(r=!0,o.handles.delete(c),[...e.destinations.values()].some(d=>d.handles.size)||(e.stop?.(),e.stop=void 0))}};return o.handles.add(c),e.stop??(e.stop=E(e)),s==="history"&&c.pageview(),c}var f=document.currentScript;if(f)try{v({endpoint:f.dataset.endpoint,enabled:f.dataset.enabled==="true"})}catch(t){console.warn("[fimo-analytics]",t)}})();
package/dist/index.d.ts CHANGED
@@ -4,7 +4,12 @@ export type AnalyticsOptions = {
4
4
  enabled?: boolean;
5
5
  routing?: 'history' | 'manual';
6
6
  };
7
- export type AnalyticsProps = Pick<AnalyticsOptions, 'endpoint' | 'enabled'>;
7
+ /**
8
+ * Framework components need no props on Fimo hosting: they read the tenant API
9
+ * URL and the on/off flag Fimo injects at build time. Props override them, for
10
+ * example to send through a same-origin proxy.
11
+ */
12
+ export type AnalyticsProps = Partial<Pick<AnalyticsOptions, 'endpoint' | 'enabled'>>;
8
13
  export type Pageview = {
9
14
  path?: string;
10
15
  pageName?: string;
@@ -1,4 +1,4 @@
1
- import { type Analytics, type AnalyticsOptions } from './index.js';
1
+ import { type Analytics, type AnalyticsOptions, type AnalyticsProps } from './index.js';
2
2
  /**
3
3
  * An adapter must never take its host application down. `init` throws on a
4
4
  * misconfigured endpoint — most often an unset environment variable
@@ -13,3 +13,20 @@ import { type Analytics, type AnalyticsOptions } from './index.js';
13
13
  * match it.
14
14
  */
15
15
  export declare function initOrWarn(options: AnalyticsOptions): Analytics;
16
+ /** What a framework exposes from the variables Fimo hosting injects. */
17
+ export type FimoEnv = {
18
+ apiUrl?: string;
19
+ enabled?: string;
20
+ flag: string;
21
+ };
22
+ /**
23
+ * Resolve component props against Fimo's hosting variables. Explicit props
24
+ * win. A missing flag means off, so development, previews and self-hosted
25
+ * copies never count visits; one console line says why.
26
+ */
27
+ export declare function fimoOptions(props: AnalyticsProps, env: FimoEnv): AnalyticsOptions;
28
+ /**
29
+ * Vite replaces these exact expressions at build time, in dependencies too.
30
+ * Other bundlers leave `import.meta.env` undefined, which reads as unset.
31
+ */
32
+ export declare function viteEnv(): FimoEnv;
package/dist/internal.js CHANGED
@@ -21,3 +21,37 @@ export function initOrWarn(options) {
21
21
  return { pageview() { }, destroy() { } };
22
22
  }
23
23
  }
24
+ let explained = false;
25
+ /**
26
+ * Resolve component props against Fimo's hosting variables. Explicit props
27
+ * win. A missing flag means off, so development, previews and self-hosted
28
+ * copies never count visits; one console line says why.
29
+ */
30
+ export function fimoOptions(props, env) {
31
+ const apiUrl = env.apiUrl?.replace(/\/+$/, '');
32
+ if (props.enabled === undefined && !env.enabled && !explained) {
33
+ explained = true;
34
+ console.info(`[fimo-analytics] Tracking is off: ${env.flag} is not set. Fimo hosting sets it for published sites; set it to "true" to track elsewhere.`);
35
+ }
36
+ return {
37
+ endpoint: props.endpoint ?? (apiUrl ? `${apiUrl}/e/p` : ''),
38
+ enabled: props.enabled ?? env.enabled === 'true',
39
+ };
40
+ }
41
+ /**
42
+ * Vite replaces these exact expressions at build time, in dependencies too.
43
+ * Other bundlers leave `import.meta.env` undefined, which reads as unset.
44
+ */
45
+ export function viteEnv() {
46
+ const flag = 'VITE_ENABLE_ANALYTICS';
47
+ try {
48
+ return {
49
+ apiUrl: import.meta.env.VITE_API_URL,
50
+ enabled: import.meta.env.VITE_ENABLE_ANALYTICS,
51
+ flag,
52
+ };
53
+ }
54
+ catch {
55
+ return { flag };
56
+ }
57
+ }
package/dist/next.js CHANGED
@@ -3,7 +3,21 @@ import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { useRouter } from 'next/compat/router.js';
4
4
  import { usePathname, useSearchParams } from 'next/navigation.js';
5
5
  import { Suspense, useEffect } from 'react';
6
- import { initOrWarn } from './internal.js';
6
+ import { fimoOptions, initOrWarn } from './internal.js';
7
+ /** Next inlines these exact expressions into client bundles, in dependencies too. */
8
+ function nextEnv() {
9
+ const flag = 'NEXT_PUBLIC_FIMO_ENABLE_ANALYTICS';
10
+ try {
11
+ return {
12
+ apiUrl: process.env.NEXT_PUBLIC_FIMO_API_URL,
13
+ enabled: process.env.NEXT_PUBLIC_FIMO_ENABLE_ANALYTICS,
14
+ flag,
15
+ };
16
+ }
17
+ catch {
18
+ return { flag };
19
+ }
20
+ }
7
21
  function AppAnalytics({ endpoint, enabled }) {
8
22
  const pathname = usePathname();
9
23
  const search = useSearchParams();
@@ -11,7 +25,7 @@ function AppAnalytics({ endpoint, enabled }) {
11
25
  useEffect(() => {
12
26
  if (pathname === null)
13
27
  return;
14
- const tracker = initOrWarn({ endpoint, enabled, routing: 'manual' });
28
+ const tracker = initOrWarn({ ...fimoOptions({ endpoint, enabled }, nextEnv()), routing: 'manual' });
15
29
  // Read the committed browser URL to retain its original query encoding and base path.
16
30
  tracker.pageview();
17
31
  return () => tracker.destroy();
@@ -25,7 +39,7 @@ export function Analytics({ endpoint, enabled }) {
25
39
  useEffect(() => {
26
40
  if (!ready || !events)
27
41
  return;
28
- const tracker = initOrWarn({ endpoint, enabled, routing: 'manual' });
42
+ const tracker = initOrWarn({ ...fimoOptions({ endpoint, enabled }, nextEnv()), routing: 'manual' });
29
43
  const committed = () => tracker.pageview();
30
44
  committed();
31
45
  events.on('routeChangeComplete', committed);
package/dist/nuxt.js CHANGED
@@ -1,9 +1,14 @@
1
1
  import { addPlugin, createResolver, defineNuxtModule } from '@nuxt/kit';
2
+ import { fimoOptions } from './internal.js';
2
3
  const analytics = defineNuxtModule({
3
4
  meta: { name: 'fimo-analytics', configKey: 'analytics' },
4
- defaults: { endpoint: '', enabled: true },
5
5
  setup(options, nuxt) {
6
- nuxt.options.runtimeConfig.public.fimoAnalytics = options;
6
+ // Fimo hosting provides these while the site builds.
7
+ nuxt.options.runtimeConfig.public.fimoAnalytics = fimoOptions(options, {
8
+ apiUrl: process.env.NUXT_PUBLIC_FIMO_API_URL,
9
+ enabled: process.env.NUXT_PUBLIC_FIMO_ENABLE_ANALYTICS,
10
+ flag: 'NUXT_PUBLIC_FIMO_ENABLE_ANALYTICS',
11
+ });
7
12
  addPlugin({ src: createResolver(import.meta.url).resolve('./nuxt-plugin.mjs'), mode: 'client' });
8
13
  },
9
14
  });
@@ -1,11 +1,11 @@
1
1
  'use client';
2
2
  import { useEffect } from 'react';
3
3
  import { useLocation } from 'react-router';
4
- import { initOrWarn } from './internal.js';
4
+ import { fimoOptions, initOrWarn, viteEnv } from './internal.js';
5
5
  export function Analytics({ endpoint, enabled, pageName }) {
6
6
  const { pathname, search } = useLocation();
7
7
  useEffect(() => {
8
- const tracker = initOrWarn({ endpoint, enabled, routing: 'manual' });
8
+ const tracker = initOrWarn({ ...fimoOptions({ endpoint, enabled }, viteEnv()), routing: 'manual' });
9
9
  tracker.pageview({ path: pathname + search, pageName });
10
10
  return () => tracker.destroy();
11
11
  }, [endpoint, enabled, pathname, search, pageName]);
package/dist/react.js CHANGED
@@ -1,9 +1,9 @@
1
1
  'use client';
2
2
  import { useEffect } from 'react';
3
- import { initOrWarn } from './internal.js';
3
+ import { fimoOptions, initOrWarn, viteEnv } from './internal.js';
4
4
  export function Analytics({ endpoint, enabled }) {
5
5
  useEffect(() => {
6
- const tracker = initOrWarn({ endpoint, enabled });
6
+ const tracker = initOrWarn(fimoOptions({ endpoint, enabled }, viteEnv()));
7
7
  return () => tracker.destroy();
8
8
  }, [endpoint, enabled]);
9
9
  return null;
package/dist/vue.d.ts CHANGED
@@ -1,21 +1,22 @@
1
1
  export declare const Analytics: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
2
2
  endpoint: {
3
3
  type: StringConstructor;
4
- required: true;
4
+ default: undefined;
5
5
  };
6
6
  enabled: {
7
7
  type: BooleanConstructor;
8
- default: boolean;
8
+ default: undefined;
9
9
  };
10
10
  }>, () => null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
11
11
  endpoint: {
12
12
  type: StringConstructor;
13
- required: true;
13
+ default: undefined;
14
14
  };
15
15
  enabled: {
16
16
  type: BooleanConstructor;
17
- default: boolean;
17
+ default: undefined;
18
18
  };
19
19
  }>> & Readonly<{}>, {
20
+ endpoint: string;
20
21
  enabled: boolean;
21
22
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
package/dist/vue.js CHANGED
@@ -1,15 +1,15 @@
1
1
  import { defineComponent, onMounted, onUnmounted, watch } from 'vue';
2
- import { initOrWarn } from './internal.js';
2
+ import { fimoOptions, initOrWarn, viteEnv } from './internal.js';
3
3
  export const Analytics = defineComponent({
4
4
  name: 'FimoAnalytics',
5
- props: { endpoint: { type: String, required: true }, enabled: { type: Boolean, default: true } },
5
+ props: { endpoint: { type: String, default: undefined }, enabled: { type: Boolean, default: undefined } },
6
6
  setup(props) {
7
7
  let tracker;
8
8
  let stop;
9
9
  onMounted(() => {
10
10
  stop = watch(() => [props.endpoint, props.enabled], () => {
11
11
  tracker?.destroy();
12
- tracker = initOrWarn({ endpoint: props.endpoint, enabled: props.enabled });
12
+ tracker = initOrWarn(fimoOptions({ endpoint: props.endpoint, enabled: props.enabled }, viteEnv()));
13
13
  }, { immediate: true });
14
14
  });
15
15
  onUnmounted(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fimo-analytics",
3
- "version": "2.7.0-experimental.1",
3
+ "version": "2.8.0-staging.11",
4
4
  "description": "Framework-independent Fimo pageview analytics with optional framework adapters.",
5
5
  "files": [
6
6
  "dist/",
@@ -68,9 +68,9 @@
68
68
  "@nuxt/schema": "4.5.2",
69
69
  "@types/react": "19.2.14",
70
70
  "esbuild": "^0.25.10",
71
- "next": "16.3.3",
71
+ "next": "16.3.8",
72
72
  "react": "19.2.4",
73
- "react-router": "7.18.2",
73
+ "react-router": "7.18.4",
74
74
  "typescript": "7.0.2",
75
75
  "vue": "3.5.42"
76
76
  },