stat18ion 0.0.2 → 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,30 +18,49 @@ import { init } from 'stat18ion';
18
18
 
19
19
  init({
20
20
  siteId: 'YOUR_SITE_ID',
21
- // Optional: defaults to production endpoint
22
- // endpoint: 'https://api.your-domain.com/api/event',
23
- // Optional: enable logs in console
24
- // 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
25
23
  });
26
24
  ```
27
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
+
28
34
  ### Next.js Integration
29
35
 
30
- In `app/layout.tsx`:
36
+ To keep your layout as a **Server Component** (for Metadata/SEO), create a small client-side component:
31
37
 
32
38
  ```tsx
39
+ // components/StatTracker.tsx
33
40
  'use client';
34
41
  import { useEffect } from 'react';
35
42
  import { init } from 'stat18ion';
36
43
 
37
- export default function RootLayout({ children }) {
44
+ export default function StatTracker() {
38
45
  useEffect(() => {
39
46
  init({ siteId: 'YOUR_UUID_HERE' });
40
47
  }, []);
48
+ return null;
49
+ }
50
+ ```
41
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 }) {
42
58
  return (
43
59
  <html lang="en">
44
- <body>{children}</body>
60
+ <body>
61
+ <StatTracker />
62
+ {children}
63
+ </body>
45
64
  </html>
46
65
  );
47
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
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Analytics = exports.init = void 0;
4
4
  let config = {
5
5
  siteId: '',
6
- endpoint: '', // Should be provided via init
6
+ endpoint: 'https://stats.hashboard.in/api/event', // SaaS default (Replace with your actual domain)
7
7
  };
8
8
  const log = (message, ...args) => {
9
9
  if (config.debug) {
@@ -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.0.2",
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",