@aman-sagar06077/zappa-analytics 0.1.0 → 0.1.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.
Files changed (3) hide show
  1. package/README.md +9 -1
  2. package/index.js +1 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -12,10 +12,16 @@ npm i @aman-sagar06077/zappa-analytics
12
12
  import { Analytics } from '@aman-sagar06077/zappa-analytics/next';
13
13
 
14
14
  export default function RootLayout({ children }: { children: React.ReactNode }) {
15
- return <html><body>{children}<Analytics projectId="YOUR_PROJECT_ID" writeKey="Zappa_YOUR_PROJECT_WRITE_KEY" /></body></html>;
15
+ return <html><body>{children}<Analytics
16
+ projectId={process.env.NEXT_PUBLIC_ZAPPA_PROJECT_ID!}
17
+ writeKey={process.env.NEXT_PUBLIC_ZAPPA_WRITE_KEY!}
18
+ endpoint={process.env.NEXT_PUBLIC_ZAPPA_ORIGIN + '/api/events'}
19
+ /></body></html>;
16
20
  }
17
21
  ```
18
22
 
23
+ Copy the project-specific `NEXT_PUBLIC_ZAPPA_PROJECT_ID`, `NEXT_PUBLIC_ZAPPA_WRITE_KEY`, and `NEXT_PUBLIC_ZAPPA_ORIGIN` values from Zappa's Installation setup into `.env.local` and your production hosting environment. These values are public browser configuration; the write key scopes events to one project and is not a secret.
24
+
19
25
  ## Any JavaScript site
20
26
 
21
27
  ```js
@@ -24,4 +30,6 @@ const analytics = init({ projectId: 'YOUR_PROJECT_ID', writeKey: 'Zappa_YOUR_PRO
24
30
  analytics.track('signup_completed', { plan: 1 });
25
31
  ```
26
32
 
33
+ The SDK defaults to Zappa's hosted collector at `https://www.zappa.in/api/events`. Override `endpoint` only when using a different collector.
34
+
27
35
  Only initialize analytics when your consent policy permits it. Pass `enabled={false}` to the Next.js component until consent is granted, then render it with `enabled` set to `true`. `init` fails closed without a valid write key. The package tracks initial navigation, History API push/replace, query-only changes and browser back/forward, suppressing duplicate pageviews. It shares a persistent first-party visitor and session hint across tabs; the collector assigns the authoritative session after 30 minutes of inactivity or at a UTC day boundary. Use `analytics.reset()` to start a fresh anonymous identity and `analytics.optOut()` to stop collection and clear identifiers. Events are sent in batches of up to 20 and retried on transient network failures.
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- const DEFAULT_ENDPOINT = 'https://Zappa-bice.vercel.app/api/events';
1
+ const DEFAULT_ENDPOINT = 'https://www.zappa.in/api/events';
2
2
  const VISITOR_KEY = 'Zappa_visitor';
3
3
  const SESSION_KEY = 'Zappa_session';
4
4
  const IDLE_MS = 30 * 60 * 1000;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aman-sagar06077/zappa-analytics",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Privacy-aware website analytics for Zappa projects.",
5
5
  "license": "MIT",
6
6
  "type": "module",