trodo-node 1.0.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 +192 -0
- package/dist/cjs/TrodoClient.js +113 -0
- package/dist/cjs/TrodoClient.js.map +1 -0
- package/dist/cjs/UserContext.js +166 -0
- package/dist/cjs/UserContext.js.map +1 -0
- package/dist/cjs/api/ApiClient.js +144 -0
- package/dist/cjs/api/ApiClient.js.map +1 -0
- package/dist/cjs/api/endpoints.js +26 -0
- package/dist/cjs/api/endpoints.js.map +1 -0
- package/dist/cjs/auto/AutoEventManager.js +70 -0
- package/dist/cjs/auto/AutoEventManager.js.map +1 -0
- package/dist/cjs/index.js +141 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/managers/GroupManager.js +84 -0
- package/dist/cjs/managers/GroupManager.js.map +1 -0
- package/dist/cjs/managers/PeopleManager.js +75 -0
- package/dist/cjs/managers/PeopleManager.js.map +1 -0
- package/dist/cjs/queue/BatchFlusher.js +35 -0
- package/dist/cjs/queue/BatchFlusher.js.map +1 -0
- package/dist/cjs/queue/EventQueue.js +27 -0
- package/dist/cjs/queue/EventQueue.js.map +1 -0
- package/dist/cjs/session/ServerSession.js +113 -0
- package/dist/cjs/session/ServerSession.js.map +1 -0
- package/dist/cjs/session/SessionManager.js +54 -0
- package/dist/cjs/session/SessionManager.js.map +1 -0
- package/dist/cjs/types/index.js +6 -0
- package/dist/cjs/types/index.js.map +1 -0
- package/dist/esm/TrodoClient.d.ts +39 -0
- package/dist/esm/TrodoClient.d.ts.map +1 -0
- package/dist/esm/TrodoClient.js +109 -0
- package/dist/esm/TrodoClient.js.map +1 -0
- package/dist/esm/UserContext.d.ts +40 -0
- package/dist/esm/UserContext.d.ts.map +1 -0
- package/dist/esm/UserContext.js +162 -0
- package/dist/esm/UserContext.js.map +1 -0
- package/dist/esm/api/ApiClient.d.ts +40 -0
- package/dist/esm/api/ApiClient.d.ts.map +1 -0
- package/dist/esm/api/ApiClient.js +107 -0
- package/dist/esm/api/ApiClient.js.map +1 -0
- package/dist/esm/api/endpoints.d.ts +24 -0
- package/dist/esm/api/endpoints.d.ts.map +1 -0
- package/dist/esm/api/endpoints.js +23 -0
- package/dist/esm/api/endpoints.js.map +1 -0
- package/dist/esm/auto/AutoEventManager.d.ts +16 -0
- package/dist/esm/auto/AutoEventManager.d.ts.map +1 -0
- package/dist/esm/auto/AutoEventManager.js +66 -0
- package/dist/esm/auto/AutoEventManager.js.map +1 -0
- package/dist/esm/index.d.ts +81 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +108 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/managers/GroupManager.d.ts +14 -0
- package/dist/esm/managers/GroupManager.d.ts.map +1 -0
- package/dist/esm/managers/GroupManager.js +80 -0
- package/dist/esm/managers/GroupManager.js.map +1 -0
- package/dist/esm/managers/PeopleManager.d.ts +20 -0
- package/dist/esm/managers/PeopleManager.d.ts.map +1 -0
- package/dist/esm/managers/PeopleManager.js +71 -0
- package/dist/esm/managers/PeopleManager.js.map +1 -0
- package/dist/esm/queue/BatchFlusher.d.ts +13 -0
- package/dist/esm/queue/BatchFlusher.d.ts.map +1 -0
- package/dist/esm/queue/BatchFlusher.js +31 -0
- package/dist/esm/queue/BatchFlusher.js.map +1 -0
- package/dist/esm/queue/EventQueue.d.ts +14 -0
- package/dist/esm/queue/EventQueue.d.ts.map +1 -0
- package/dist/esm/queue/EventQueue.js +23 -0
- package/dist/esm/queue/EventQueue.js.map +1 -0
- package/dist/esm/session/ServerSession.d.ts +6 -0
- package/dist/esm/session/ServerSession.d.ts.map +1 -0
- package/dist/esm/session/ServerSession.js +74 -0
- package/dist/esm/session/ServerSession.js.map +1 -0
- package/dist/esm/session/SessionManager.d.ts +12 -0
- package/dist/esm/session/SessionManager.d.ts.map +1 -0
- package/dist/esm/session/SessionManager.js +50 -0
- package/dist/esm/session/SessionManager.js.map +1 -0
- package/dist/esm/types/index.d.ts +110 -0
- package/dist/esm/types/index.d.ts.map +1 -0
- package/dist/esm/types/index.js +5 -0
- package/dist/esm/types/index.js.map +1 -0
- package/package.json +71 -0
package/README.md
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# trodo-node
|
|
2
|
+
|
|
3
|
+
Server-side Node.js SDK for [Trodo Analytics](https://trodo.ai). Track backend events, identify users, and manage people/groups — all merging seamlessly with your frontend Trodo data under the same `siteId`.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install trodo-node
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Node 18+ uses native `fetch`. For Node 16/17, install the optional peer dependency:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install trodo-node node-fetch
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
```javascript
|
|
20
|
+
const trodo = require('trodo-node');
|
|
21
|
+
|
|
22
|
+
// Initialize once at app startup
|
|
23
|
+
trodo.init({
|
|
24
|
+
siteId: 'your-site-id',
|
|
25
|
+
debug: false, // optional: log API calls
|
|
26
|
+
autoEvents: true, // optional: capture uncaughtException / unhandledRejection
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// Get a user context
|
|
30
|
+
const user = trodo.forUser('user-123');
|
|
31
|
+
|
|
32
|
+
// Track a custom event
|
|
33
|
+
await user.track('purchase_completed', { amount: 99.99, plan: 'pro' });
|
|
34
|
+
|
|
35
|
+
// Identify the user (merges with frontend events under the same identity)
|
|
36
|
+
await user.identify('user@example.com'); // distinctId becomes id_user@example.com
|
|
37
|
+
|
|
38
|
+
// Update people profile
|
|
39
|
+
await user.people.set({ plan: 'pro', company: 'Acme' });
|
|
40
|
+
|
|
41
|
+
// Track a server-side error
|
|
42
|
+
await user.captureError(new Error('payment failed'));
|
|
43
|
+
|
|
44
|
+
// Flush queued events before process exit
|
|
45
|
+
await trodo.shutdown();
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## ESM
|
|
49
|
+
|
|
50
|
+
```javascript
|
|
51
|
+
import trodo from 'trodo-node';
|
|
52
|
+
trodo.init({ siteId: 'your-site-id' });
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Cross-SDK Identity Merging
|
|
56
|
+
|
|
57
|
+
Frontend and backend events merge when both sides call `identify()` with the same value:
|
|
58
|
+
|
|
59
|
+
```javascript
|
|
60
|
+
// Browser SDK
|
|
61
|
+
Trodo.identify('user@example.com'); // → id_user@example.com
|
|
62
|
+
|
|
63
|
+
// Node.js SDK (same value)
|
|
64
|
+
await user.identify('user@example.com'); // → id_user@example.com
|
|
65
|
+
|
|
66
|
+
// Both event streams now appear together in the Trodo dashboard
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## API Reference
|
|
70
|
+
|
|
71
|
+
### `trodo.init(config)`
|
|
72
|
+
|
|
73
|
+
| Option | Type | Default | Description |
|
|
74
|
+
|--------|------|---------|-------------|
|
|
75
|
+
| `siteId` | `string` | required | Your Trodo site ID |
|
|
76
|
+
| `apiBase` | `string` | `https://sdkapi.trodo.ai` | API base URL |
|
|
77
|
+
| `debug` | `boolean` | `false` | Log API requests/responses |
|
|
78
|
+
| `autoEvents` | `boolean` | `false` | Hook `uncaughtException` + `unhandledRejection` |
|
|
79
|
+
| `retries` | `number` | `3` | HTTP retry attempts on 5xx errors |
|
|
80
|
+
| `timeout` | `number` | `10000` | HTTP timeout in milliseconds |
|
|
81
|
+
| `batchEnabled` | `boolean` | `false` | Queue events and flush in bulk |
|
|
82
|
+
| `batchSize` | `number` | `50` | Max events per batch flush |
|
|
83
|
+
| `batchFlushIntervalMs` | `number` | `5000` | Flush interval in milliseconds |
|
|
84
|
+
| `onError` | `function` | `undefined` | Callback for SDK errors |
|
|
85
|
+
|
|
86
|
+
### `trodo.forUser(distinctId, options?)`
|
|
87
|
+
|
|
88
|
+
Returns a user-bound context. All subsequent calls use this user's session.
|
|
89
|
+
|
|
90
|
+
```javascript
|
|
91
|
+
const user = trodo.forUser('user-123', {
|
|
92
|
+
sessionId: req.cookies.trodo_session, // optional: correlate with browser session
|
|
93
|
+
});
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### User Context Methods
|
|
97
|
+
|
|
98
|
+
```javascript
|
|
99
|
+
await user.track(eventName, properties?) // Track custom event
|
|
100
|
+
await user.trackEvent(eventName, properties?) // Alias for track()
|
|
101
|
+
await user.identify(identifyId) // Merge identity
|
|
102
|
+
await user.walletAddress(address) // Set crypto wallet address
|
|
103
|
+
await user.reset() // Clear session context
|
|
104
|
+
await user.captureError(error) // Track server_error event
|
|
105
|
+
|
|
106
|
+
// People profile
|
|
107
|
+
await user.people.set(properties)
|
|
108
|
+
await user.people.setOnce(properties)
|
|
109
|
+
await user.people.unset(keys)
|
|
110
|
+
await user.people.increment(properties)
|
|
111
|
+
await user.people.append(properties)
|
|
112
|
+
await user.people.union(properties)
|
|
113
|
+
await user.people.remove(properties)
|
|
114
|
+
await user.people.trackCharge(amount, properties?)
|
|
115
|
+
await user.people.clearCharges()
|
|
116
|
+
await user.people.deleteUser()
|
|
117
|
+
|
|
118
|
+
// Groups
|
|
119
|
+
await user.set_group(groupKey, groupId)
|
|
120
|
+
await user.add_group(groupKey, groupId)
|
|
121
|
+
await user.remove_group(groupKey, groupId)
|
|
122
|
+
const group = user.get_group(groupKey, groupId)
|
|
123
|
+
await group.set(properties)
|
|
124
|
+
await group.set_once(properties)
|
|
125
|
+
await group.union(properties)
|
|
126
|
+
await group.remove(properties)
|
|
127
|
+
await group.unset(keys)
|
|
128
|
+
await group.increment(properties)
|
|
129
|
+
await group.append(properties)
|
|
130
|
+
await group.delete()
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Direct Call Pattern (for pipelines)
|
|
134
|
+
|
|
135
|
+
```javascript
|
|
136
|
+
await trodo.track('user-123', 'event_name', { key: 'value' })
|
|
137
|
+
await trodo.identify('user-123', 'identifyId')
|
|
138
|
+
await trodo.people.set('user-123', { plan: 'pro' })
|
|
139
|
+
await trodo.set_group('user-123', 'company', 'acme')
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Global Methods
|
|
143
|
+
|
|
144
|
+
```javascript
|
|
145
|
+
trodo.enableAutoEvents() // Enable uncaughtException hooks
|
|
146
|
+
trodo.disableAutoEvents() // Disable hooks
|
|
147
|
+
await trodo.flush() // Flush pending batch queue
|
|
148
|
+
await trodo.shutdown() // Flush + stop background timers
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Auto Events
|
|
152
|
+
|
|
153
|
+
When `autoEvents: true`, the SDK hooks Node.js process error events and sends `server_error` events to Trodo:
|
|
154
|
+
|
|
155
|
+
- `process.on('uncaughtException')`
|
|
156
|
+
- `process.on('unhandledRejection')`
|
|
157
|
+
|
|
158
|
+
These events use `distinct_id: 'server_global'` in the dashboard.
|
|
159
|
+
|
|
160
|
+
Per-user error capture: `user.captureError(error)` uses the user's own `distinctId`.
|
|
161
|
+
|
|
162
|
+
## Batching
|
|
163
|
+
|
|
164
|
+
```javascript
|
|
165
|
+
trodo.init({
|
|
166
|
+
siteId: 'your-site-id',
|
|
167
|
+
batchEnabled: true,
|
|
168
|
+
batchSize: 100,
|
|
169
|
+
batchFlushIntervalMs: 3000,
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
// Events are queued and flushed every 3s or when 100 events accumulate
|
|
173
|
+
await user.track('page_view');
|
|
174
|
+
|
|
175
|
+
// Always flush before process exit
|
|
176
|
+
process.on('SIGTERM', () => trodo.shutdown());
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## TypeScript
|
|
180
|
+
|
|
181
|
+
Full TypeScript support with bundled type declarations:
|
|
182
|
+
|
|
183
|
+
```typescript
|
|
184
|
+
import trodo, { TrodoConfig, ForUserOptions } from 'trodo-node';
|
|
185
|
+
|
|
186
|
+
const config: TrodoConfig = { siteId: 'your-site-id' };
|
|
187
|
+
trodo.init(config);
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## License
|
|
191
|
+
|
|
192
|
+
ISC
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TrodoClient = void 0;
|
|
4
|
+
const ApiClient_js_1 = require("./api/ApiClient.js");
|
|
5
|
+
const SessionManager_js_1 = require("./session/SessionManager.js");
|
|
6
|
+
const EventQueue_js_1 = require("./queue/EventQueue.js");
|
|
7
|
+
const BatchFlusher_js_1 = require("./queue/BatchFlusher.js");
|
|
8
|
+
const AutoEventManager_js_1 = require("./auto/AutoEventManager.js");
|
|
9
|
+
const UserContext_js_1 = require("./UserContext.js");
|
|
10
|
+
const DEFAULT_API_BASE = 'https://sdkapi.trodo.ai';
|
|
11
|
+
class TrodoClient {
|
|
12
|
+
constructor(config) {
|
|
13
|
+
this.userContextCache = new Map();
|
|
14
|
+
if (!config.siteId)
|
|
15
|
+
throw new Error('trodo-node: siteId is required');
|
|
16
|
+
this.siteId = config.siteId;
|
|
17
|
+
this.apiBase = config.apiBase ?? DEFAULT_API_BASE;
|
|
18
|
+
this.apiClient = new ApiClient_js_1.ApiClient(this.apiBase, this.siteId, config.timeout ?? 10000, config.retries ?? 2, config.onError, config.debug ?? false);
|
|
19
|
+
this.sessionManager = new SessionManager_js_1.SessionManager();
|
|
20
|
+
if (config.batchEnabled) {
|
|
21
|
+
this.eventQueue = new EventQueue_js_1.EventQueue(config.batchSize ?? 50);
|
|
22
|
+
this.batchFlusher = new BatchFlusher_js_1.BatchFlusher(this.eventQueue, this.apiClient, config.batchFlushIntervalMs ?? 5000);
|
|
23
|
+
this.batchFlusher.start();
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
this.eventQueue = null;
|
|
27
|
+
this.batchFlusher = null;
|
|
28
|
+
}
|
|
29
|
+
this.autoEventManager = new AutoEventManager_js_1.AutoEventManager(this.siteId, this.apiClient, this.sessionManager);
|
|
30
|
+
if (config.autoEvents) {
|
|
31
|
+
this.autoEventManager.enable();
|
|
32
|
+
}
|
|
33
|
+
// Wire up direct-call-pattern people helpers
|
|
34
|
+
const client = this;
|
|
35
|
+
this.people = {
|
|
36
|
+
set: (d, p) => client.forUser(d).people.set(p),
|
|
37
|
+
setOnce: (d, p) => client.forUser(d).people.setOnce(p),
|
|
38
|
+
unset: (d, k) => client.forUser(d).people.unset(k),
|
|
39
|
+
increment: (d, k, a) => client.forUser(d).people.increment(k, a),
|
|
40
|
+
append: (d, k, v) => client.forUser(d).people.append(k, v),
|
|
41
|
+
union: (d, k, v) => client.forUser(d).people.union(k, v),
|
|
42
|
+
remove: (d, k, v) => client.forUser(d).people.remove(k, v),
|
|
43
|
+
trackCharge: (d, a, p) => client.forUser(d).people.trackCharge(a, p),
|
|
44
|
+
clearCharges: (d) => client.forUser(d).people.clearCharges(),
|
|
45
|
+
deleteUser: (d) => client.forUser(d).people.deleteUser(),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
// --------------------------------------------------------------------------
|
|
49
|
+
// Primary pattern: forUser()
|
|
50
|
+
// --------------------------------------------------------------------------
|
|
51
|
+
forUser(distinctId, options) {
|
|
52
|
+
const key = distinctId;
|
|
53
|
+
const cached = this.userContextCache.get(key);
|
|
54
|
+
if (cached)
|
|
55
|
+
return cached;
|
|
56
|
+
const ctx = new UserContext_js_1.UserContext(distinctId, this.siteId, this.apiClient, this.sessionManager, this.eventQueue, this.batchFlusher, this.autoEventManager, options);
|
|
57
|
+
this.userContextCache.set(key, ctx);
|
|
58
|
+
return ctx;
|
|
59
|
+
}
|
|
60
|
+
// --------------------------------------------------------------------------
|
|
61
|
+
// Direct-call pattern (distinctId as first param)
|
|
62
|
+
// --------------------------------------------------------------------------
|
|
63
|
+
async track(distinctId, eventName, properties, options) {
|
|
64
|
+
return this.forUser(distinctId).track(eventName, properties, options);
|
|
65
|
+
}
|
|
66
|
+
async identify(distinctId, identifyId) {
|
|
67
|
+
return this.forUser(distinctId).identify(identifyId);
|
|
68
|
+
}
|
|
69
|
+
async walletAddress(distinctId, walletAddress) {
|
|
70
|
+
return this.forUser(distinctId).walletAddress(walletAddress);
|
|
71
|
+
}
|
|
72
|
+
async reset(distinctId) {
|
|
73
|
+
this.userContextCache.delete(distinctId);
|
|
74
|
+
return this.forUser(distinctId).reset();
|
|
75
|
+
}
|
|
76
|
+
async set_group(distinctId, groupKey, groupId) {
|
|
77
|
+
return this.forUser(distinctId).set_group(groupKey, groupId);
|
|
78
|
+
}
|
|
79
|
+
async add_group(distinctId, groupKey, groupId) {
|
|
80
|
+
return this.forUser(distinctId).add_group(groupKey, groupId);
|
|
81
|
+
}
|
|
82
|
+
async remove_group(distinctId, groupKey, groupId) {
|
|
83
|
+
return this.forUser(distinctId).remove_group(groupKey, groupId);
|
|
84
|
+
}
|
|
85
|
+
get_group(distinctId, groupKey, groupId) {
|
|
86
|
+
return this.forUser(distinctId).get_group(groupKey, groupId);
|
|
87
|
+
}
|
|
88
|
+
// --------------------------------------------------------------------------
|
|
89
|
+
// Auto events
|
|
90
|
+
// --------------------------------------------------------------------------
|
|
91
|
+
enableAutoEvents() {
|
|
92
|
+
this.autoEventManager.enable();
|
|
93
|
+
}
|
|
94
|
+
disableAutoEvents() {
|
|
95
|
+
this.autoEventManager.disable();
|
|
96
|
+
}
|
|
97
|
+
// --------------------------------------------------------------------------
|
|
98
|
+
// Lifecycle
|
|
99
|
+
// --------------------------------------------------------------------------
|
|
100
|
+
async flush() {
|
|
101
|
+
if (this.batchFlusher)
|
|
102
|
+
await this.batchFlusher.flush();
|
|
103
|
+
}
|
|
104
|
+
async shutdown() {
|
|
105
|
+
this.autoEventManager.disable();
|
|
106
|
+
if (this.batchFlusher) {
|
|
107
|
+
this.batchFlusher.stop();
|
|
108
|
+
await this.batchFlusher.flush();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.TrodoClient = TrodoClient;
|
|
113
|
+
//# sourceMappingURL=TrodoClient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AAe;QAEf,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC/D,CAAC;IAED,6EAA6E;IAC7E,cAAc;IACd,6EAA6E;IAE7E,gBAAgB;QACd,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC;IACjC,CAAC;IAED,iBAAiB;QACf,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC;IAClC,CAAC;IAED,6EAA6E;IAC7E,YAAY;IACZ,6EAA6E;IAE7E,KAAK,CAAC,KAAK;QACT,IAAI,IAAI,CAAC,YAAY;YAAE,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;IACzD,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC;QAChC,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC;YACzB,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;QAClC,CAAC;IACH,CAAC;CACF;AAlMD,kCAkMC"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserContext = void 0;
|
|
4
|
+
const PeopleManager_js_1 = require("./managers/PeopleManager.js");
|
|
5
|
+
const GroupManager_js_1 = require("./managers/GroupManager.js");
|
|
6
|
+
class UserContext {
|
|
7
|
+
constructor(_distinctId, siteId, apiClient, sessionManager, eventQueue, batchFlusher, autoEventManager, options = {}) {
|
|
8
|
+
this._distinctId = _distinctId;
|
|
9
|
+
this.siteId = siteId;
|
|
10
|
+
this.apiClient = apiClient;
|
|
11
|
+
this.sessionManager = sessionManager;
|
|
12
|
+
this.eventQueue = eventQueue;
|
|
13
|
+
this.batchFlusher = batchFlusher;
|
|
14
|
+
this.autoEventManager = autoEventManager;
|
|
15
|
+
this.options = options;
|
|
16
|
+
this.session = null;
|
|
17
|
+
// Eagerly start session initialisation (non-blocking)
|
|
18
|
+
this.initPromise = this.sessionManager
|
|
19
|
+
.getOrCreate(_distinctId, siteId, options)
|
|
20
|
+
.then((s) => {
|
|
21
|
+
this.session = s;
|
|
22
|
+
});
|
|
23
|
+
this.people = new PeopleManager_js_1.PeopleManager(apiClient, siteId, () => this.getDistinctId());
|
|
24
|
+
this.groupManager = new GroupManager_js_1.GroupManager(apiClient, siteId, () => this.getDistinctId());
|
|
25
|
+
}
|
|
26
|
+
getDistinctId() {
|
|
27
|
+
return this.session?.distinctId ?? this._distinctId;
|
|
28
|
+
}
|
|
29
|
+
async getSession() {
|
|
30
|
+
await this.initPromise;
|
|
31
|
+
if (!this.session) {
|
|
32
|
+
this.session = await this.sessionManager.getOrCreate(this._distinctId, this.siteId, this.options);
|
|
33
|
+
}
|
|
34
|
+
return this.session;
|
|
35
|
+
}
|
|
36
|
+
async sendEvent(eventName, properties, opts = {}) {
|
|
37
|
+
const session = await this.getSession();
|
|
38
|
+
await this.sessionManager.ensureConfirmed(session, this.apiClient);
|
|
39
|
+
const payload = {
|
|
40
|
+
event_type: 'custom',
|
|
41
|
+
event_name: eventName,
|
|
42
|
+
event_category: opts.category ?? 'custom',
|
|
43
|
+
session_id: session.sessionId,
|
|
44
|
+
user_id: session.distinctId,
|
|
45
|
+
custom_properties: properties ?? {},
|
|
46
|
+
page_data: null,
|
|
47
|
+
auto_event_data: null,
|
|
48
|
+
element_data: null,
|
|
49
|
+
override_data: null,
|
|
50
|
+
};
|
|
51
|
+
if (this.eventQueue && this.batchFlusher) {
|
|
52
|
+
const flush = this.eventQueue.enqueue(payload);
|
|
53
|
+
if (flush)
|
|
54
|
+
await this.batchFlusher.flush();
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
await this.apiClient.postEvent(payload);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
// --------------------------------------------------------------------------
|
|
61
|
+
// Event Tracking
|
|
62
|
+
// --------------------------------------------------------------------------
|
|
63
|
+
async track(eventName, properties, options) {
|
|
64
|
+
return this.sendEvent(eventName, properties, options);
|
|
65
|
+
}
|
|
66
|
+
/** Alias for track() — matches frontend SDK naming */
|
|
67
|
+
async trackEvent(eventName, properties, options) {
|
|
68
|
+
return this.sendEvent(eventName, properties, options);
|
|
69
|
+
}
|
|
70
|
+
// --------------------------------------------------------------------------
|
|
71
|
+
// Identity
|
|
72
|
+
// --------------------------------------------------------------------------
|
|
73
|
+
async identify(identifyId) {
|
|
74
|
+
const session = await this.getSession();
|
|
75
|
+
await this.sessionManager.ensureConfirmed(session, this.apiClient);
|
|
76
|
+
const result = await this.apiClient.postIdentify({
|
|
77
|
+
siteId: this.siteId,
|
|
78
|
+
sessionId: session.sessionId,
|
|
79
|
+
userId: session.distinctId,
|
|
80
|
+
distinctId: session.distinctId,
|
|
81
|
+
identifyId,
|
|
82
|
+
});
|
|
83
|
+
// Update session distinctId with what the backend returns
|
|
84
|
+
const newDistinctId = result.newDistinctId ?? result.distinctId;
|
|
85
|
+
if (newDistinctId && newDistinctId !== session.distinctId) {
|
|
86
|
+
const oldDistinctId = session.distinctId;
|
|
87
|
+
session.distinctId = newDistinctId;
|
|
88
|
+
// Re-key the session in SessionManager under the new distinctId
|
|
89
|
+
this.sessionManager.update(oldDistinctId, { distinctId: newDistinctId });
|
|
90
|
+
}
|
|
91
|
+
return result;
|
|
92
|
+
}
|
|
93
|
+
async walletAddress(walletAddress) {
|
|
94
|
+
const session = await this.getSession();
|
|
95
|
+
await this.sessionManager.ensureConfirmed(session, this.apiClient);
|
|
96
|
+
return this.apiClient.postWalletAddress({
|
|
97
|
+
siteId: this.siteId,
|
|
98
|
+
sessionId: session.sessionId,
|
|
99
|
+
userId: session.distinctId,
|
|
100
|
+
distinctId: session.distinctId,
|
|
101
|
+
walletAddress,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
async reset() {
|
|
105
|
+
const session = await this.getSession();
|
|
106
|
+
const result = await this.apiClient.postReset({
|
|
107
|
+
siteId: this.siteId,
|
|
108
|
+
sessionId: session.sessionId,
|
|
109
|
+
userId: session.distinctId,
|
|
110
|
+
distinctId: session.distinctId,
|
|
111
|
+
});
|
|
112
|
+
this.sessionManager.invalidate(this._distinctId);
|
|
113
|
+
this.session = null;
|
|
114
|
+
return result;
|
|
115
|
+
}
|
|
116
|
+
// --------------------------------------------------------------------------
|
|
117
|
+
// People (delegate to PeopleManager)
|
|
118
|
+
// --------------------------------------------------------------------------
|
|
119
|
+
// Accessible via user.people.set(...) etc. — already set up in constructor.
|
|
120
|
+
// --------------------------------------------------------------------------
|
|
121
|
+
// Groups
|
|
122
|
+
// --------------------------------------------------------------------------
|
|
123
|
+
async set_group(groupKey, groupId) {
|
|
124
|
+
await this.getSession(); // ensure session is ready
|
|
125
|
+
return this.groupManager.set_group(groupKey, groupId);
|
|
126
|
+
}
|
|
127
|
+
async add_group(groupKey, groupId) {
|
|
128
|
+
await this.getSession();
|
|
129
|
+
return this.groupManager.add_group(groupKey, groupId);
|
|
130
|
+
}
|
|
131
|
+
async remove_group(groupKey, groupId) {
|
|
132
|
+
await this.getSession();
|
|
133
|
+
return this.groupManager.remove_group(groupKey, groupId);
|
|
134
|
+
}
|
|
135
|
+
get_group(groupKey, groupId) {
|
|
136
|
+
return this.groupManager.get_group(groupKey, groupId);
|
|
137
|
+
}
|
|
138
|
+
// --------------------------------------------------------------------------
|
|
139
|
+
// Error capture
|
|
140
|
+
// --------------------------------------------------------------------------
|
|
141
|
+
async captureError(error, severity = 'error') {
|
|
142
|
+
const session = await this.getSession();
|
|
143
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
144
|
+
await this.autoEventManager.trackError(err, err.name || 'Error', severity, session.distinctId);
|
|
145
|
+
}
|
|
146
|
+
// --------------------------------------------------------------------------
|
|
147
|
+
// Auto events (per-context toggle)
|
|
148
|
+
// --------------------------------------------------------------------------
|
|
149
|
+
enableAutoEvents() {
|
|
150
|
+
this.autoEventManager.enable();
|
|
151
|
+
}
|
|
152
|
+
disableAutoEvents() {
|
|
153
|
+
this.autoEventManager.disable();
|
|
154
|
+
}
|
|
155
|
+
// --------------------------------------------------------------------------
|
|
156
|
+
// Session info
|
|
157
|
+
// --------------------------------------------------------------------------
|
|
158
|
+
getSessionId() {
|
|
159
|
+
return this.session?.sessionId ?? null;
|
|
160
|
+
}
|
|
161
|
+
getCurrentDistinctId() {
|
|
162
|
+
return this.getDistinctId();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
exports.UserContext = UserContext;
|
|
166
|
+
//# sourceMappingURL=UserContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UserContext.js","sourceRoot":"","sources":["../../src/UserContext.ts"],"names":[],"mappings":";;;AAeA,kEAA4D;AAC5D,gEAA0D;AAI1D,MAAa,WAAW;IAOtB,YACmB,WAAmB,EACnB,MAAc,EACd,SAAoB,EACpB,cAA8B,EAC9B,UAA6B,EAC7B,YAAiC,EACjC,gBAAkC,EAClC,UAA0B,EAAE;QAP5B,gBAAW,GAAX,WAAW,CAAQ;QACnB,WAAM,GAAN,MAAM,CAAQ;QACd,cAAS,GAAT,SAAS,CAAW;QACpB,mBAAc,GAAd,cAAc,CAAgB;QAC9B,eAAU,GAAV,UAAU,CAAmB;QAC7B,iBAAY,GAAZ,YAAY,CAAqB;QACjC,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,YAAO,GAAP,OAAO,CAAqB;QAdvC,YAAO,GAAyB,IAAI,CAAC;QAgB3C,sDAAsD;QACtD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,cAAc;aACnC,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC;aACzC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;YACV,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;QACnB,CAAC,CAAC,CAAC;QAEL,IAAI,CAAC,MAAM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IACJ,CAAC;IAED,6EAA6E;IAC7E,mCAAmC;IACnC,6EAA6E;IAE7E,gBAAgB;QACd,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC;IACjC,CAAC;IAED,iBAAiB;QACf,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC;IAClC,CAAC;IAED,6EAA6E;IAC7E,eAAe;IACf,6EAA6E;IAE7E,YAAY;QACV,OAAO,IAAI,CAAC,OAAO,EAAE,SAAS,IAAI,IAAI,CAAC;IACzC,CAAC;IAED,oBAAoB;QAClB,OAAO,IAAI,CAAC,aAAa,EAAE,CAAC;IAC9B,CAAC;CACF;AAxOD,kCAwOC"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ApiClient = void 0;
|
|
37
|
+
const endpoints_js_1 = require("./endpoints.js");
|
|
38
|
+
class ApiClient {
|
|
39
|
+
constructor(apiBase, siteId, timeout, retries, onError, debug = false) {
|
|
40
|
+
this._fetchFn = null;
|
|
41
|
+
this.apiBase = apiBase;
|
|
42
|
+
this.siteId = siteId;
|
|
43
|
+
this.timeout = timeout;
|
|
44
|
+
this.retries = retries;
|
|
45
|
+
this.onError = onError;
|
|
46
|
+
this.debug = debug;
|
|
47
|
+
}
|
|
48
|
+
async getFetch() {
|
|
49
|
+
if (this._fetchFn)
|
|
50
|
+
return this._fetchFn;
|
|
51
|
+
// Use built-in fetch (Node 18+) or fall back to node-fetch
|
|
52
|
+
if (typeof globalThis.fetch === 'function') {
|
|
53
|
+
this._fetchFn = globalThis.fetch.bind(globalThis);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
try {
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
58
|
+
// @ts-ignore – node-fetch is an optional peer dependency for Node <18
|
|
59
|
+
const nodeFetch = await Promise.resolve().then(() => __importStar(require('node-fetch')));
|
|
60
|
+
this._fetchFn = nodeFetch.default;
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
throw new Error('trodo-node: No fetch implementation found. On Node <18 install peer dependency: npm install node-fetch');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return this._fetchFn;
|
|
67
|
+
}
|
|
68
|
+
log(...args) {
|
|
69
|
+
if (this.debug)
|
|
70
|
+
process.stderr.write(`[trodo-node] ${args.join(' ')}\n`);
|
|
71
|
+
}
|
|
72
|
+
async request(path, body, attempt = 0) {
|
|
73
|
+
const url = `${this.apiBase}${path}`;
|
|
74
|
+
const fetchFn = await this.getFetch();
|
|
75
|
+
const controller = new AbortController();
|
|
76
|
+
const timer = setTimeout(() => controller.abort(), this.timeout);
|
|
77
|
+
try {
|
|
78
|
+
this.log(`POST ${url}`);
|
|
79
|
+
const res = await fetchFn(url, {
|
|
80
|
+
method: 'POST',
|
|
81
|
+
headers: {
|
|
82
|
+
'Content-Type': 'application/json',
|
|
83
|
+
'X-Trodo-Site-Id': this.siteId,
|
|
84
|
+
},
|
|
85
|
+
body: JSON.stringify(body),
|
|
86
|
+
signal: controller.signal,
|
|
87
|
+
});
|
|
88
|
+
clearTimeout(timer);
|
|
89
|
+
if (!res.ok && res.status >= 500 && attempt < this.retries) {
|
|
90
|
+
const delay = Math.pow(2, attempt) * 1000;
|
|
91
|
+
this.log(`Retry ${attempt + 1} after ${delay}ms (status ${res.status})`);
|
|
92
|
+
await new Promise((r) => setTimeout(r, delay));
|
|
93
|
+
return this.request(path, body, attempt + 1);
|
|
94
|
+
}
|
|
95
|
+
const text = await res.text();
|
|
96
|
+
try {
|
|
97
|
+
return JSON.parse(text);
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
return {};
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
catch (err) {
|
|
104
|
+
clearTimeout(timer);
|
|
105
|
+
if (attempt < this.retries) {
|
|
106
|
+
const delay = Math.pow(2, attempt) * 1000;
|
|
107
|
+
this.log(`Retry ${attempt + 1} after ${delay}ms (network error)`);
|
|
108
|
+
await new Promise((r) => setTimeout(r, delay));
|
|
109
|
+
return this.request(path, body, attempt + 1);
|
|
110
|
+
}
|
|
111
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
112
|
+
this.log(`Error: ${error.message}`);
|
|
113
|
+
if (this.onError)
|
|
114
|
+
this.onError(error);
|
|
115
|
+
return {};
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
async postTrack(sessionData) {
|
|
119
|
+
return this.request(endpoints_js_1.ENDPOINTS.TRACK, { sessionData });
|
|
120
|
+
}
|
|
121
|
+
async postEvent(event) {
|
|
122
|
+
return this.request(endpoints_js_1.ENDPOINTS.EVENTS, event);
|
|
123
|
+
}
|
|
124
|
+
async postBulkEvents(events) {
|
|
125
|
+
return this.request(endpoints_js_1.ENDPOINTS.EVENTS_BULK, { events });
|
|
126
|
+
}
|
|
127
|
+
async postIdentify(payload) {
|
|
128
|
+
return this.request(endpoints_js_1.ENDPOINTS.IDENTIFY, payload);
|
|
129
|
+
}
|
|
130
|
+
async postWalletAddress(payload) {
|
|
131
|
+
return this.request(endpoints_js_1.ENDPOINTS.WALLET_ADDRESS, payload);
|
|
132
|
+
}
|
|
133
|
+
async postReset(payload) {
|
|
134
|
+
return this.request(endpoints_js_1.ENDPOINTS.RESET, payload);
|
|
135
|
+
}
|
|
136
|
+
async postPeople(path, payload) {
|
|
137
|
+
return this.request(path, payload);
|
|
138
|
+
}
|
|
139
|
+
async postGroup(path, payload) {
|
|
140
|
+
return this.request(path, payload);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
exports.ApiClient = ApiClient;
|
|
144
|
+
//# sourceMappingURL=ApiClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiClient.js","sourceRoot":"","sources":["../../../src/api/ApiClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA2C;AAW3C,MAAa,SAAS;IASpB,YACE,OAAe,EACf,MAAc,EACd,OAAe,EACf,OAAe,EACf,OAAgC,EAChC,KAAK,GAAG,KAAK;QARP,aAAQ,GAAmB,IAAI,CAAC;QAUtC,IAAI,CAAC,OAAO,GAA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I,CAAC,OAAO,CAAY,wBAAS,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IACpE,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,OAMlB;QACC,OAAO,IAAI,CAAC,OAAO,CAAiB,wBAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACnE,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,OAMvB;QACC,OAAO,IAAI,CAAC,OAAO,CAAsB,wBAAS,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAC9E,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,OAKf;QACC,OAAO,IAAI,CAAC,OAAO,CAAc,wBAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC7D,CAAC;IAED,KAAK,CAAC,UAAU,CACd,IAAY,EACZ,OAAgC;QAEhC,OAAO,IAAI,CAAC,OAAO,CAAY,IAAI,EAAE,OAAO,CAAC,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,SAAS,CACb,IAAY,EACZ,OAAgC;QAEhC,OAAO,IAAI,CAAC,OAAO,CAAY,IAAI,EAAE,OAAO,CAAC,CAAC;IAChD,CAAC;CACF;AA5JD,8BA4JC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ENDPOINTS = void 0;
|
|
4
|
+
exports.ENDPOINTS = {
|
|
5
|
+
TRACK: '/api/sdk/track',
|
|
6
|
+
EVENTS: '/api/events',
|
|
7
|
+
EVENTS_BULK: '/api/events/bulk',
|
|
8
|
+
IDENTIFY: '/api/sdk/identify',
|
|
9
|
+
WALLET_ADDRESS: '/api/sdk/wallet-address',
|
|
10
|
+
RESET: '/api/sdk/reset',
|
|
11
|
+
PEOPLE_SET: '/api/sdk/people/set',
|
|
12
|
+
PEOPLE_SET_ONCE: '/api/sdk/people/set_once',
|
|
13
|
+
PEOPLE_UNSET: '/api/sdk/people/unset',
|
|
14
|
+
PEOPLE_INCREMENT: '/api/sdk/people/increment',
|
|
15
|
+
PEOPLE_APPEND: '/api/sdk/people/append',
|
|
16
|
+
PEOPLE_UNION: '/api/sdk/people/union',
|
|
17
|
+
PEOPLE_REMOVE: '/api/sdk/people/remove',
|
|
18
|
+
PEOPLE_TRACK_CHARGE: '/api/sdk/people/track_charge',
|
|
19
|
+
PEOPLE_CLEAR_CHARGES: '/api/sdk/people/clear_charges',
|
|
20
|
+
PEOPLE_DELETE_USER: '/api/sdk/people/delete_user',
|
|
21
|
+
GROUPS_SET: '/api/sdk/groups/set_group',
|
|
22
|
+
GROUPS_ADD: '/api/sdk/groups/add_group',
|
|
23
|
+
GROUPS_REMOVE: '/api/sdk/groups/remove_group',
|
|
24
|
+
GROUPS_PROFILE: '/api/sdk/groups/profile',
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=endpoints.js.map
|