@athena-tracker/tracker 1.0.1 → 1.2.0
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 +389 -163
- package/dist/events/capture-react-native.d.ts +77 -0
- package/dist/events/capture-react-native.d.ts.map +1 -0
- package/dist/index.d.ts +13 -106
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +1207 -146
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1223 -154
- package/dist/index.js.map +1 -1
- package/dist/inference/auto-detect.d.ts +21 -0
- package/dist/inference/auto-detect.d.ts.map +1 -0
- package/dist/inference/on-device.d.ts +36 -0
- package/dist/inference/on-device.d.ts.map +1 -0
- package/dist/inference/server.d.ts +30 -0
- package/dist/inference/server.d.ts.map +1 -0
- package/dist/react-native/ForcedReloadWrapper.d.ts +26 -0
- package/dist/react-native/ForcedReloadWrapper.d.ts.map +1 -0
- package/dist/tracker.d.ts +82 -0
- package/dist/tracker.d.ts.map +1 -0
- package/dist/types/index.d.ts +105 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/utils/webhook.d.ts +80 -0
- package/dist/utils/webhook.d.ts.map +1 -0
- package/package.json +58 -14
package/README.md
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
# @athena-tracker/tracker
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> Behavioral analytics tracker with edge AI for React Native and Web
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@athena-tracker/tracker)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- ✅ **90+ Behavioral Event Types** - Auto-captured touch, navigation, lifecycle events
|
|
11
|
+
- ✅ **Dual-Mode ML Inference** - On-device (ONNX) or server-side (auto-fallback)
|
|
12
|
+
- ✅ **Purchase Intent Prediction** - Real-time predictions for e-commerce (0.0-1.0)
|
|
13
|
+
- ✅ **5 User Archetypes** - Fast Mover, On Track, Slow Adopter, At Risk, Different Path
|
|
14
|
+
- ✅ **Cross-Platform** - Works on Web, iOS, Android (React Native)
|
|
15
|
+
- ✅ **Privacy-First** - Optional on-device inference (data never leaves device)
|
|
16
|
+
- ✅ **Zero Config** - Smart auto-detection of best inference mode
|
|
17
|
+
- ✅ **TypeScript Support** - Full type definitions included
|
|
4
18
|
|
|
5
19
|
## Installation
|
|
6
20
|
|
|
@@ -8,236 +22,448 @@ ATHENA Analytics tracker SDK wrapper for easy integration
|
|
|
8
22
|
npm install @athena-tracker/tracker
|
|
9
23
|
```
|
|
10
24
|
|
|
11
|
-
|
|
25
|
+
### For React Native with On-Device Inference
|
|
12
26
|
|
|
13
|
-
|
|
27
|
+
```bash
|
|
28
|
+
npm install @athena-tracker/tracker onnxruntime-react-native
|
|
29
|
+
```
|
|
14
30
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
### For OTA Updates (Server-Side Inference)
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm install @athena-tracker/tracker
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
(No `onnxruntime-react-native` required - will automatically fall back to server-side inference)
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## ⚠️ Getting Credentials (Required Before Installation)
|
|
42
|
+
|
|
43
|
+
**Before you can use this package, you need an `appToken` from Pascal.**
|
|
44
|
+
|
|
45
|
+
### For B2B Platform Partners (App Generators like Anything.com, Bubble.io)
|
|
46
|
+
|
|
47
|
+
If you're building a platform that generates apps for customers:
|
|
48
|
+
|
|
49
|
+
1. **Contact Pascal** to get partner credentials:
|
|
50
|
+
- Email: partnerships@pascal.cx
|
|
51
|
+
- Request: ATHENA B2B partner workspace
|
|
52
|
+
|
|
53
|
+
2. **Receive credentials**:
|
|
54
|
+
- Workspace ID: `ws_your_company_com`
|
|
55
|
+
- JWT Token: `eyJhbGc...` (perpetual token)
|
|
56
|
+
|
|
57
|
+
3. **Provision apps via API**:
|
|
58
|
+
|
|
59
|
+
```javascript
|
|
60
|
+
// Your backend code
|
|
61
|
+
const axios = require('axios');
|
|
62
|
+
|
|
63
|
+
async function provisionApp(appDetails) {
|
|
64
|
+
const response = await axios.post(
|
|
65
|
+
'https://tracker.pascal.cx/api/athena/provision',
|
|
66
|
+
{
|
|
67
|
+
workspaceId: process.env.ATHENA_WORKSPACE_ID,
|
|
68
|
+
appId: appDetails.id,
|
|
69
|
+
appName: appDetails.name,
|
|
70
|
+
platform: ['web', 'ios', 'android']
|
|
33
71
|
},
|
|
72
|
+
{
|
|
73
|
+
headers: {
|
|
74
|
+
'Authorization': `Bearer ${process.env.ATHENA_WORKSPACE_JWT}`,
|
|
75
|
+
'Content-Type': 'application/json'
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
const { appToken } = response.data;
|
|
81
|
+
|
|
82
|
+
// Store appToken in your database
|
|
83
|
+
await db.apps.update({
|
|
84
|
+
id: appDetails.id,
|
|
85
|
+
athena_app_token: appToken
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
return appToken;
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
4. **Inject token into generated apps** (see Quick Start below)
|
|
93
|
+
|
|
94
|
+
### For Agencies/Merchants (Website Integration)
|
|
95
|
+
|
|
96
|
+
If you're integrating tracking for merchant websites:
|
|
97
|
+
|
|
98
|
+
1. **Contact Pascal** for a partner API key:
|
|
99
|
+
- Email: partnerships@pascal.cx
|
|
100
|
+
- Request: Partner merchant provisioning
|
|
101
|
+
|
|
102
|
+
2. **Provision merchants via API**:
|
|
103
|
+
|
|
104
|
+
```javascript
|
|
105
|
+
const response = await axios.post(
|
|
106
|
+
'https://tracker.pascal.cx/api/partners/YOUR_PARTNER_NAME/merchants',
|
|
107
|
+
{
|
|
108
|
+
merchant_id: 'merchant_001',
|
|
109
|
+
merchant_email: 'owner@merchant.com',
|
|
110
|
+
webhook_url: 'https://your-platform.com/webhooks/pascal'
|
|
34
111
|
},
|
|
35
|
-
|
|
112
|
+
{
|
|
113
|
+
headers: {
|
|
114
|
+
'Authorization': `Bearer ${process.env.PASCAL_PARTNER_API_KEY}`,
|
|
115
|
+
'Content-Type': 'application/json'
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
);
|
|
36
119
|
|
|
37
|
-
//
|
|
38
|
-
|
|
120
|
+
const { api_key } = response.data; // This IS your appToken
|
|
121
|
+
```
|
|
39
122
|
|
|
40
|
-
|
|
41
|
-
identify('user-123', {
|
|
42
|
-
email: 'user@example.com',
|
|
43
|
-
name: 'John Doe',
|
|
44
|
-
plan: 'pro',
|
|
45
|
-
});
|
|
123
|
+
### Testing with Demo Token
|
|
46
124
|
|
|
47
|
-
|
|
48
|
-
track('button_clicked', {
|
|
49
|
-
buttonId: 'cta-signup',
|
|
50
|
-
location: 'homepage',
|
|
51
|
-
});
|
|
125
|
+
For testing purposes, you can use a demo token:
|
|
52
126
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
127
|
+
```javascript
|
|
128
|
+
// ⚠️ FOR TESTING ONLY - NOT FOR PRODUCTION
|
|
129
|
+
AthenaTracker.init({
|
|
130
|
+
appToken: 'at_demo_test_mode_no_predictions',
|
|
131
|
+
debug: true
|
|
56
132
|
});
|
|
57
133
|
```
|
|
58
134
|
|
|
59
|
-
|
|
135
|
+
**📖 Complete Guide**: See `PARTNER_INTEGRATION_GUIDE.md` for full details on both integration patterns.
|
|
60
136
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return <div>Your App</div>;
|
|
78
|
-
}
|
|
137
|
+
## Quick Start
|
|
138
|
+
|
|
139
|
+
### React Native
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
import AthenaTracker from '@athena-tracker/tracker';
|
|
143
|
+
|
|
144
|
+
// Initialize tracker
|
|
145
|
+
AthenaTracker.init({
|
|
146
|
+
appToken: 'at_live_xxxxx',
|
|
147
|
+
inferenceMode: 'auto', // Auto-detects environment
|
|
148
|
+
webhook: {
|
|
149
|
+
url: 'https://your-backend.com/webhooks/athena',
|
|
150
|
+
enabled: true
|
|
151
|
+
}
|
|
152
|
+
});
|
|
79
153
|
```
|
|
80
154
|
|
|
81
|
-
###
|
|
155
|
+
### Web
|
|
82
156
|
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const tracker = initTracker({
|
|
92
|
-
projectId: process.env.NEXT_PUBLIC_ATHENA_PROJECT_ID,
|
|
93
|
-
apiKey: process.env.NEXT_PUBLIC_ATHENA_API_KEY,
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
tracker.load();
|
|
157
|
+
```html
|
|
158
|
+
<script src="https://tracker.pascal.cx/v1/tracker.min.js"></script>
|
|
159
|
+
<script>
|
|
160
|
+
const tracker = new PascalTracker({
|
|
161
|
+
projectId: 'your-app-token',
|
|
162
|
+
edgeAI: {
|
|
163
|
+
enabled: true,
|
|
164
|
+
modelPath: 'https://tracker.pascal.cx/models/base_model_int8.onnx'
|
|
97
165
|
}
|
|
98
|
-
}
|
|
166
|
+
});
|
|
167
|
+
</script>
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Configuration
|
|
171
|
+
|
|
172
|
+
### AthenaConfig
|
|
99
173
|
|
|
100
|
-
|
|
174
|
+
```typescript
|
|
175
|
+
interface AthenaConfig {
|
|
176
|
+
appToken: string; // Required: App token from ATHENA provisioning
|
|
177
|
+
apiUrl?: string; // Optional: API base URL (default: https://tracker.pascal.cx)
|
|
178
|
+
inferenceMode?: 'auto' | 'on-device' | 'server'; // Optional: Inference mode
|
|
179
|
+
modelPath?: string; // Optional: ONNX model path (for on-device)
|
|
180
|
+
serverInferenceUrl?: string; // Optional: Server inference endpoint
|
|
181
|
+
webhook?: WebhookConfig; // Optional: Webhook configuration
|
|
182
|
+
batching?: BatchingConfig; // Optional: Event batching
|
|
183
|
+
debug?: boolean; // Optional: Debug mode
|
|
101
184
|
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Inference Modes
|
|
188
|
+
|
|
189
|
+
#### Auto Mode (Recommended)
|
|
102
190
|
|
|
103
|
-
|
|
191
|
+
Automatically detects whether `onnxruntime-react-native` is available:
|
|
192
|
+
|
|
193
|
+
```typescript
|
|
194
|
+
AthenaTracker.init({
|
|
195
|
+
appToken: 'at_live_xxxxx',
|
|
196
|
+
inferenceMode: 'auto' // Default
|
|
197
|
+
});
|
|
104
198
|
```
|
|
105
199
|
|
|
106
|
-
|
|
200
|
+
#### On-Device Mode (Forced)
|
|
107
201
|
|
|
108
|
-
|
|
109
|
-
// main.js
|
|
110
|
-
import { createApp } from 'vue';
|
|
111
|
-
import { initTracker } from '@athena-tracker/tracker';
|
|
112
|
-
import App from './App.vue';
|
|
202
|
+
Force on-device inference (requires `onnxruntime-react-native`):
|
|
113
203
|
|
|
114
|
-
|
|
204
|
+
```typescript
|
|
205
|
+
AthenaTracker.init({
|
|
206
|
+
appToken: 'at_live_xxxxx',
|
|
207
|
+
inferenceMode: 'on-device',
|
|
208
|
+
modelPath: '/path/to/model.onnx'
|
|
209
|
+
});
|
|
210
|
+
```
|
|
115
211
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
212
|
+
#### Server Mode (Forced)
|
|
213
|
+
|
|
214
|
+
Force server-side inference:
|
|
215
|
+
|
|
216
|
+
```typescript
|
|
217
|
+
AthenaTracker.init({
|
|
218
|
+
appToken: 'at_live_xxxxx',
|
|
219
|
+
inferenceMode: 'server',
|
|
220
|
+
// ⚠️ REQUIRED for predictions - this is a separate service from apiUrl
|
|
221
|
+
serverInferenceUrl: 'https://pascal-ml-api-cgn7rucynq-uc.a.run.app/v1/predict'
|
|
120
222
|
});
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
**⚠️ CRITICAL**: The `serverInferenceUrl` parameter is **REQUIRED** for ML predictions. This is a **separate service** from `apiUrl`:
|
|
226
|
+
- `apiUrl` (default: `https://tracker.pascal.cx`) - Handles event ingestion only
|
|
227
|
+
- `serverInferenceUrl` - Handles ML inference and predictions (separate Cloud Run service)
|
|
121
228
|
|
|
122
|
-
|
|
123
|
-
|
|
229
|
+
Without `serverInferenceUrl`, predictions will fail with HTTP 404 errors. See troubleshooting below for details.
|
|
230
|
+
|
|
231
|
+
## Webhook Integration
|
|
232
|
+
|
|
233
|
+
Receive real-time predictions via webhooks:
|
|
234
|
+
|
|
235
|
+
```typescript
|
|
236
|
+
AthenaTracker.init({
|
|
237
|
+
appToken: 'at_live_xxxxx',
|
|
238
|
+
webhook: {
|
|
239
|
+
url: 'https://your-backend.com/webhooks/athena',
|
|
240
|
+
enabled: true,
|
|
241
|
+
retry: {
|
|
242
|
+
maxAttempts: 3,
|
|
243
|
+
backoffMs: 1000
|
|
244
|
+
}
|
|
245
|
+
}
|
|
124
246
|
});
|
|
247
|
+
```
|
|
125
248
|
|
|
126
|
-
|
|
249
|
+
### Webhook Payload
|
|
250
|
+
|
|
251
|
+
```json
|
|
252
|
+
{
|
|
253
|
+
"user_id": "user_abc",
|
|
254
|
+
"session_id": "sess_123",
|
|
255
|
+
"predicted_class": "engaged_explorer",
|
|
256
|
+
"confidence": 0.85,
|
|
257
|
+
"archetype": "on_track",
|
|
258
|
+
"purchase_intent": 0.72,
|
|
259
|
+
"cart_abandonment_risk": 0.15,
|
|
260
|
+
"recommended_action": "Show 10% discount offer",
|
|
261
|
+
"urgency": "high",
|
|
262
|
+
"trigger_reason": "High-value cart ($249), 80% scroll depth, 45s time-on-page",
|
|
263
|
+
"timestamp": "2026-02-24T12:34:56Z"
|
|
264
|
+
}
|
|
127
265
|
```
|
|
128
266
|
|
|
129
|
-
##
|
|
267
|
+
## User Archetypes
|
|
130
268
|
|
|
131
|
-
|
|
269
|
+
| Archetype | Description | Similarity Score |
|
|
270
|
+
|-----------|-------------|------------------|
|
|
271
|
+
| **fast_mover** | High purchase intent, quick decision-maker | >85% |
|
|
272
|
+
| **on_track** | Steady browsing, likely to convert | 60-85% |
|
|
273
|
+
| **slow_adopter** | Needs guidance, price-sensitive | 40-60% |
|
|
274
|
+
| **at_risk** | Low engagement, high abandonment risk | <40% |
|
|
275
|
+
| **different_path** | Unconventional browsing pattern | Unique |
|
|
132
276
|
|
|
133
|
-
|
|
277
|
+
## API Reference
|
|
134
278
|
|
|
135
|
-
|
|
136
|
-
- `config.projectId` (required): Your ATHENA project ID
|
|
137
|
-
- `config.apiKey` (required): Your ATHENA API key
|
|
138
|
-
- `config.apiUrl` (optional): API endpoint URL (default: 'https://tracker.pascal.cx')
|
|
139
|
-
- `config.sampleRate` (optional): Session sampling rate 0.0-1.0 (default: 1.0)
|
|
140
|
-
- `config.recording` (optional): Recording configuration
|
|
141
|
-
- `enabled`: Enable session recording (default: true)
|
|
142
|
-
- `sampleRate`: Recording sampling rate 0.0-1.0 (default: 0.1)
|
|
143
|
-
- `maskAllInputs`: Mask all input fields (default: true)
|
|
144
|
-
- `maskInputOptions`: Specific input masking options
|
|
145
|
-
- `config.edgeAI` (optional): Edge AI configuration
|
|
146
|
-
- `enabled`: Enable client-side ML predictions (default: true)
|
|
147
|
-
- `modelPath`: Custom ONNX model path
|
|
148
|
-
- `webhook`: Webhook configuration
|
|
279
|
+
### AthenaTracker
|
|
149
280
|
|
|
150
|
-
|
|
281
|
+
```typescript
|
|
282
|
+
class AthenaTracker {
|
|
283
|
+
static init(config: AthenaConfig): Promise<void>
|
|
284
|
+
static identify(userId: string, traits?: Record<string, any>): void
|
|
285
|
+
static track(eventType: string, properties?: Record<string, any>): void
|
|
286
|
+
static getInferenceMode(): 'on-device' | 'server' | null
|
|
287
|
+
static getSessionId(): string | null
|
|
288
|
+
}
|
|
289
|
+
```
|
|
151
290
|
|
|
152
|
-
###
|
|
291
|
+
### Methods
|
|
153
292
|
|
|
154
|
-
|
|
293
|
+
#### `init(config)`
|
|
155
294
|
|
|
156
|
-
|
|
295
|
+
Initialize the tracker with configuration.
|
|
157
296
|
|
|
158
|
-
|
|
297
|
+
```typescript
|
|
298
|
+
await AthenaTracker.init({
|
|
299
|
+
appToken: 'at_live_xxxxx'
|
|
300
|
+
});
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
#### `identify(userId, traits?)`
|
|
159
304
|
|
|
160
|
-
Identify a user
|
|
305
|
+
Identify a user.
|
|
161
306
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
307
|
+
```typescript
|
|
308
|
+
AthenaTracker.identify('user_123', {
|
|
309
|
+
email: 'user@example.com',
|
|
310
|
+
name: 'John Doe'
|
|
311
|
+
});
|
|
312
|
+
```
|
|
165
313
|
|
|
166
|
-
|
|
314
|
+
#### `track(eventType, properties?)`
|
|
167
315
|
|
|
168
316
|
Track a custom event.
|
|
169
317
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
318
|
+
```typescript
|
|
319
|
+
AthenaTracker.track('button_click', {
|
|
320
|
+
button_id: 'checkout',
|
|
321
|
+
page: '/cart'
|
|
322
|
+
});
|
|
323
|
+
```
|
|
173
324
|
|
|
174
|
-
|
|
325
|
+
## React Native Components
|
|
175
326
|
|
|
176
|
-
|
|
327
|
+
### AthenaOTAWrapper
|
|
177
328
|
|
|
178
|
-
|
|
179
|
-
- `pageName`: Optional page name
|
|
180
|
-
- `properties`: Optional page properties
|
|
329
|
+
For apps using Expo OTA updates, wrap your app with `AthenaOTAWrapper`:
|
|
181
330
|
|
|
182
|
-
|
|
331
|
+
```tsx
|
|
332
|
+
import { AthenaOTAWrapper } from '@athena-tracker/tracker';
|
|
333
|
+
|
|
334
|
+
export default function App() {
|
|
335
|
+
return (
|
|
336
|
+
<AthenaOTAWrapper
|
|
337
|
+
loadingMessage="Loading..."
|
|
338
|
+
updateMessage="Updating..."
|
|
339
|
+
>
|
|
340
|
+
<YourApp />
|
|
341
|
+
</AthenaOTAWrapper>
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
```
|
|
183
345
|
|
|
184
|
-
|
|
346
|
+
**What it does:**
|
|
347
|
+
- Checks for OTA updates on app launch
|
|
348
|
+
- Fetches and applies updates automatically
|
|
349
|
+
- Forces immediate reload (<2 seconds)
|
|
350
|
+
- Displays loading spinner during update
|
|
185
351
|
|
|
186
|
-
|
|
352
|
+
**Props:**
|
|
353
|
+
- `loadingMessage` (string, optional): Message during initial load (default: "Loading...")
|
|
354
|
+
- `updateMessage` (string, optional): Message during update (default: "Updating...")
|
|
187
355
|
|
|
188
|
-
|
|
356
|
+
---
|
|
189
357
|
|
|
190
|
-
|
|
358
|
+
### ReactNativeEventCapture
|
|
191
359
|
|
|
192
|
-
|
|
360
|
+
Advanced event capture for custom use cases:
|
|
193
361
|
|
|
194
|
-
|
|
362
|
+
```tsx
|
|
363
|
+
import { ReactNativeEventCapture } from '@athena-tracker/tracker';
|
|
364
|
+
|
|
365
|
+
const capture = new ReactNativeEventCapture({
|
|
366
|
+
captureTouch: true,
|
|
367
|
+
captureNavigation: true,
|
|
368
|
+
captureLifecycle: true,
|
|
369
|
+
captureNetworkErrors: true,
|
|
370
|
+
batchSize: 10,
|
|
371
|
+
batchIntervalMs: 10000
|
|
372
|
+
});
|
|
195
373
|
|
|
196
|
-
|
|
374
|
+
// Start capturing
|
|
375
|
+
capture.start();
|
|
197
376
|
|
|
198
|
-
|
|
377
|
+
// Track screen view manually
|
|
378
|
+
capture.trackScreenView('ProductDetails', { productId: '123' });
|
|
199
379
|
|
|
200
|
-
|
|
380
|
+
// Track custom event
|
|
381
|
+
capture.track('AddToCart', { productId: '123', price: 49.99 });
|
|
201
382
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
enabled: true, // Enable recording
|
|
205
|
-
sampleRate: 0.1, // Record 10% of sessions
|
|
206
|
-
maskAllInputs: true, // Mask all input fields
|
|
207
|
-
maskInputOptions: {
|
|
208
|
-
password: true, // Mask password fields
|
|
209
|
-
email: true, // Mask email fields
|
|
210
|
-
},
|
|
211
|
-
compressionLevel: 6, // Compression level (1-9)
|
|
212
|
-
maxChunkSize: 102400, // Max chunk size in bytes
|
|
213
|
-
}
|
|
383
|
+
// Stop capturing
|
|
384
|
+
capture.stop();
|
|
214
385
|
```
|
|
215
386
|
|
|
216
|
-
|
|
387
|
+
**Configuration:**
|
|
388
|
+
- `captureTouch` (boolean): Capture touch events (Tap, Swipe, LongPress)
|
|
389
|
+
- `captureNavigation` (boolean): Capture screen navigation
|
|
390
|
+
- `captureLifecycle` (boolean): Capture app lifecycle (Open, Background, Foreground)
|
|
391
|
+
- `captureNetworkErrors` (boolean): Capture failed network requests
|
|
392
|
+
- `batchSize` (number): Events per batch (default: 10)
|
|
393
|
+
- `batchIntervalMs` (number): Batch interval in milliseconds (default: 10000)
|
|
394
|
+
|
|
395
|
+
**Captured Events:**
|
|
396
|
+
- `AppOpen`, `AppForeground`, `AppBackground`, `AppInactive`
|
|
397
|
+
- `Tap`, `Swipe`, `LongPress`
|
|
398
|
+
- `ScreenView`
|
|
399
|
+
- `NetworkError`
|
|
400
|
+
|
|
401
|
+
## Performance
|
|
402
|
+
|
|
403
|
+
- **Bundle size**: ~10MB (includes ONNX model for on-device mode)
|
|
404
|
+
- **On-device inference latency**: <10ms P95
|
|
405
|
+
- **Server-side inference latency**: <100ms P95
|
|
406
|
+
- **Memory overhead**: <50MB
|
|
407
|
+
- **Battery impact**: Negligible (<1%)
|
|
408
|
+
|
|
409
|
+
## Troubleshooting
|
|
410
|
+
|
|
411
|
+
### "Server inference failed: 404 Not Found" Error
|
|
412
|
+
|
|
413
|
+
**Symptom**: Predictions fail with 404 errors in console logs.
|
|
414
|
+
|
|
415
|
+
**Cause**: Missing or incorrect `serverInferenceUrl` configuration.
|
|
416
|
+
|
|
417
|
+
**Solution**: Explicitly set the `serverInferenceUrl` parameter:
|
|
217
418
|
|
|
218
419
|
```typescript
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
},
|
|
226
|
-
}
|
|
420
|
+
AthenaTracker.init({
|
|
421
|
+
appToken: 'at_live_xxxxx',
|
|
422
|
+
apiUrl: 'https://tracker.pascal.cx', // Event ingestion
|
|
423
|
+
serverInferenceUrl: 'https://pascal-ml-api-cgn7rucynq-uc.a.run.app/v1/predict', // ML inference
|
|
424
|
+
inferenceMode: 'server'
|
|
425
|
+
});
|
|
227
426
|
```
|
|
228
427
|
|
|
229
|
-
|
|
428
|
+
### Event Tracking Works But No Predictions
|
|
230
429
|
|
|
231
|
-
|
|
430
|
+
**Cause**: Event tracking and ML predictions use separate endpoints.
|
|
232
431
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
432
|
+
**Solution**: Verify `serverInferenceUrl` is set correctly. Test with:
|
|
433
|
+
|
|
434
|
+
```bash
|
|
435
|
+
curl -X POST https://pascal-ml-api-cgn7rucynq-uc.a.run.app/v1/predict \
|
|
436
|
+
-H "Content-Type: application/json" \
|
|
437
|
+
-d '{"app_token":"your_token","events":[...]}'
|
|
239
438
|
```
|
|
240
439
|
|
|
440
|
+
## What's New in v1.1.0
|
|
441
|
+
|
|
442
|
+
- ✅ **Updated ML inference endpoint** to latest production URL
|
|
443
|
+
- ✅ **70+ event types supported** via EVENT_MAPPING (cart_viewed, coupon_applied, etc.)
|
|
444
|
+
- ✅ **Enhanced documentation** with critical configuration requirements
|
|
445
|
+
- ✅ **React Native integration validated** with production test app
|
|
446
|
+
- ✅ **Improved error messages** for missing serverInferenceUrl
|
|
447
|
+
|
|
448
|
+
## Browser Support
|
|
449
|
+
|
|
450
|
+
- Chrome/Edge 90+
|
|
451
|
+
- Safari 14+
|
|
452
|
+
- Firefox 88+
|
|
453
|
+
- React Native 0.70+
|
|
454
|
+
|
|
241
455
|
## License
|
|
242
456
|
|
|
243
457
|
MIT
|
|
458
|
+
|
|
459
|
+
## Documentation
|
|
460
|
+
|
|
461
|
+
- Full documentation: https://docs.athena.ai/tracker
|
|
462
|
+
- Integration guide: See ATHENA_HANDOVER_DOCUMENTATION.md
|
|
463
|
+
- API reference: https://tracker.pascal.cx/docs
|
|
464
|
+
|
|
465
|
+
## Support
|
|
466
|
+
|
|
467
|
+
- Issues: https://github.com/RubaiyatF/Pascal/issues
|
|
468
|
+
- Email: support@pascal.cx
|
|
469
|
+
- Slack: #athena-integration (for partners)
|