@productbet/tracker-core 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 +84 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# @productbet/tracker-core
|
|
2
|
+
|
|
3
|
+
Core behavioral analytics SDK for [ProductBet](https://productbet.io). Handles session recording, event tracking, user identification, and data ingestion.
|
|
4
|
+
|
|
5
|
+
> Most users should install **[@productbet/tracker-react](https://www.npmjs.com/package/@productbet/tracker-react)** or **[@productbet/tracker-next](https://www.npmjs.com/package/@productbet/tracker-next)** instead, which include this package automatically.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @productbet/tracker-core
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { ProductBetTracker } from "@productbet/tracker-core"
|
|
17
|
+
|
|
18
|
+
const tracker = ProductBetTracker.init("pb_live_xxxx", {
|
|
19
|
+
enableSessionRecording: true,
|
|
20
|
+
enableAutoTracking: true,
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
tracker.start()
|
|
24
|
+
|
|
25
|
+
// Identify a user
|
|
26
|
+
tracker.identify("user_123", { plan: "pro", company: "Acme" })
|
|
27
|
+
|
|
28
|
+
// Track a custom event
|
|
29
|
+
tracker.track("feature_used", { feature: "export", format: "csv" })
|
|
30
|
+
|
|
31
|
+
// Stop tracking
|
|
32
|
+
tracker.stop()
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Configuration
|
|
36
|
+
|
|
37
|
+
All options are optional.
|
|
38
|
+
|
|
39
|
+
| Option | Type | Default | Description |
|
|
40
|
+
|---|---|---|---|
|
|
41
|
+
| `ingestionUrl` | `string` | `"https://productbet.io/tracking"` | Ingestion endpoint URL |
|
|
42
|
+
| `enableSessionRecording` | `boolean` | `false` | Enable rrweb session replay |
|
|
43
|
+
| `enableAutoTracking` | `boolean` | `true` | Auto-track clicks, forms, navigation, scroll |
|
|
44
|
+
| `enableConsoleTracking` | `boolean` | `true` | Capture console errors and warnings |
|
|
45
|
+
| `enableNetworkTracking` | `boolean` | `true` | Capture failed network requests |
|
|
46
|
+
| `recordCanvas` | `boolean` | `false` | Include canvas elements in recordings |
|
|
47
|
+
| `maxQueueSize` | `number` | `1000` | Max events queued before flush |
|
|
48
|
+
| `flushIntervalMs` | `number` | `3000` | How often events are sent (ms) |
|
|
49
|
+
| `sessionTimeoutMs` | `number` | `1800000` | Session timeout (30 min default) |
|
|
50
|
+
| `debug` | `boolean` | `false` | Enable debug logging |
|
|
51
|
+
| `redaction` | `RedactionOptions` | `{ mode: "privacy-first" }` | PII redaction settings |
|
|
52
|
+
| `autoTrackingOptions` | `AutoTrackingOptions` | See below | Fine-tune auto-tracking |
|
|
53
|
+
|
|
54
|
+
### Auto-tracking options
|
|
55
|
+
|
|
56
|
+
| Option | Type | Default |
|
|
57
|
+
|---|---|---|
|
|
58
|
+
| `trackClicks` | `boolean` | `true` |
|
|
59
|
+
| `trackForms` | `boolean` | `true` |
|
|
60
|
+
| `trackNavigation` | `boolean` | `true` |
|
|
61
|
+
| `trackScrollDepth` | `boolean` | `true` |
|
|
62
|
+
| `detectRageClicks` | `boolean` | `true` |
|
|
63
|
+
| `detectDeadClicks` | `boolean` | `true` |
|
|
64
|
+
| `includeText` | `boolean` | `true` |
|
|
65
|
+
| `includeClasses` | `boolean` | `true` |
|
|
66
|
+
|
|
67
|
+
### Redaction
|
|
68
|
+
|
|
69
|
+
By default, the SDK runs in `privacy-first` mode where all text input values are redacted. Use `unredactFields` to allowlist specific fields:
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
ProductBetTracker.init("pb_live_xxxx", {
|
|
73
|
+
redaction: {
|
|
74
|
+
mode: "privacy-first",
|
|
75
|
+
unredactFields: ["search", "email"],
|
|
76
|
+
},
|
|
77
|
+
})
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Set `mode: "visibility-first"` to capture all field values by default.
|
|
81
|
+
|
|
82
|
+
## License
|
|
83
|
+
|
|
84
|
+
MIT
|
package/package.json
CHANGED