@webticks/react 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.
Files changed (3) hide show
  1. package/README.md +61 -0
  2. package/index.jsx +3 -3
  3. package/package.json +5 -2
package/README.md ADDED
@@ -0,0 +1,61 @@
1
+ # @webticks/react
2
+
3
+ React integration for WebTicks analytics.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @webticks/react
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ Add the component to your app's root with explicit configuration:
14
+
15
+ ```jsx
16
+ import WebticksAnalytics from '@webticks/react';
17
+
18
+ function App() {
19
+ return (
20
+ <>
21
+ <WebticksAnalytics
22
+ backendUrl="https://your-api.com/track"
23
+ appId="your-app-id"
24
+ />
25
+ {/* Your app */}
26
+ </>
27
+ );
28
+ }
29
+ ```
30
+
31
+ ## Best Practices: Environment Variables
32
+
33
+ For security and flexibility, it is **highly recommended** to source your configuration from environment variables rather than hardcoding them in your source code.
34
+
35
+ ```jsx
36
+ // Example using Vite
37
+ <WebticksAnalytics
38
+ backendUrl={import.meta.env.VITE_WEBTICKS_BACKEND_URL}
39
+ appId={import.meta.env.VITE_WEBTICKS_APP_ID}
40
+ />
41
+
42
+ // Example using Create React App
43
+ <WebticksAnalytics
44
+ backendUrl={process.env.REACT_APP_WEBTICKS_BACKEND_URL}
45
+ appId={process.env.REACT_APP_WEBTICKS_APP_ID}
46
+ />
47
+ ```
48
+
49
+ ## Props
50
+
51
+ | Prop | Type | Description |
52
+ |------|------|-------------|
53
+ | `backendUrl` | `string` | Recommended. URL to send analytics. Defaults to `/api/track`. |
54
+ | `appId` | `string` | Required. Your application ID. |
55
+
56
+ > [!NOTE]
57
+ > `appId` and `backendUrl` are typically provided by the [webticks-api](https://github.com/Celerinc/webticks-api.git) project, which you can self-host. Alternatively, you can use any backend that implements the WebTicks ingestion API.
58
+
59
+ ## License
60
+
61
+ [MPL-2.0](https://github.com/Celerinc/webticks/blob/main/LICENSE)
package/index.jsx CHANGED
@@ -2,10 +2,10 @@
2
2
  import inject from '@webticks/core';
3
3
  import { useEffect } from 'react';
4
4
 
5
- function WebticksAnalytics() {
5
+ function WebticksAnalytics({ backendUrl, appId }) {
6
6
  useEffect(() => {
7
- inject();
8
- }, []);
7
+ inject({ backendUrl, appId });
8
+ }, [backendUrl, appId]);
9
9
  return null;
10
10
  }
11
11
 
package/package.json CHANGED
@@ -1,10 +1,13 @@
1
1
  {
2
2
  "name": "@webticks/react",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "React integration for WebTicks analytics",
5
5
  "main": "index.jsx",
6
6
  "module": "index.jsx",
7
7
  "type": "module",
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
8
11
  "keywords": [
9
12
  "analytics",
10
13
  "tracking",
@@ -26,6 +29,6 @@
26
29
  "react": ">=16.8.0"
27
30
  },
28
31
  "dependencies": {
29
- "@webticks/core": "^0.1.0"
32
+ "@webticks/core": "^0.1.1"
30
33
  }
31
34
  }