autotel-subscribers 42.0.0 → 43.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 +112 -108
- package/dist/amplitude.cjs +1 -2
- package/dist/amplitude.cjs.map +1 -1
- package/dist/amplitude.d.cts +0 -1
- package/dist/amplitude.d.cts.map +1 -1
- package/dist/amplitude.d.ts +0 -1
- package/dist/amplitude.d.ts.map +1 -1
- package/dist/amplitude.js +1 -3
- package/dist/amplitude.js.map +1 -1
- package/dist/architecture-snapshot.cjs +1 -1
- package/dist/architecture-snapshot.cjs.map +1 -1
- package/dist/architecture-snapshot.d.cts +18 -10
- package/dist/architecture-snapshot.d.cts.map +1 -1
- package/dist/architecture-snapshot.d.ts +18 -10
- package/dist/architecture-snapshot.d.ts.map +1 -1
- package/dist/architecture-snapshot.js.map +1 -1
- package/dist/event-subscriber-base-C_F3Ycbe.cjs.map +1 -1
- package/dist/event-subscriber-base-Day2ml6V.js.map +1 -1
- package/dist/{event-subscriber-base-DOVIZK7N.d.ts → event-subscriber-base-DpZclJM4.d.cts} +1 -2
- package/dist/event-subscriber-base-DpZclJM4.d.cts.map +1 -0
- package/dist/{event-subscriber-base-DOVIZK7N.d.cts → event-subscriber-base-DpZclJM4.d.ts} +1 -2
- package/dist/event-subscriber-base-DpZclJM4.d.ts.map +1 -0
- package/dist/factories.cjs +2 -3
- package/dist/factories.cjs.map +1 -1
- package/dist/factories.d.cts +1 -2
- package/dist/factories.d.cts.map +1 -1
- package/dist/factories.d.ts +1 -2
- package/dist/factories.d.ts.map +1 -1
- package/dist/factories.js +2 -2
- package/dist/factories.js.map +1 -1
- package/dist/file.cjs +2 -2
- package/dist/file.cjs.map +1 -1
- package/dist/file.d.cts +1 -2
- package/dist/file.d.cts.map +1 -1
- package/dist/file.d.ts +1 -2
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +1 -1
- package/dist/file.js.map +1 -1
- package/dist/index.cjs +1 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/middleware.cjs +0 -1
- package/dist/middleware.cjs.map +1 -1
- package/dist/middleware.d.cts +0 -1
- package/dist/middleware.d.cts.map +1 -1
- package/dist/middleware.d.ts +0 -1
- package/dist/middleware.d.ts.map +1 -1
- package/dist/middleware.js.map +1 -1
- package/dist/mixpanel.cjs +1 -2
- package/dist/mixpanel.cjs.map +1 -1
- package/dist/mixpanel.d.cts +0 -1
- package/dist/mixpanel.d.cts.map +1 -1
- package/dist/mixpanel.d.ts +0 -1
- package/dist/mixpanel.d.ts.map +1 -1
- package/dist/mixpanel.js +1 -3
- package/dist/mixpanel.js.map +1 -1
- package/dist/{posthog-C9M1c_oG.js → posthog-ByP8BmHb.js} +2 -2
- package/dist/posthog-ByP8BmHb.js.map +1 -0
- package/dist/{posthog-DZfoAW1q.cjs → posthog-DOOBZanH.cjs} +3 -3
- package/dist/posthog-DOOBZanH.cjs.map +1 -0
- package/dist/posthog.cjs +1 -2
- package/dist/posthog.d.cts +332 -2
- package/dist/posthog.d.cts.map +1 -0
- package/dist/posthog.d.ts +332 -2
- package/dist/posthog.d.ts.map +1 -0
- package/dist/posthog.js +1 -1
- package/dist/{rolldown-runtime-BHkdefai.js → rolldown-runtime-C_NdSu1c.cjs} +7 -27
- package/dist/security.cjs +2 -3
- package/dist/security.cjs.map +1 -1
- package/dist/security.d.cts +1 -2
- package/dist/security.d.cts.map +1 -1
- package/dist/security.d.ts +1 -2
- package/dist/security.d.ts.map +1 -1
- package/dist/security.js +2 -2
- package/dist/security.js.map +1 -1
- package/dist/segment.cjs +1 -2
- package/dist/segment.cjs.map +1 -1
- package/dist/segment.d.cts +0 -1
- package/dist/segment.d.cts.map +1 -1
- package/dist/segment.d.ts +0 -1
- package/dist/segment.d.ts.map +1 -1
- package/dist/segment.js +1 -3
- package/dist/segment.js.map +1 -1
- package/dist/slack.cjs +3 -4
- package/dist/slack.cjs.map +1 -1
- package/dist/slack.d.cts +1 -2
- package/dist/slack.d.cts.map +1 -1
- package/dist/slack.d.ts +1 -2
- package/dist/slack.d.ts.map +1 -1
- package/dist/slack.js +3 -3
- package/dist/slack.js.map +1 -1
- package/dist/webhook-delivery-D3v50C81.js.map +1 -1
- package/dist/webhook-delivery-DZeUlZhi.cjs.map +1 -1
- package/dist/webhook.cjs +0 -1
- package/dist/webhook.cjs.map +1 -1
- package/dist/webhook.d.cts +0 -1
- package/dist/webhook.d.cts.map +1 -1
- package/dist/webhook.d.ts +0 -1
- package/dist/webhook.d.ts.map +1 -1
- package/dist/webhook.js.map +1 -1
- package/examples/quickstart-custom-subscriber.ts +12 -7
- package/examples/subscriber-bigquery.ts +9 -5
- package/examples/subscriber-databricks.ts +22 -27
- package/examples/subscriber-kafka.ts +18 -9
- package/examples/subscriber-kinesis.ts +24 -18
- package/examples/subscriber-posthog.ts +41 -23
- package/examples/subscriber-pubsub.ts +8 -11
- package/examples/subscriber-snowflake.ts +2 -2
- package/package.json +15 -15
- package/skills/autotel-subscribers/SKILL.md +8 -8
- package/dist/cjs-Bef2t9Tr.js +0 -8183
- package/dist/cjs-Bef2t9Tr.js.map +0 -1
- package/dist/cjs-C2fugEI8.cjs +0 -6471
- package/dist/cjs-C2fugEI8.cjs.map +0 -1
- package/dist/cjs-C5tev9Yr.cjs +0 -8186
- package/dist/cjs-C5tev9Yr.cjs.map +0 -1
- package/dist/cjs-CY69zXGd.js +0 -6468
- package/dist/cjs-CY69zXGd.js.map +0 -1
- package/dist/event-subscriber-base-DOVIZK7N.d.cts.map +0 -1
- package/dist/event-subscriber-base-DOVIZK7N.d.ts.map +0 -1
- package/dist/index.node-BF2WkODf.js +0 -4347
- package/dist/index.node-BF2WkODf.js.map +0 -1
- package/dist/index.node-DOkEUdYV.cjs +0 -4348
- package/dist/index.node-DOkEUdYV.cjs.map +0 -1
- package/dist/mixpanel-node-BVS2X-h7.cjs +0 -3228
- package/dist/mixpanel-node-BVS2X-h7.cjs.map +0 -1
- package/dist/mixpanel-node-BltEtoG6.js +0 -3222
- package/dist/mixpanel-node-BltEtoG6.js.map +0 -1
- package/dist/posthog-C9M1c_oG.js.map +0 -1
- package/dist/posthog-DCV5Arkw.d.ts +0 -3567
- package/dist/posthog-DCV5Arkw.d.ts.map +0 -1
- package/dist/posthog-DRYlG5fG.d.cts +0 -3567
- package/dist/posthog-DRYlG5fG.d.cts.map +0 -1
- package/dist/posthog-DZfoAW1q.cjs.map +0 -1
- package/dist/rolldown-runtime-CfAboj1T.cjs +0 -81
- package/dist/tslib.es6-02HJIdSd.cjs +0 -557
- package/dist/tslib.es6-02HJIdSd.cjs.map +0 -1
- package/dist/tslib.es6-Dvm0j0am.js +0 -546
- package/dist/tslib.es6-Dvm0j0am.js.map +0 -1
package/README.md
CHANGED
|
@@ -7,6 +7,7 @@ Subscribers for [autotel](https://github.com/jagreehal/autotel) to send events t
|
|
|
7
7
|
## Why Use This?
|
|
8
8
|
|
|
9
9
|
**Track once, send everywhere:**
|
|
10
|
+
|
|
10
11
|
- Primary metrics → **OpenTelemetry** (infrastructure monitoring)
|
|
11
12
|
- Product events → **PostHog / Mixpanel / Amplitude**
|
|
12
13
|
- Customer data → **Segment**
|
|
@@ -42,7 +43,7 @@ class MySubscriber extends EventSubscriber {
|
|
|
42
43
|
// Send to your platform
|
|
43
44
|
await fetch('https://api.example.com/events', {
|
|
44
45
|
method: 'POST',
|
|
45
|
-
body: JSON.stringify(payload)
|
|
46
|
+
body: JSON.stringify(payload),
|
|
46
47
|
});
|
|
47
48
|
}
|
|
48
49
|
}
|
|
@@ -63,7 +64,7 @@ class KafkaSubscriber extends StreamingEventSubscriber {
|
|
|
63
64
|
protected async sendBatch(events: EventPayload[]): Promise<void> {
|
|
64
65
|
await this.producer.send({
|
|
65
66
|
topic: 'events',
|
|
66
|
-
messages: events.map(e => ({ value: JSON.stringify(e) }))
|
|
67
|
+
messages: events.map((e) => ({ value: JSON.stringify(e) })),
|
|
67
68
|
});
|
|
68
69
|
}
|
|
69
70
|
}
|
|
@@ -96,15 +97,15 @@ pnpm add @amplitude/events-node # For Amplitude
|
|
|
96
97
|
Import subscribers directly from their entry points:
|
|
97
98
|
|
|
98
99
|
```typescript
|
|
99
|
-
import {
|
|
100
|
+
import { Event } from 'autotel/event';
|
|
100
101
|
import { PostHogSubscriber } from 'autotel-subscribers/posthog';
|
|
101
102
|
import { WebhookSubscriber } from 'autotel-subscribers/webhook';
|
|
102
103
|
|
|
103
104
|
const events = new Event('checkout', {
|
|
104
105
|
subscribers: [
|
|
105
106
|
new PostHogSubscriber({ apiKey: process.env.POSTHOG_API_KEY! }),
|
|
106
|
-
new WebhookSubscriber({ url: 'https://your-webhook.com' })
|
|
107
|
-
]
|
|
107
|
+
new WebhookSubscriber({ url: 'https://your-webhook.com' }),
|
|
108
|
+
],
|
|
108
109
|
});
|
|
109
110
|
|
|
110
111
|
// Sent to: OpenTelemetry + PostHog + Webhook
|
|
@@ -129,17 +130,17 @@ class MySubscriber extends EventSubscriber {
|
|
|
129
130
|
await fetch('https://your-api.com/events', {
|
|
130
131
|
method: 'POST',
|
|
131
132
|
headers: {
|
|
132
|
-
|
|
133
|
-
'Content-Type': 'application/json'
|
|
133
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
134
|
+
'Content-Type': 'application/json',
|
|
134
135
|
},
|
|
135
|
-
body: JSON.stringify(payload)
|
|
136
|
+
body: JSON.stringify(payload),
|
|
136
137
|
});
|
|
137
138
|
}
|
|
138
139
|
}
|
|
139
140
|
|
|
140
141
|
// Use it!
|
|
141
142
|
const events = new Event('my-app', {
|
|
142
|
-
subscribers: [new MySubscriber('your-api-key')]
|
|
143
|
+
subscribers: [new MySubscriber('your-api-key')],
|
|
143
144
|
});
|
|
144
145
|
```
|
|
145
146
|
|
|
@@ -160,15 +161,16 @@ AdapterTestHarness.printResults(results);
|
|
|
160
161
|
### Add Middleware (Retry, Sampling, etc.)
|
|
161
162
|
|
|
162
163
|
```typescript
|
|
163
|
-
import {
|
|
164
|
+
import {
|
|
165
|
+
applyMiddleware,
|
|
166
|
+
retryMiddleware,
|
|
167
|
+
samplingMiddleware,
|
|
168
|
+
} from 'autotel-subscribers/middleware';
|
|
164
169
|
|
|
165
|
-
const subscriber = applyMiddleware(
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
samplingMiddleware(0.1) // Only send 10% of events
|
|
170
|
-
]
|
|
171
|
-
);
|
|
170
|
+
const subscriber = applyMiddleware(new MySubscriber('api-key'), [
|
|
171
|
+
retryMiddleware({ maxRetries: 3 }), // Retry failed requests
|
|
172
|
+
samplingMiddleware(0.1), // Only send 10% of events
|
|
173
|
+
]);
|
|
172
174
|
```
|
|
173
175
|
|
|
174
176
|
---
|
|
@@ -178,22 +180,22 @@ const subscriber = applyMiddleware(
|
|
|
178
180
|
### PostHog
|
|
179
181
|
|
|
180
182
|
```typescript
|
|
181
|
-
import {
|
|
183
|
+
import { Event } from 'autotel/event';
|
|
182
184
|
import { PostHogSubscriber } from 'autotel-subscribers/posthog';
|
|
183
185
|
|
|
184
186
|
const events = new Event('checkout', {
|
|
185
187
|
subscribers: [
|
|
186
188
|
new PostHogSubscriber({
|
|
187
189
|
apiKey: process.env.POSTHOG_API_KEY!,
|
|
188
|
-
host: 'https://us.i.posthog.com' // optional
|
|
189
|
-
})
|
|
190
|
-
]
|
|
190
|
+
host: 'https://us.i.posthog.com', // optional
|
|
191
|
+
}),
|
|
192
|
+
],
|
|
191
193
|
});
|
|
192
194
|
|
|
193
195
|
// Sent to: OpenTelemetry + PostHog
|
|
194
196
|
events.trackEvent('order.completed', {
|
|
195
197
|
userId: '123',
|
|
196
|
-
amount: 99.99
|
|
198
|
+
amount: 99.99,
|
|
197
199
|
});
|
|
198
200
|
```
|
|
199
201
|
|
|
@@ -202,7 +204,7 @@ events.trackEvent('order.completed', {
|
|
|
202
204
|
```typescript
|
|
203
205
|
const subscriber = new PostHogSubscriber({
|
|
204
206
|
apiKey: 'phc_...',
|
|
205
|
-
serverless: true,
|
|
207
|
+
serverless: true, // Auto-configures for serverless (flushAt: 1, flushInterval: 0)
|
|
206
208
|
});
|
|
207
209
|
```
|
|
208
210
|
|
|
@@ -211,7 +213,7 @@ const subscriber = new PostHogSubscriber({
|
|
|
211
213
|
```typescript
|
|
212
214
|
// When PostHog is already loaded via script tag
|
|
213
215
|
const subscriber = new PostHogSubscriber({
|
|
214
|
-
useGlobalClient: true,
|
|
216
|
+
useGlobalClient: true, // Uses window.posthog
|
|
215
217
|
});
|
|
216
218
|
```
|
|
217
219
|
|
|
@@ -222,7 +224,7 @@ const subscriber = new PostHogSubscriber({
|
|
|
222
224
|
apiKey: 'phc_...',
|
|
223
225
|
|
|
224
226
|
// Automatic filtering (enabled by default)
|
|
225
|
-
filterUndefinedValues: true,
|
|
227
|
+
filterUndefinedValues: true, // Removes undefined/null from attributes
|
|
226
228
|
|
|
227
229
|
// Enhanced error handling
|
|
228
230
|
onErrorWithContext: (ctx) => {
|
|
@@ -249,9 +251,9 @@ import { MixpanelSubscriber } from 'autotel-subscribers/mixpanel';
|
|
|
249
251
|
const events = new Event('checkout', {
|
|
250
252
|
subscribers: [
|
|
251
253
|
new MixpanelSubscriber({
|
|
252
|
-
token: process.env.MIXPANEL_TOKEN
|
|
253
|
-
})
|
|
254
|
-
]
|
|
254
|
+
token: process.env.MIXPANEL_TOKEN!,
|
|
255
|
+
}),
|
|
256
|
+
],
|
|
255
257
|
});
|
|
256
258
|
```
|
|
257
259
|
|
|
@@ -263,9 +265,9 @@ import { SegmentSubscriber } from 'autotel-subscribers/segment';
|
|
|
263
265
|
const events = new Event('checkout', {
|
|
264
266
|
subscribers: [
|
|
265
267
|
new SegmentSubscriber({
|
|
266
|
-
writeKey: process.env.SEGMENT_WRITE_KEY
|
|
267
|
-
})
|
|
268
|
-
]
|
|
268
|
+
writeKey: process.env.SEGMENT_WRITE_KEY!,
|
|
269
|
+
}),
|
|
270
|
+
],
|
|
269
271
|
});
|
|
270
272
|
```
|
|
271
273
|
|
|
@@ -277,9 +279,9 @@ import { AmplitudeSubscriber } from 'autotel-subscribers/amplitude';
|
|
|
277
279
|
const events = new Event('checkout', {
|
|
278
280
|
subscribers: [
|
|
279
281
|
new AmplitudeSubscriber({
|
|
280
|
-
apiKey: process.env.AMPLITUDE_API_KEY
|
|
281
|
-
})
|
|
282
|
-
]
|
|
282
|
+
apiKey: process.env.AMPLITUDE_API_KEY!,
|
|
283
|
+
}),
|
|
284
|
+
],
|
|
283
285
|
});
|
|
284
286
|
```
|
|
285
287
|
|
|
@@ -293,9 +295,9 @@ const events = new Event('checkout', {
|
|
|
293
295
|
new WebhookSubscriber({
|
|
294
296
|
url: 'https://hooks.zapier.com/hooks/catch/...',
|
|
295
297
|
headers: { 'X-API-Key': 'secret' },
|
|
296
|
-
maxRetries: 3
|
|
297
|
-
})
|
|
298
|
-
]
|
|
298
|
+
maxRetries: 3,
|
|
299
|
+
}),
|
|
300
|
+
],
|
|
299
301
|
});
|
|
300
302
|
```
|
|
301
303
|
|
|
@@ -306,7 +308,7 @@ const events = new Event('checkout', {
|
|
|
306
308
|
Send to **multiple platforms simultaneously**:
|
|
307
309
|
|
|
308
310
|
```typescript
|
|
309
|
-
import {
|
|
311
|
+
import { Event } from 'autotel/event';
|
|
310
312
|
import { PostHogSubscriber } from 'autotel-subscribers/posthog';
|
|
311
313
|
import { MixpanelSubscriber } from 'autotel-subscribers/mixpanel';
|
|
312
314
|
import { SegmentSubscriber } from 'autotel-subscribers/segment';
|
|
@@ -315,15 +317,15 @@ const events = new Event('checkout', {
|
|
|
315
317
|
subscribers: [
|
|
316
318
|
new PostHogSubscriber({ apiKey: 'phc_...' }),
|
|
317
319
|
new MixpanelSubscriber({ token: '...' }),
|
|
318
|
-
new SegmentSubscriber({ writeKey: '...' })
|
|
319
|
-
]
|
|
320
|
+
new SegmentSubscriber({ writeKey: '...' }),
|
|
321
|
+
],
|
|
320
322
|
});
|
|
321
323
|
|
|
322
324
|
// Sent to: OpenTelemetry + PostHog + Mixpanel + Segment
|
|
323
|
-
events.trackEvent('order.completed', {
|
|
324
|
-
userId: '123',
|
|
325
|
+
events.trackEvent('order.completed', {
|
|
326
|
+
userId: '123',
|
|
325
327
|
amount: 99.99,
|
|
326
|
-
currency: 'USD'
|
|
328
|
+
currency: 'USD',
|
|
327
329
|
});
|
|
328
330
|
```
|
|
329
331
|
|
|
@@ -339,27 +341,30 @@ Autotel-subscribers provides **direct subscribers** (fire-and-forget) - events a
|
|
|
339
341
|
|
|
340
342
|
```typescript
|
|
341
343
|
const events = new Event('app', {
|
|
342
|
-
subscribers: [new PostHogSubscriber({ apiKey: '...' })]
|
|
343
|
-
})
|
|
344
|
+
subscribers: [new PostHogSubscriber({ apiKey: '...' })],
|
|
345
|
+
});
|
|
344
346
|
|
|
345
347
|
// Events sent immediately, real-time
|
|
346
|
-
events.trackEvent('user.signup', { userId: '123' })
|
|
347
|
-
events.trackEvent('page.viewed', { path: '/checkout' })
|
|
348
|
+
events.trackEvent('user.signup', { userId: '123' });
|
|
349
|
+
events.trackEvent('page.viewed', { path: '/checkout' });
|
|
348
350
|
```
|
|
349
351
|
|
|
350
352
|
**Use for:**
|
|
353
|
+
|
|
351
354
|
- Page views, button clicks, feature usage
|
|
352
355
|
- User behavior tracking
|
|
353
356
|
- High-volume, non-critical events
|
|
354
357
|
- Real-time events dashboards
|
|
355
358
|
|
|
356
359
|
**Benefits:**
|
|
360
|
+
|
|
357
361
|
- Simple, zero infrastructure
|
|
358
362
|
- Real-time delivery
|
|
359
363
|
- No database overhead
|
|
360
364
|
- Fire-and-forget
|
|
361
365
|
|
|
362
366
|
**Trade-offs:**
|
|
367
|
+
|
|
363
368
|
- Events can be lost if adapter/network fails
|
|
364
369
|
- No atomicity with database transactions
|
|
365
370
|
|
|
@@ -368,6 +373,7 @@ events.trackEvent('page.viewed', { path: '/checkout' })
|
|
|
368
373
|
**For guaranteed delivery with atomicity**, use the separate [`autotel-outbox`](https://github.com/jagreehal/autotel/tree/main/packages/autotel-outbox) package.
|
|
369
374
|
|
|
370
375
|
This provides:
|
|
376
|
+
|
|
371
377
|
- Guaranteed delivery (retries on failure)
|
|
372
378
|
- Atomicity with database state changes
|
|
373
379
|
- Fan-out to multiple destinations
|
|
@@ -375,20 +381,20 @@ This provides:
|
|
|
375
381
|
- Adds latency (1+ minute delay)
|
|
376
382
|
|
|
377
383
|
**Install:**
|
|
384
|
+
|
|
378
385
|
```bash
|
|
379
386
|
npm install autotel-outbox
|
|
380
387
|
```
|
|
381
388
|
|
|
382
389
|
**Usage:**
|
|
390
|
+
|
|
383
391
|
```typescript
|
|
384
392
|
import { OutboxEventSubscriber } from 'autotel-outbox';
|
|
385
393
|
import { PostHogSubscriber } from 'autotel-subscribers/posthog';
|
|
386
394
|
|
|
387
395
|
const outbox = new DrizzleD1OutboxStorage(env.DB);
|
|
388
396
|
const events = new Event('checkout', {
|
|
389
|
-
subscribers: [
|
|
390
|
-
new OutboxEventSubscriber(outbox, { aggregateType: 'Order' })
|
|
391
|
-
]
|
|
397
|
+
subscribers: [new OutboxEventSubscriber(outbox, { aggregateType: 'Order' })],
|
|
392
398
|
});
|
|
393
399
|
```
|
|
394
400
|
|
|
@@ -407,29 +413,29 @@ interface EventSubscriber {
|
|
|
407
413
|
trackFunnelStep(
|
|
408
414
|
funnelName: string,
|
|
409
415
|
step: 'started' | 'completed' | 'abandoned' | 'failed',
|
|
410
|
-
attributes?: Record<string, any
|
|
416
|
+
attributes?: Record<string, any>,
|
|
411
417
|
): Promise<void>;
|
|
412
418
|
|
|
413
419
|
// Track funnel progression (custom step names)
|
|
414
420
|
trackFunnelProgression?(
|
|
415
421
|
funnelName: string,
|
|
416
|
-
stepName: string,
|
|
417
|
-
stepNumber?: number,
|
|
418
|
-
attributes?: Record<string, any
|
|
422
|
+
stepName: string, // Any string, not limited to enum
|
|
423
|
+
stepNumber?: number, // Optional numeric position
|
|
424
|
+
attributes?: Record<string, any>,
|
|
419
425
|
): Promise<void>;
|
|
420
426
|
|
|
421
427
|
// Track business outcomes
|
|
422
428
|
trackOutcome(
|
|
423
429
|
operationName: string,
|
|
424
430
|
outcome: 'success' | 'failure' | 'partial',
|
|
425
|
-
attributes?: Record<string, any
|
|
431
|
+
attributes?: Record<string, any>,
|
|
426
432
|
): Promise<void>;
|
|
427
433
|
|
|
428
434
|
// Track business values (revenue, counts, etc.)
|
|
429
435
|
trackValue(
|
|
430
436
|
name: string,
|
|
431
437
|
value: number,
|
|
432
|
-
attributes?: Record<string, any
|
|
438
|
+
attributes?: Record<string, any>,
|
|
433
439
|
): Promise<void>;
|
|
434
440
|
|
|
435
441
|
// Flush and clean up resources
|
|
@@ -444,25 +450,25 @@ interface EventSubscriber {
|
|
|
444
450
|
Create your own adapter for any platform:
|
|
445
451
|
|
|
446
452
|
```typescript
|
|
447
|
-
import { EventSubscriber } from 'autotel/
|
|
453
|
+
import { EventSubscriber } from 'autotel/event-subscriber';
|
|
448
454
|
|
|
449
455
|
class MyCustomSubscriber implements EventSubscriber {
|
|
450
456
|
trackEvent(name: string, attributes?: Record<string, any>): void {
|
|
451
457
|
// Send to your platform
|
|
452
458
|
fetch('https://api.myplatform.com/events', {
|
|
453
459
|
method: 'POST',
|
|
454
|
-
body: JSON.stringify({ event: name, ...attributes })
|
|
460
|
+
body: JSON.stringify({ event: name, ...attributes }),
|
|
455
461
|
});
|
|
456
462
|
}
|
|
457
|
-
|
|
463
|
+
|
|
458
464
|
trackFunnelStep(funnel: string, step: string, attributes?: any): void {
|
|
459
465
|
// Implement funnel tracking
|
|
460
466
|
}
|
|
461
|
-
|
|
467
|
+
|
|
462
468
|
trackOutcome(operation: string, outcome: string, attributes?: any): void {
|
|
463
469
|
// Implement outcome tracking
|
|
464
470
|
}
|
|
465
|
-
|
|
471
|
+
|
|
466
472
|
trackValue(name: string, value: number, attributes?: any): void {
|
|
467
473
|
// Implement value tracking
|
|
468
474
|
}
|
|
@@ -470,7 +476,7 @@ class MyCustomSubscriber implements EventSubscriber {
|
|
|
470
476
|
|
|
471
477
|
// Use it
|
|
472
478
|
const events = new Event('app', {
|
|
473
|
-
subscribers: [new MyCustomSubscriber()]
|
|
479
|
+
subscribers: [new MyCustomSubscriber()],
|
|
474
480
|
});
|
|
475
481
|
```
|
|
476
482
|
|
|
@@ -483,15 +489,15 @@ const events = new Event('app', {
|
|
|
483
489
|
```typescript
|
|
484
490
|
const events = new Event('checkout', {
|
|
485
491
|
subscribers: [
|
|
486
|
-
new PostHogSubscriber({
|
|
492
|
+
new PostHogSubscriber({
|
|
487
493
|
apiKey: 'phc_...',
|
|
488
|
-
enabled: process.env.NODE_ENV === 'production' // Only in prod
|
|
494
|
+
enabled: process.env.NODE_ENV === 'production', // Only in prod
|
|
489
495
|
}),
|
|
490
|
-
new MixpanelSubscriber({
|
|
496
|
+
new MixpanelSubscriber({
|
|
491
497
|
token: '...',
|
|
492
|
-
enabled: false // Temporarily disabled
|
|
493
|
-
})
|
|
494
|
-
]
|
|
498
|
+
enabled: false, // Temporarily disabled
|
|
499
|
+
}),
|
|
500
|
+
],
|
|
495
501
|
});
|
|
496
502
|
```
|
|
497
503
|
|
|
@@ -518,6 +524,7 @@ import { PostHogSubscriber } from 'autotel-subscribers/posthog';
|
|
|
518
524
|
```
|
|
519
525
|
|
|
520
526
|
Bundle sizes (gzipped):
|
|
527
|
+
|
|
521
528
|
- PostHog: ~8KB
|
|
522
529
|
- Mixpanel: ~6KB
|
|
523
530
|
- Segment: ~12KB
|
|
@@ -529,10 +536,12 @@ Bundle sizes (gzipped):
|
|
|
529
536
|
## Performance
|
|
530
537
|
|
|
531
538
|
**Zero overhead when not used:**
|
|
539
|
+
|
|
532
540
|
- If `subscribers: []` (empty), no adapter code runs
|
|
533
541
|
- Tree-shaken out in production builds
|
|
534
542
|
|
|
535
543
|
**Minimal overhead when used:**
|
|
544
|
+
|
|
536
545
|
- Adapters only fire if added to the array
|
|
537
546
|
- Non-blocking (fire-and-forget)
|
|
538
547
|
- No impact on primary OpenTelemetry metrics
|
|
@@ -548,64 +557,60 @@ Add behaviors without modifying adapter code:
|
|
|
548
557
|
```typescript
|
|
549
558
|
import {
|
|
550
559
|
applyMiddleware,
|
|
551
|
-
retryMiddleware,
|
|
552
|
-
samplingMiddleware,
|
|
553
|
-
enrichmentMiddleware,
|
|
554
|
-
loggingMiddleware,
|
|
555
|
-
filterMiddleware,
|
|
556
|
-
transformMiddleware,
|
|
557
|
-
batchingMiddleware,
|
|
558
|
-
rateLimitMiddleware,
|
|
560
|
+
retryMiddleware, // Exponential backoff retry
|
|
561
|
+
samplingMiddleware, // Send only X% of events
|
|
562
|
+
enrichmentMiddleware, // Add fields to events
|
|
563
|
+
loggingMiddleware, // Debug events
|
|
564
|
+
filterMiddleware, // Only send matching events
|
|
565
|
+
transformMiddleware, // Transform events
|
|
566
|
+
batchingMiddleware, // Batch for efficiency
|
|
567
|
+
rateLimitMiddleware, // Throttle requests
|
|
559
568
|
circuitBreakerMiddleware, // Prevent cascading failures
|
|
560
|
-
timeoutMiddleware
|
|
569
|
+
timeoutMiddleware, // Add timeouts
|
|
561
570
|
} from 'autotel-subscribers/middleware';
|
|
562
571
|
```
|
|
563
572
|
|
|
564
573
|
### Examples
|
|
565
574
|
|
|
566
575
|
**Retry with Circuit Breaker:**
|
|
576
|
+
|
|
567
577
|
```typescript
|
|
568
|
-
const subscriber = applyMiddleware(
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
circuitBreakerMiddleware({ failureThreshold: 5, timeout: 60000 })
|
|
573
|
-
]
|
|
574
|
-
);
|
|
578
|
+
const subscriber = applyMiddleware(new PostHogSubscriber({ apiKey: '...' }), [
|
|
579
|
+
retryMiddleware({ maxRetries: 3, delayMs: 1000 }),
|
|
580
|
+
circuitBreakerMiddleware({ failureThreshold: 5, timeout: 60000 }),
|
|
581
|
+
]);
|
|
575
582
|
```
|
|
576
583
|
|
|
577
584
|
**Sample Events (Reduce Costs):**
|
|
585
|
+
|
|
578
586
|
```typescript
|
|
579
587
|
// Only send 10% of events
|
|
580
|
-
const subscriber = applyMiddleware(
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
);
|
|
588
|
+
const subscriber = applyMiddleware(new WebhookSubscriber({ url: '...' }), [
|
|
589
|
+
samplingMiddleware(0.1),
|
|
590
|
+
]);
|
|
584
591
|
```
|
|
585
592
|
|
|
586
593
|
**Enrich Events:**
|
|
594
|
+
|
|
587
595
|
```typescript
|
|
588
|
-
const subscriber = applyMiddleware(
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
...event,
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
}))
|
|
599
|
-
]
|
|
600
|
-
);
|
|
596
|
+
const subscriber = applyMiddleware(adapter, [
|
|
597
|
+
enrichmentMiddleware((event) => ({
|
|
598
|
+
...event,
|
|
599
|
+
attributes: {
|
|
600
|
+
...event.attributes,
|
|
601
|
+
environment: process.env.NODE_ENV,
|
|
602
|
+
timestamp: Date.now(),
|
|
603
|
+
},
|
|
604
|
+
})),
|
|
605
|
+
]);
|
|
601
606
|
```
|
|
602
607
|
|
|
603
608
|
**Batch Events:**
|
|
609
|
+
|
|
604
610
|
```typescript
|
|
605
|
-
const subscriber = applyMiddleware(
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
);
|
|
611
|
+
const subscriber = applyMiddleware(adapter, [
|
|
612
|
+
batchingMiddleware({ batchSize: 100, flushInterval: 5000 }),
|
|
613
|
+
]);
|
|
609
614
|
```
|
|
610
615
|
|
|
611
616
|
---
|
|
@@ -633,6 +638,7 @@ AdapterTestHarness.printResults(results);
|
|
|
633
638
|
```
|
|
634
639
|
|
|
635
640
|
Tests include:
|
|
641
|
+
|
|
636
642
|
- Basic event tracking
|
|
637
643
|
- Funnel tracking
|
|
638
644
|
- Outcome tracking
|
|
@@ -693,7 +699,7 @@ import {
|
|
|
693
699
|
import {
|
|
694
700
|
AdapterTestHarness,
|
|
695
701
|
MockWebhookServer,
|
|
696
|
-
MockEventSubscriber
|
|
702
|
+
MockEventSubscriber,
|
|
697
703
|
} from 'autotel-subscribers/testing';
|
|
698
704
|
|
|
699
705
|
// For outbox pattern, see autotel-outbox package
|
|
@@ -720,5 +726,3 @@ See the [autotel-examples](https://github.com/jagreehal/autotel/tree/main/packag
|
|
|
720
726
|
## License
|
|
721
727
|
|
|
722
728
|
Apache-2.0 © [Jag Reehal](https://jagreehal.com)
|
|
723
|
-
|
|
724
|
-
|
package/dist/amplitude.cjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_rolldown_runtime = require('./rolldown-runtime-CfAboj1T.cjs');
|
|
3
2
|
|
|
4
3
|
//#region src/amplitude.ts
|
|
5
4
|
var AmplitudeSubscriber = class {
|
|
@@ -16,7 +15,7 @@ var AmplitudeSubscriber = class {
|
|
|
16
15
|
}
|
|
17
16
|
async initialize() {
|
|
18
17
|
try {
|
|
19
|
-
const amplitude = await
|
|
18
|
+
const amplitude = await import("@amplitude/analytics-node");
|
|
20
19
|
amplitude.init(this.config.apiKey);
|
|
21
20
|
this.amplitudeModule = amplitude;
|
|
22
21
|
} catch (error) {
|
package/dist/amplitude.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amplitude.cjs","names":[],"sources":["../src/amplitude.ts"],"sourcesContent":["/**\n * Amplitude Subscriber for autotel\n *\n * Send events to Amplitude for product events.\n *\n * @example\n * ```typescript\n * import {
|
|
1
|
+
{"version":3,"file":"amplitude.cjs","names":[],"sources":["../src/amplitude.ts"],"sourcesContent":["/**\n * Amplitude Subscriber for autotel\n *\n * Send events to Amplitude for product events.\n *\n * @example\n * ```typescript\n * import { Event } from 'autotel/event';\n * import { AmplitudeSubscriber } from 'autotel-subscribers/amplitude';\n *\n * const events = new Event('checkout', {\n * subscribers: [\n * new AmplitudeSubscriber({\n * apiKey: process.env.AMPLITUDE_API_KEY!\n * })\n * ]\n * });\n *\n * events.trackEvent('order.completed', { userId: '123', amount: 99.99 });\n * ```\n */\n\nimport type {\n EventSubscriber,\n EventAttributes,\n FunnelStatus,\n OutcomeStatus,\n} from 'autotel/event-subscriber';\n\nexport interface AmplitudeConfig {\n /** Amplitude API key */\n apiKey: string;\n /** Enable/disable the subscriber */\n enabled?: boolean;\n}\n\nexport class AmplitudeSubscriber implements EventSubscriber {\n readonly name = 'AmplitudeSubscriber';\n readonly version = '1.0.0';\n\n private amplitudeModule: any = null;\n private enabled: boolean;\n private config: AmplitudeConfig;\n private initPromise: Promise<void> | null = null;\n\n constructor(config: AmplitudeConfig) {\n this.enabled = config.enabled ?? true;\n this.config = config;\n\n if (this.enabled) {\n // Start initialization immediately but don't block constructor\n this.initPromise = this.initialize();\n }\n }\n\n private async initialize(): Promise<void> {\n try {\n // Dynamic import to avoid adding @amplitude/analytics-node as a hard dependency\n // The SDK exports init(), track(), flush() as separate functions\n const amplitude = await import('@amplitude/analytics-node');\n amplitude.init(this.config.apiKey);\n this.amplitudeModule = amplitude;\n } catch (error) {\n console.error(\n 'Amplitude subscriber failed to initialize. Install @amplitude/analytics-node: pnpm add @amplitude/analytics-node',\n error,\n );\n this.enabled = false;\n }\n }\n\n private async ensureInitialized(): Promise<void> {\n if (this.initPromise) {\n await this.initPromise;\n this.initPromise = null;\n }\n }\n\n async trackEvent(name: string, attributes?: EventAttributes): Promise<void> {\n if (!this.enabled) return;\n\n await this.ensureInitialized();\n this.amplitudeModule?.track({\n event_type: name,\n user_id: attributes?.userId || attributes?.user_id || 'anonymous',\n event_properties: attributes,\n });\n }\n\n async trackFunnelStep(\n funnelName: string,\n step: FunnelStatus,\n attributes?: EventAttributes,\n ): Promise<void> {\n if (!this.enabled) return;\n\n await this.ensureInitialized();\n this.amplitudeModule?.track({\n event_type: `${funnelName}.${step}`,\n user_id: attributes?.userId || attributes?.user_id || 'anonymous',\n event_properties: {\n funnel: funnelName,\n step,\n ...attributes,\n },\n });\n }\n\n async trackOutcome(\n operationName: string,\n outcome: OutcomeStatus,\n attributes?: EventAttributes,\n ): Promise<void> {\n if (!this.enabled) return;\n\n await this.ensureInitialized();\n this.amplitudeModule?.track({\n event_type: `${operationName}.${outcome}`,\n user_id: attributes?.userId || attributes?.user_id || 'anonymous',\n event_properties: {\n operation: operationName,\n outcome,\n ...attributes,\n },\n });\n }\n\n async trackValue(\n name: string,\n value: number,\n attributes?: EventAttributes,\n ): Promise<void> {\n if (!this.enabled) return;\n\n await this.ensureInitialized();\n this.amplitudeModule?.track({\n event_type: name,\n user_id: attributes?.userId || attributes?.user_id || 'anonymous',\n event_properties: {\n value,\n ...attributes,\n },\n });\n }\n\n /** Flush pending events before shutdown */\n async shutdown(): Promise<void> {\n await this.ensureInitialized();\n if (this.amplitudeModule) {\n await this.amplitudeModule.flush();\n }\n }\n}\n"],"mappings":";;;AAoCA,IAAa,sBAAb,MAA4D;CAC1D,AAAS,OAAO;CAChB,AAAS,UAAU;CAEnB,AAAQ,kBAAuB;CAC/B,AAAQ;CACR,AAAQ;CACR,AAAQ,cAAoC;CAE5C,YAAY,QAAyB;EACnC,KAAK,UAAU,OAAO,WAAW;EACjC,KAAK,SAAS;EAEd,IAAI,KAAK,SAEP,KAAK,cAAc,KAAK,WAAW;CAEvC;CAEA,MAAc,aAA4B;EACxC,IAAI;GAGF,MAAM,YAAY,MAAM,OAAO;GAC/B,UAAU,KAAK,KAAK,OAAO,MAAM;GACjC,KAAK,kBAAkB;EACzB,SAAS,OAAO;GACd,QAAQ,MACN,oHACA,KACF;GACA,KAAK,UAAU;EACjB;CACF;CAEA,MAAc,oBAAmC;EAC/C,IAAI,KAAK,aAAa;GACpB,MAAM,KAAK;GACX,KAAK,cAAc;EACrB;CACF;CAEA,MAAM,WAAW,MAAc,YAA6C;EAC1E,IAAI,CAAC,KAAK,SAAS;EAEnB,MAAM,KAAK,kBAAkB;EAC7B,KAAK,iBAAiB,MAAM;GAC1B,YAAY;GACZ,SAAS,YAAY,UAAU,YAAY,WAAW;GACtD,kBAAkB;EACpB,CAAC;CACH;CAEA,MAAM,gBACJ,YACA,MACA,YACe;EACf,IAAI,CAAC,KAAK,SAAS;EAEnB,MAAM,KAAK,kBAAkB;EAC7B,KAAK,iBAAiB,MAAM;GAC1B,YAAY,GAAG,WAAW,GAAG;GAC7B,SAAS,YAAY,UAAU,YAAY,WAAW;GACtD,kBAAkB;IAChB,QAAQ;IACR;IACA,GAAG;GACL;EACF,CAAC;CACH;CAEA,MAAM,aACJ,eACA,SACA,YACe;EACf,IAAI,CAAC,KAAK,SAAS;EAEnB,MAAM,KAAK,kBAAkB;EAC7B,KAAK,iBAAiB,MAAM;GAC1B,YAAY,GAAG,cAAc,GAAG;GAChC,SAAS,YAAY,UAAU,YAAY,WAAW;GACtD,kBAAkB;IAChB,WAAW;IACX;IACA,GAAG;GACL;EACF,CAAC;CACH;CAEA,MAAM,WACJ,MACA,OACA,YACe;EACf,IAAI,CAAC,KAAK,SAAS;EAEnB,MAAM,KAAK,kBAAkB;EAC7B,KAAK,iBAAiB,MAAM;GAC1B,YAAY;GACZ,SAAS,YAAY,UAAU,YAAY,WAAW;GACtD,kBAAkB;IAChB;IACA,GAAG;GACL;EACF,CAAC;CACH;;CAGA,MAAM,WAA0B;EAC9B,MAAM,KAAK,kBAAkB;EAC7B,IAAI,KAAK,iBACP,MAAM,KAAK,gBAAgB,MAAM;CAErC;AACF"}
|
package/dist/amplitude.d.cts
CHANGED
package/dist/amplitude.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amplitude.d.cts","names":[],"sources":["../src/amplitude.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"amplitude.d.cts","names":[],"sources":["../src/amplitude.ts"],"mappings":";;UA6BiB;;EAEf;;EAEA;;cAGW,+BAA+B;WACjC;WACA;UAED;UACA;UACA;UACA;EAEI,YAAA,QAAQ;UAUN;UAgBA;EAOR,WAAW,cAAc,aAAa,kBAAkB;EAWxD,gBACJ,oBACA,MAAM,cACN,aAAa,kBACZ;EAeG,aACJ,uBACA,SAAS,eACT,aAAa,kBACZ;EAeG,WACJ,cACA,eACA,aAAa,kBACZ;;EAeG,YAAY"}
|
package/dist/amplitude.d.ts
CHANGED
package/dist/amplitude.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amplitude.d.ts","names":[],"sources":["../src/amplitude.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"amplitude.d.ts","names":[],"sources":["../src/amplitude.ts"],"mappings":";;UA6BiB;;EAEf;;EAEA;;cAGW,+BAA+B;WACjC;WACA;UAED;UACA;UACA;UACA;EAEI,YAAA,QAAQ;UAUN;UAgBA;EAOR,WAAW,cAAc,aAAa,kBAAkB;EAWxD,gBACJ,oBACA,MAAM,cACN,aAAa,kBACZ;EAeG,aACJ,uBACA,SAAS,eACT,aAAa,kBACZ;EAeG,WACJ,cACA,eACA,aAAa,kBACZ;;EAeG,YAAY"}
|
package/dist/amplitude.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { o as __toESM } from "./rolldown-runtime-BHkdefai.js";
|
|
2
|
-
|
|
3
1
|
//#region src/amplitude.ts
|
|
4
2
|
var AmplitudeSubscriber = class {
|
|
5
3
|
name = "AmplitudeSubscriber";
|
|
@@ -15,7 +13,7 @@ var AmplitudeSubscriber = class {
|
|
|
15
13
|
}
|
|
16
14
|
async initialize() {
|
|
17
15
|
try {
|
|
18
|
-
const amplitude = await import("
|
|
16
|
+
const amplitude = await import("@amplitude/analytics-node");
|
|
19
17
|
amplitude.init(this.config.apiKey);
|
|
20
18
|
this.amplitudeModule = amplitude;
|
|
21
19
|
} catch (error) {
|
package/dist/amplitude.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amplitude.js","names":[],"sources":["../src/amplitude.ts"],"sourcesContent":["/**\n * Amplitude Subscriber for autotel\n *\n * Send events to Amplitude for product events.\n *\n * @example\n * ```typescript\n * import {
|
|
1
|
+
{"version":3,"file":"amplitude.js","names":[],"sources":["../src/amplitude.ts"],"sourcesContent":["/**\n * Amplitude Subscriber for autotel\n *\n * Send events to Amplitude for product events.\n *\n * @example\n * ```typescript\n * import { Event } from 'autotel/event';\n * import { AmplitudeSubscriber } from 'autotel-subscribers/amplitude';\n *\n * const events = new Event('checkout', {\n * subscribers: [\n * new AmplitudeSubscriber({\n * apiKey: process.env.AMPLITUDE_API_KEY!\n * })\n * ]\n * });\n *\n * events.trackEvent('order.completed', { userId: '123', amount: 99.99 });\n * ```\n */\n\nimport type {\n EventSubscriber,\n EventAttributes,\n FunnelStatus,\n OutcomeStatus,\n} from 'autotel/event-subscriber';\n\nexport interface AmplitudeConfig {\n /** Amplitude API key */\n apiKey: string;\n /** Enable/disable the subscriber */\n enabled?: boolean;\n}\n\nexport class AmplitudeSubscriber implements EventSubscriber {\n readonly name = 'AmplitudeSubscriber';\n readonly version = '1.0.0';\n\n private amplitudeModule: any = null;\n private enabled: boolean;\n private config: AmplitudeConfig;\n private initPromise: Promise<void> | null = null;\n\n constructor(config: AmplitudeConfig) {\n this.enabled = config.enabled ?? true;\n this.config = config;\n\n if (this.enabled) {\n // Start initialization immediately but don't block constructor\n this.initPromise = this.initialize();\n }\n }\n\n private async initialize(): Promise<void> {\n try {\n // Dynamic import to avoid adding @amplitude/analytics-node as a hard dependency\n // The SDK exports init(), track(), flush() as separate functions\n const amplitude = await import('@amplitude/analytics-node');\n amplitude.init(this.config.apiKey);\n this.amplitudeModule = amplitude;\n } catch (error) {\n console.error(\n 'Amplitude subscriber failed to initialize. Install @amplitude/analytics-node: pnpm add @amplitude/analytics-node',\n error,\n );\n this.enabled = false;\n }\n }\n\n private async ensureInitialized(): Promise<void> {\n if (this.initPromise) {\n await this.initPromise;\n this.initPromise = null;\n }\n }\n\n async trackEvent(name: string, attributes?: EventAttributes): Promise<void> {\n if (!this.enabled) return;\n\n await this.ensureInitialized();\n this.amplitudeModule?.track({\n event_type: name,\n user_id: attributes?.userId || attributes?.user_id || 'anonymous',\n event_properties: attributes,\n });\n }\n\n async trackFunnelStep(\n funnelName: string,\n step: FunnelStatus,\n attributes?: EventAttributes,\n ): Promise<void> {\n if (!this.enabled) return;\n\n await this.ensureInitialized();\n this.amplitudeModule?.track({\n event_type: `${funnelName}.${step}`,\n user_id: attributes?.userId || attributes?.user_id || 'anonymous',\n event_properties: {\n funnel: funnelName,\n step,\n ...attributes,\n },\n });\n }\n\n async trackOutcome(\n operationName: string,\n outcome: OutcomeStatus,\n attributes?: EventAttributes,\n ): Promise<void> {\n if (!this.enabled) return;\n\n await this.ensureInitialized();\n this.amplitudeModule?.track({\n event_type: `${operationName}.${outcome}`,\n user_id: attributes?.userId || attributes?.user_id || 'anonymous',\n event_properties: {\n operation: operationName,\n outcome,\n ...attributes,\n },\n });\n }\n\n async trackValue(\n name: string,\n value: number,\n attributes?: EventAttributes,\n ): Promise<void> {\n if (!this.enabled) return;\n\n await this.ensureInitialized();\n this.amplitudeModule?.track({\n event_type: name,\n user_id: attributes?.userId || attributes?.user_id || 'anonymous',\n event_properties: {\n value,\n ...attributes,\n },\n });\n }\n\n /** Flush pending events before shutdown */\n async shutdown(): Promise<void> {\n await this.ensureInitialized();\n if (this.amplitudeModule) {\n await this.amplitudeModule.flush();\n }\n }\n}\n"],"mappings":";AAoCA,IAAa,sBAAb,MAA4D;CAC1D,AAAS,OAAO;CAChB,AAAS,UAAU;CAEnB,AAAQ,kBAAuB;CAC/B,AAAQ;CACR,AAAQ;CACR,AAAQ,cAAoC;CAE5C,YAAY,QAAyB;EACnC,KAAK,UAAU,OAAO,WAAW;EACjC,KAAK,SAAS;EAEd,IAAI,KAAK,SAEP,KAAK,cAAc,KAAK,WAAW;CAEvC;CAEA,MAAc,aAA4B;EACxC,IAAI;GAGF,MAAM,YAAY,MAAM,OAAO;GAC/B,UAAU,KAAK,KAAK,OAAO,MAAM;GACjC,KAAK,kBAAkB;EACzB,SAAS,OAAO;GACd,QAAQ,MACN,oHACA,KACF;GACA,KAAK,UAAU;EACjB;CACF;CAEA,MAAc,oBAAmC;EAC/C,IAAI,KAAK,aAAa;GACpB,MAAM,KAAK;GACX,KAAK,cAAc;EACrB;CACF;CAEA,MAAM,WAAW,MAAc,YAA6C;EAC1E,IAAI,CAAC,KAAK,SAAS;EAEnB,MAAM,KAAK,kBAAkB;EAC7B,KAAK,iBAAiB,MAAM;GAC1B,YAAY;GACZ,SAAS,YAAY,UAAU,YAAY,WAAW;GACtD,kBAAkB;EACpB,CAAC;CACH;CAEA,MAAM,gBACJ,YACA,MACA,YACe;EACf,IAAI,CAAC,KAAK,SAAS;EAEnB,MAAM,KAAK,kBAAkB;EAC7B,KAAK,iBAAiB,MAAM;GAC1B,YAAY,GAAG,WAAW,GAAG;GAC7B,SAAS,YAAY,UAAU,YAAY,WAAW;GACtD,kBAAkB;IAChB,QAAQ;IACR;IACA,GAAG;GACL;EACF,CAAC;CACH;CAEA,MAAM,aACJ,eACA,SACA,YACe;EACf,IAAI,CAAC,KAAK,SAAS;EAEnB,MAAM,KAAK,kBAAkB;EAC7B,KAAK,iBAAiB,MAAM;GAC1B,YAAY,GAAG,cAAc,GAAG;GAChC,SAAS,YAAY,UAAU,YAAY,WAAW;GACtD,kBAAkB;IAChB,WAAW;IACX;IACA,GAAG;GACL;EACF,CAAC;CACH;CAEA,MAAM,WACJ,MACA,OACA,YACe;EACf,IAAI,CAAC,KAAK,SAAS;EAEnB,MAAM,KAAK,kBAAkB;EAC7B,KAAK,iBAAiB,MAAM;GAC1B,YAAY;GACZ,SAAS,YAAY,UAAU,YAAY,WAAW;GACtD,kBAAkB;IAChB;IACA,GAAG;GACL;EACF,CAAC;CACH;;CAGA,MAAM,WAA0B;EAC9B,MAAM,KAAK,kBAAkB;EAC7B,IAAI,KAAK,iBACP,MAAM,KAAK,gBAAgB,MAAM;CAErC;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_rolldown_runtime = require('./rolldown-runtime-
|
|
2
|
+
const require_rolldown_runtime = require('./rolldown-runtime-C_NdSu1c.cjs');
|
|
3
3
|
const require_event_subscriber_base = require('./event-subscriber-base-C_F3Ycbe.cjs');
|
|
4
4
|
let node_fs_promises = require("node:fs/promises");
|
|
5
5
|
node_fs_promises = require_rolldown_runtime.__toESM(node_fs_promises, 1);
|