stat18ion 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -18,29 +18,49 @@ import { init } from 'stat18ion';
18
18
 
19
19
  init({
20
20
  siteId: 'YOUR_SITE_ID',
21
- // Optional: defaults to Stat18ion SaaS endpoint
22
- // endpoint: 'https://api.your-domain.com/api/event',
23
- debug: false
21
+ debug: false, // Set to true to see logs in console
22
+ trackLocal: false // Set to true to send data from localhost/dev
24
23
  });
25
24
  ```
26
25
 
26
+ ### Configuration Options
27
+ | Option | Type | Default | Description |
28
+ | :--- | :--- | :--- | :--- |
29
+ | `siteId` | `string` | Required | Your unique Site UUID from the dashboard. |
30
+ | `endpoint` | `string` | SaaS URL | Your backend event endpoint. |
31
+ | `debug` | `boolean` | `false` | Enable console logging for events. |
32
+ | `trackLocal` | `boolean` | `false` | If false, data is never sent from `localhost`. |
33
+
27
34
  ### Next.js Integration
28
35
 
29
- In `app/layout.tsx`:
36
+ To keep your layout as a **Server Component** (for Metadata/SEO), create a small client-side component:
30
37
 
31
38
  ```tsx
39
+ // components/StatTracker.tsx
32
40
  'use client';
33
41
  import { useEffect } from 'react';
34
42
  import { init } from 'stat18ion';
35
43
 
36
- export default function RootLayout({ children }) {
44
+ export default function StatTracker() {
37
45
  useEffect(() => {
38
46
  init({ siteId: 'YOUR_UUID_HERE' });
39
47
  }, []);
48
+ return null;
49
+ }
50
+ ```
40
51
 
52
+ Then add it to your `app/layout.tsx`:
53
+
54
+ ```tsx
55
+ import StatTracker from './components/StatTracker';
56
+
57
+ export default function RootLayout({ children }) {
41
58
  return (
42
59
  <html lang="en">
43
- <body>{children}</body>
60
+ <body>
61
+ <StatTracker />
62
+ {children}
63
+ </body>
44
64
  </html>
45
65
  );
46
66
  }
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ type Config = {
2
2
  siteId: string;
3
3
  endpoint?: string;
4
4
  debug?: boolean;
5
+ trackLocal?: boolean;
5
6
  };
6
7
  export declare const init: (options: Config) => void;
7
8
  export declare const Analytics: () => null;
package/dist/index.js CHANGED
@@ -27,9 +27,12 @@ const sendEvent = (payload) => {
27
27
  }
28
28
  };
29
29
  const trackPageView = () => {
30
- // Ignore localhost by default to avoid pollution
31
30
  const isLocal = ['localhost', '127.0.0.1', '0.0.0.0'].includes(window.location.hostname);
32
- if (isLocal && !config.debug) {
31
+ // Safety check: Don't send data from local dev unless explicitly asked
32
+ if (isLocal && !config.trackLocal) {
33
+ if (config.debug) {
34
+ log('Skipping event sending on localhost. Use trackLocal: true to enable.');
35
+ }
33
36
  return;
34
37
  }
35
38
  const payload = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stat18ion",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Privacy-first, lightweight analytics tracker for the modern web.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",