autotel-subscribers 49.0.0 → 50.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 CHANGED
@@ -2,14 +2,16 @@
2
2
 
3
3
  **Send events to multiple platforms**
4
4
 
5
- Subscribers for [autotel](https://github.com/jagreehal/autotel) to send events to PostHog, Mixpanel, Amplitude, Segment, and custom webhooks.
5
+ Subscribers for [autotel](https://github.com/jagreehal/autotel) to send events to Mixpanel, Amplitude, Segment, Slack, Loki, files, and custom webhooks.
6
+
7
+ > **PostHog moved.** `PostHogSubscriber` now lives in [`autotel-posthog`](../autotel-posthog), alongside the browser session/replay join, so one package covers PostHog end to end. Import it from `autotel-posthog/subscriber`; it still extends the `EventSubscriber` base defined here.
6
8
 
7
9
  ## Why Use This?
8
10
 
9
11
  **Track once, send everywhere:**
10
12
 
11
13
  - Primary metrics → **OpenTelemetry** (infrastructure monitoring)
12
- - Product events → **PostHog / Mixpanel / Amplitude**
14
+ - Product events → **Mixpanel / Amplitude / Segment**
13
15
  - Customer data → **Segment**
14
16
  - Custom integrations → **Webhooks** (Zapier, Make.com, etc.)
15
17
 
@@ -98,7 +100,7 @@ Import subscribers directly from their entry points:
98
100
 
99
101
  ```typescript
100
102
  import { Event } from 'autotel/event';
101
- import { PostHogSubscriber } from 'autotel-subscribers/posthog';
103
+ import { PostHogSubscriber } from 'autotel-posthog/subscriber';
102
104
  import { WebhookSubscriber } from 'autotel-subscribers/webhook';
103
105
 
104
106
  const events = new Event('checkout', {
@@ -181,7 +183,7 @@ const subscriber = applyMiddleware(new MySubscriber('api-key'), [
181
183
 
182
184
  ```typescript
183
185
  import { Event } from 'autotel/event';
184
- import { PostHogSubscriber } from 'autotel-subscribers/posthog';
186
+ import { PostHogSubscriber } from 'autotel-posthog/subscriber';
185
187
 
186
188
  const events = new Event('checkout', {
187
189
  subscribers: [
@@ -309,7 +311,7 @@ Send to **multiple platforms simultaneously**:
309
311
 
310
312
  ```typescript
311
313
  import { Event } from 'autotel/event';
312
- import { PostHogSubscriber } from 'autotel-subscribers/posthog';
314
+ import { PostHogSubscriber } from 'autotel-posthog/subscriber';
313
315
  import { MixpanelSubscriber } from 'autotel-subscribers/mixpanel';
314
316
  import { SegmentSubscriber } from 'autotel-subscribers/segment';
315
317
 
@@ -390,7 +392,7 @@ npm install autotel-outbox
390
392
 
391
393
  ```typescript
392
394
  import { OutboxEventSubscriber } from 'autotel-outbox';
393
- import { PostHogSubscriber } from 'autotel-subscribers/posthog';
395
+ import { PostHogSubscriber } from 'autotel-posthog/subscriber';
394
396
 
395
397
  const outbox = new DrizzleD1OutboxStorage(env.DB);
396
398
  const events = new Event('checkout', {
@@ -520,7 +522,7 @@ Adapters are **fully tree-shakeable**:
520
522
 
521
523
  ```typescript
522
524
  // Only PostHog code is bundled (not Mixpanel, Segment, etc.)
523
- import { PostHogSubscriber } from 'autotel-subscribers/posthog';
525
+ import { PostHogSubscriber } from 'autotel-posthog/subscriber';
524
526
  ```
525
527
 
526
528
  Bundle sizes (gzipped):
@@ -676,7 +678,7 @@ All exports available:
676
678
 
677
679
  ```typescript
678
680
  // Import subscribers from their specific entry points
679
- import { PostHogSubscriber } from 'autotel-subscribers/posthog';
681
+ import { PostHogSubscriber } from 'autotel-posthog/subscriber';
680
682
  import { MixpanelSubscriber } from 'autotel-subscribers/mixpanel';
681
683
  import { SegmentSubscriber } from 'autotel-subscribers/segment';
682
684
  import { AmplitudeSubscriber } from 'autotel-subscribers/amplitude';
@@ -8,36 +8,6 @@ node_path = require_rolldown_runtime.__toESM(node_path, 1);
8
8
 
9
9
  //#region src/architecture-snapshot.ts
10
10
  /**
11
- * ArchitectureSnapshotSubscriber
12
- *
13
- * Captures `track()` events into an in-memory architecture snapshot, then
14
- * writes it to disk. The snapshot is the input to `autotel-eventcatalog`'s
15
- * generator and is designed to be deterministic, reviewable, and committable.
16
- *
17
- * v0 scope: capture event names, observation counts, first/last-seen, sample
18
- * trace IDs, and the dotted field paths present in payloads. Producer /
19
- * consumer / channel attribution is read from a small `_autotel.*` convention
20
- * inside event attributes — that convention is documented in
21
- * `apps/example-eventcatalog`.
22
- *
23
- * @example
24
- * ```typescript
25
- * import { init, track } from 'autotel';
26
- * import { ArchitectureSnapshotSubscriber } from 'autotel-subscribers/architecture';
27
- *
28
- * const snapshot = new ArchitectureSnapshotSubscriber({ service: 'orders' });
29
- *
30
- * init({
31
- * service: 'orders',
32
- * subscribers: [snapshot],
33
- * });
34
- *
35
- * // ... exercise the system (run integration tests, hit endpoints, etc.) ...
36
- *
37
- * await snapshot.writeToFile('./.autotel/snapshot.json');
38
- * ```
39
- */
40
- /**
41
11
  * Public, versioned snapshot format. The generator and any downstream tooling
42
12
  * target this spec. Bumping the spec version is a breaking change for
43
13
  * downstream consumers, so add fields rather than rename existing ones.
@@ -256,21 +226,21 @@ function classifyValueType(value) {
256
226
  return typeof value;
257
227
  }
258
228
  function mergeFieldStats(a, b) {
259
- const merged = { ...a };
229
+ const merged = new Map(Object.entries(a));
260
230
  for (const [path, bs] of Object.entries(b)) {
261
- const prev = merged[path];
231
+ const prev = merged.get(path);
262
232
  if (!prev) {
263
- merged[path] = bs;
233
+ merged.set(path, bs);
264
234
  continue;
265
235
  }
266
236
  const types = /* @__PURE__ */ new Set([...prev.types, ...bs.types]);
267
237
  const sampleValues = /* @__PURE__ */ new Set([...prev.sampleValues, ...bs.sampleValues]);
268
- merged[path] = {
238
+ merged.set(path, {
269
239
  types: [...types].toSorted(),
270
240
  sampleValues: [...sampleValues].toSorted(comparePrimitiveValues).slice(0, 20)
271
- };
241
+ });
272
242
  }
273
- return merged;
243
+ return Object.fromEntries(merged);
274
244
  }
275
245
  function sortFieldStats(stats) {
276
246
  if (!stats) return void 0;
@@ -4,36 +4,6 @@ import path from "node:path";
4
4
 
5
5
  //#region src/architecture-snapshot.ts
6
6
  /**
7
- * ArchitectureSnapshotSubscriber
8
- *
9
- * Captures `track()` events into an in-memory architecture snapshot, then
10
- * writes it to disk. The snapshot is the input to `autotel-eventcatalog`'s
11
- * generator and is designed to be deterministic, reviewable, and committable.
12
- *
13
- * v0 scope: capture event names, observation counts, first/last-seen, sample
14
- * trace IDs, and the dotted field paths present in payloads. Producer /
15
- * consumer / channel attribution is read from a small `_autotel.*` convention
16
- * inside event attributes — that convention is documented in
17
- * `apps/example-eventcatalog`.
18
- *
19
- * @example
20
- * ```typescript
21
- * import { init, track } from 'autotel';
22
- * import { ArchitectureSnapshotSubscriber } from 'autotel-subscribers/architecture';
23
- *
24
- * const snapshot = new ArchitectureSnapshotSubscriber({ service: 'orders' });
25
- *
26
- * init({
27
- * service: 'orders',
28
- * subscribers: [snapshot],
29
- * });
30
- *
31
- * // ... exercise the system (run integration tests, hit endpoints, etc.) ...
32
- *
33
- * await snapshot.writeToFile('./.autotel/snapshot.json');
34
- * ```
35
- */
36
- /**
37
7
  * Public, versioned snapshot format. The generator and any downstream tooling
38
8
  * target this spec. Bumping the spec version is a breaking change for
39
9
  * downstream consumers, so add fields rather than rename existing ones.
@@ -252,21 +222,21 @@ function classifyValueType(value) {
252
222
  return typeof value;
253
223
  }
254
224
  function mergeFieldStats(a, b) {
255
- const merged = { ...a };
225
+ const merged = new Map(Object.entries(a));
256
226
  for (const [path, bs] of Object.entries(b)) {
257
- const prev = merged[path];
227
+ const prev = merged.get(path);
258
228
  if (!prev) {
259
- merged[path] = bs;
229
+ merged.set(path, bs);
260
230
  continue;
261
231
  }
262
232
  const types = /* @__PURE__ */ new Set([...prev.types, ...bs.types]);
263
233
  const sampleValues = /* @__PURE__ */ new Set([...prev.sampleValues, ...bs.sampleValues]);
264
- merged[path] = {
234
+ merged.set(path, {
265
235
  types: [...types].toSorted(),
266
236
  sampleValues: [...sampleValues].toSorted(comparePrimitiveValues).slice(0, 20)
267
- };
237
+ });
268
238
  }
269
- return merged;
239
+ return Object.fromEntries(merged);
270
240
  }
271
241
  function sortFieldStats(stats) {
272
242
  if (!stats) return void 0;
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_posthog = require('./posthog-DOOBZanH.cjs');
3
2
  const require_mixpanel = require('./mixpanel.cjs');
4
3
  const require_segment = require('./segment.cjs');
5
4
  const require_amplitude = require('./amplitude.cjs');
@@ -158,20 +157,15 @@ var MockEventSubscriber = class {
158
157
  *
159
158
  * @example
160
159
  * ```typescript
161
- * import { createPostHogSubscriber, createWebhookSubscriber } from 'autotel-subscribers/factories'
160
+ * import { createMixpanelSubscriber, createWebhookSubscriber } from 'autotel-subscribers/factories'
162
161
  *
163
162
  * const events = new Event('my-service', {
164
163
  * subscribers: [
165
- * createPostHogSubscriber({ apiKey: 'phc_...' }),
166
164
  * createWebhookSubscriber({ url: 'https://...' })
167
165
  * ]
168
166
  * })
169
167
  * ```
170
168
  */
171
- /** Create a PostHog events subscriber */
172
- function createPostHogSubscriber(config) {
173
- return new require_posthog.PostHogSubscriber(config);
174
- }
175
169
  /** Create a Mixpanel events subscriber */
176
170
  function createMixpanelSubscriber(config) {
177
171
  return new require_mixpanel.MixpanelSubscriber(config);
@@ -202,15 +196,15 @@ function backoffDelay(attempt, initialMs, maxMs) {
202
196
  async function callSubscriber(subscriber, call) {
203
197
  switch (call.method) {
204
198
  case "trackEvent":
205
- await subscriber.trackEvent(call.args[0], call.args[1], call.args[2]);
199
+ await subscriber.trackEvent(...call.args);
206
200
  return;
207
201
  case "trackFunnelStep":
208
- await subscriber.trackFunnelStep(call.args[0], call.args[1], call.args[2], call.args[3]);
202
+ await subscriber.trackFunnelStep(...call.args);
209
203
  return;
210
204
  case "trackOutcome":
211
- await subscriber.trackOutcome(call.args[0], call.args[1], call.args[2], call.args[3]);
205
+ await subscriber.trackOutcome(...call.args);
212
206
  return;
213
- case "trackValue": await subscriber.trackValue(call.args[0], call.args[1], call.args[2], call.args[3]);
207
+ case "trackValue": await subscriber.trackValue(...call.args);
214
208
  }
215
209
  }
216
210
  /**
@@ -220,7 +214,6 @@ async function callSubscriber(subscriber, call) {
220
214
  * ```typescript
221
215
  * const multiSubscriber = composeSubscribers(
222
216
  * [
223
- * createPostHogSubscriber({ apiKey: '...' }),
224
217
  * createWebhookSubscriber({ url: '...' })
225
218
  * ],
226
219
  * { strategy: 'parallel' }
@@ -368,7 +361,6 @@ exports.composeSubscribers = composeSubscribers;
368
361
  exports.createAmplitudeSubscriber = createAmplitudeSubscriber;
369
362
  exports.createMixpanelSubscriber = createMixpanelSubscriber;
370
363
  exports.createMockSubscriber = createMockSubscriber;
371
- exports.createPostHogSubscriber = createPostHogSubscriber;
372
364
  exports.createSegmentSubscriber = createSegmentSubscriber;
373
365
  exports.createSlackSubscriber = createSlackSubscriber;
374
366
  exports.createWebhookSubscriber = createWebhookSubscriber;
@@ -1,5 +1,4 @@
1
1
  import { AmplitudeConfig } from "./amplitude.cjs";
2
- import { PostHogConfig } from "./posthog.cjs";
3
2
  import { MixpanelConfig } from "./mixpanel.cjs";
4
3
  import { SegmentConfig } from "./segment.cjs";
5
4
  import { WebhookConfig } from "./webhook.cjs";
@@ -85,12 +84,6 @@ declare class MockEventSubscriber implements EventSubscriber {
85
84
  }
86
85
  //#endregion
87
86
  //#region src/factories.d.ts
88
- /** Create a PostHog events subscriber */
89
- declare function createPostHogSubscriber(config: {
90
- apiKey: string;
91
- host?: string;
92
- enabled?: boolean;
93
- }): EventSubscriber;
94
87
  /** Create a Mixpanel events subscriber */
95
88
  declare function createMixpanelSubscriber(config: {
96
89
  token: string;
@@ -142,7 +135,7 @@ type ComposeSubscribersOptions = {
142
135
  maxAttemptsPerSubscriber?: number;
143
136
  initialRetryDelayMs?: number;
144
137
  maxRetryDelayMs?: number;
145
- isRetriable?: (error: unknown) => boolean;
138
+ isRetriable?: (cause: unknown) => boolean;
146
139
  logger?: Pick<Console, 'debug' | 'warn' | 'error'>;
147
140
  };
148
141
  /**
@@ -152,7 +145,6 @@ type ComposeSubscribersOptions = {
152
145
  * ```typescript
153
146
  * const multiSubscriber = composeSubscribers(
154
147
  * [
155
- * createPostHogSubscriber({ apiKey: '...' }),
156
148
  * createWebhookSubscriber({ url: '...' })
157
149
  * ],
158
150
  * { strategy: 'parallel' }
@@ -165,4 +157,4 @@ type ComposeSubscribersOptions = {
165
157
  */
166
158
  declare function composeSubscribers(subscribers: EventSubscriber[], options?: ComposeSubscribersOptions): EventSubscriber;
167
159
  //#endregion
168
- export { type AmplitudeConfig, ComposeSubscriberStrategy, ComposeSubscribersOptions, type MixpanelConfig, type PostHogConfig, type SegmentConfig, type SlackSubscriberConfig, type WebhookConfig, composeSubscribers, createAmplitudeSubscriber, createMixpanelSubscriber, createMockSubscriber, createPostHogSubscriber, createSegmentSubscriber, createSlackSubscriber, createWebhookSubscriber };
160
+ export { type AmplitudeConfig, ComposeSubscriberStrategy, ComposeSubscribersOptions, type MixpanelConfig, type SegmentConfig, type SlackSubscriberConfig, type WebhookConfig, composeSubscribers, createAmplitudeSubscriber, createMixpanelSubscriber, createMockSubscriber, createSegmentSubscriber, createSlackSubscriber, createWebhookSubscriber };
@@ -1,5 +1,4 @@
1
1
  import { AmplitudeConfig } from "./amplitude.js";
2
- import { PostHogConfig } from "./posthog.js";
3
2
  import { MixpanelConfig } from "./mixpanel.js";
4
3
  import { SegmentConfig } from "./segment.js";
5
4
  import { WebhookConfig } from "./webhook.js";
@@ -85,12 +84,6 @@ declare class MockEventSubscriber implements EventSubscriber {
85
84
  }
86
85
  //#endregion
87
86
  //#region src/factories.d.ts
88
- /** Create a PostHog events subscriber */
89
- declare function createPostHogSubscriber(config: {
90
- apiKey: string;
91
- host?: string;
92
- enabled?: boolean;
93
- }): EventSubscriber;
94
87
  /** Create a Mixpanel events subscriber */
95
88
  declare function createMixpanelSubscriber(config: {
96
89
  token: string;
@@ -142,7 +135,7 @@ type ComposeSubscribersOptions = {
142
135
  maxAttemptsPerSubscriber?: number;
143
136
  initialRetryDelayMs?: number;
144
137
  maxRetryDelayMs?: number;
145
- isRetriable?: (error: unknown) => boolean;
138
+ isRetriable?: (cause: unknown) => boolean;
146
139
  logger?: Pick<Console, 'debug' | 'warn' | 'error'>;
147
140
  };
148
141
  /**
@@ -152,7 +145,6 @@ type ComposeSubscribersOptions = {
152
145
  * ```typescript
153
146
  * const multiSubscriber = composeSubscribers(
154
147
  * [
155
- * createPostHogSubscriber({ apiKey: '...' }),
156
148
  * createWebhookSubscriber({ url: '...' })
157
149
  * ],
158
150
  * { strategy: 'parallel' }
@@ -165,4 +157,4 @@ type ComposeSubscribersOptions = {
165
157
  */
166
158
  declare function composeSubscribers(subscribers: EventSubscriber[], options?: ComposeSubscribersOptions): EventSubscriber;
167
159
  //#endregion
168
- export { type AmplitudeConfig, ComposeSubscriberStrategy, ComposeSubscribersOptions, type MixpanelConfig, type PostHogConfig, type SegmentConfig, type SlackSubscriberConfig, type WebhookConfig, composeSubscribers, createAmplitudeSubscriber, createMixpanelSubscriber, createMockSubscriber, createPostHogSubscriber, createSegmentSubscriber, createSlackSubscriber, createWebhookSubscriber };
160
+ export { type AmplitudeConfig, ComposeSubscriberStrategy, ComposeSubscribersOptions, type MixpanelConfig, type SegmentConfig, type SlackSubscriberConfig, type WebhookConfig, composeSubscribers, createAmplitudeSubscriber, createMixpanelSubscriber, createMockSubscriber, createSegmentSubscriber, createSlackSubscriber, createWebhookSubscriber };
package/dist/factories.js CHANGED
@@ -1,4 +1,3 @@
1
- import { t as PostHogSubscriber } from "./posthog-ByP8BmHb.js";
2
1
  import { MixpanelSubscriber } from "./mixpanel.js";
3
2
  import { SegmentSubscriber } from "./segment.js";
4
3
  import { AmplitudeSubscriber } from "./amplitude.js";
@@ -157,20 +156,15 @@ var MockEventSubscriber = class {
157
156
  *
158
157
  * @example
159
158
  * ```typescript
160
- * import { createPostHogSubscriber, createWebhookSubscriber } from 'autotel-subscribers/factories'
159
+ * import { createMixpanelSubscriber, createWebhookSubscriber } from 'autotel-subscribers/factories'
161
160
  *
162
161
  * const events = new Event('my-service', {
163
162
  * subscribers: [
164
- * createPostHogSubscriber({ apiKey: 'phc_...' }),
165
163
  * createWebhookSubscriber({ url: 'https://...' })
166
164
  * ]
167
165
  * })
168
166
  * ```
169
167
  */
170
- /** Create a PostHog events subscriber */
171
- function createPostHogSubscriber(config) {
172
- return new PostHogSubscriber(config);
173
- }
174
168
  /** Create a Mixpanel events subscriber */
175
169
  function createMixpanelSubscriber(config) {
176
170
  return new MixpanelSubscriber(config);
@@ -201,15 +195,15 @@ function backoffDelay(attempt, initialMs, maxMs) {
201
195
  async function callSubscriber(subscriber, call) {
202
196
  switch (call.method) {
203
197
  case "trackEvent":
204
- await subscriber.trackEvent(call.args[0], call.args[1], call.args[2]);
198
+ await subscriber.trackEvent(...call.args);
205
199
  return;
206
200
  case "trackFunnelStep":
207
- await subscriber.trackFunnelStep(call.args[0], call.args[1], call.args[2], call.args[3]);
201
+ await subscriber.trackFunnelStep(...call.args);
208
202
  return;
209
203
  case "trackOutcome":
210
- await subscriber.trackOutcome(call.args[0], call.args[1], call.args[2], call.args[3]);
204
+ await subscriber.trackOutcome(...call.args);
211
205
  return;
212
- case "trackValue": await subscriber.trackValue(call.args[0], call.args[1], call.args[2], call.args[3]);
206
+ case "trackValue": await subscriber.trackValue(...call.args);
213
207
  }
214
208
  }
215
209
  /**
@@ -219,7 +213,6 @@ async function callSubscriber(subscriber, call) {
219
213
  * ```typescript
220
214
  * const multiSubscriber = composeSubscribers(
221
215
  * [
222
- * createPostHogSubscriber({ apiKey: '...' }),
223
216
  * createWebhookSubscriber({ url: '...' })
224
217
  * ],
225
218
  * { strategy: 'parallel' }
@@ -363,4 +356,4 @@ function composeSubscribers(subscribers, options = {}) {
363
356
  }
364
357
 
365
358
  //#endregion
366
- export { composeSubscribers, createAmplitudeSubscriber, createMixpanelSubscriber, createMockSubscriber, createPostHogSubscriber, createSegmentSubscriber, createSlackSubscriber, createWebhookSubscriber };
359
+ export { composeSubscribers, createAmplitudeSubscriber, createMixpanelSubscriber, createMockSubscriber, createSegmentSubscriber, createSlackSubscriber, createWebhookSubscriber };
package/dist/file.cjs CHANGED
@@ -6,24 +6,6 @@ let node_path = require("node:path");
6
6
  node_path = require_rolldown_runtime.__toESM(node_path, 1);
7
7
 
8
8
  //#region src/file.ts
9
- /**
10
- * File subscriber for autotel.
11
- *
12
- * Appends each tracked event to a file as newline-delimited JSON (NDJSON).
13
- * Useful for AI agents, scripts, evals, and local debugging that want
14
- * structured events on disk without a hosted backend. Query the file with
15
- * `jq`, load it into a notebook, or feed it to an agent.
16
- *
17
- * @example
18
- * ```typescript
19
- * import { Event } from 'autotel/event';
20
- * import { FileSubscriber } from 'autotel-subscribers/file';
21
- *
22
- * const events = new Event('worker', {
23
- * subscribers: [new FileSubscriber({ path: './telemetry/events.ndjson' })],
24
- * });
25
- * ```
26
- */
27
9
  var FileSubscriber = class extends require_event_subscriber_base.EventSubscriber {
28
10
  name = "FileSubscriber";
29
11
  version = "1.0.0";
package/dist/file.d.cts CHANGED
@@ -1,4 +1,5 @@
1
- import { n as EventPayload, r as EventSubscriber } from "./event-subscriber-base-DpZclJM4.cjs";
1
+ import { n as EventPayload, r as EventSubscriber$1 } from "./event-subscriber-base-DpZclJM4.cjs";
2
+ import { EventAttributes } from "autotel/event-subscriber";
2
3
  //#region src/file.d.ts
3
4
  interface FileSubscriberConfig {
4
5
  /** File path to append newline-delimited JSON events to. */
@@ -13,9 +14,9 @@ interface FileSubscriberConfig {
13
14
  * Transform a payload before writing. Return `null` to skip the event.
14
15
  * Defaults to writing the normalized payload unchanged.
15
16
  */
16
- transform?: (payload: EventPayload) => Record<string, unknown> | null;
17
+ transform?: (payload: EventPayload) => EventAttributes | null;
17
18
  }
18
- declare class FileSubscriber extends EventSubscriber {
19
+ declare class FileSubscriber extends EventSubscriber$1 {
19
20
  readonly name = "FileSubscriber";
20
21
  readonly version = "1.0.0";
21
22
  private readonly filePath;
package/dist/file.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { n as EventPayload, r as EventSubscriber } from "./event-subscriber-base-DpZclJM4.js";
1
+ import { n as EventPayload, r as EventSubscriber$1 } from "./event-subscriber-base-DpZclJM4.js";
2
+ import { EventAttributes } from "autotel/event-subscriber";
2
3
  //#region src/file.d.ts
3
4
  interface FileSubscriberConfig {
4
5
  /** File path to append newline-delimited JSON events to. */
@@ -13,9 +14,9 @@ interface FileSubscriberConfig {
13
14
  * Transform a payload before writing. Return `null` to skip the event.
14
15
  * Defaults to writing the normalized payload unchanged.
15
16
  */
16
- transform?: (payload: EventPayload) => Record<string, unknown> | null;
17
+ transform?: (payload: EventPayload) => EventAttributes | null;
17
18
  }
18
- declare class FileSubscriber extends EventSubscriber {
19
+ declare class FileSubscriber extends EventSubscriber$1 {
19
20
  readonly name = "FileSubscriber";
20
21
  readonly version = "1.0.0";
21
22
  private readonly filePath;
package/dist/file.js CHANGED
@@ -3,24 +3,6 @@ import { appendFile, mkdir } from "node:fs/promises";
3
3
  import path from "node:path";
4
4
 
5
5
  //#region src/file.ts
6
- /**
7
- * File subscriber for autotel.
8
- *
9
- * Appends each tracked event to a file as newline-delimited JSON (NDJSON).
10
- * Useful for AI agents, scripts, evals, and local debugging that want
11
- * structured events on disk without a hosted backend. Query the file with
12
- * `jq`, load it into a notebook, or feed it to an agent.
13
- *
14
- * @example
15
- * ```typescript
16
- * import { Event } from 'autotel/event';
17
- * import { FileSubscriber } from 'autotel-subscribers/file';
18
- *
19
- * const events = new Event('worker', {
20
- * subscribers: [new FileSubscriber({ path: './telemetry/events.ndjson' })],
21
- * });
22
- * ```
23
- */
24
6
  var FileSubscriber = class extends EventSubscriber {
25
7
  name = "FileSubscriber";
26
8
  version = "1.0.0";
package/dist/index.cjs CHANGED
@@ -1,9 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_event_subscriber_base = require('./event-subscriber-base-C_F3Ycbe.cjs');
3
- const require_posthog = require('./posthog-DOOBZanH.cjs');
4
2
  const require_mixpanel = require('./mixpanel.cjs');
5
3
  const require_segment = require('./segment.cjs');
6
4
  const require_amplitude = require('./amplitude.cjs');
5
+ const require_event_subscriber_base = require('./event-subscriber-base-C_F3Ycbe.cjs');
7
6
  const require_slack = require('./slack.cjs');
8
7
  const require_security = require('./security.cjs');
9
8
  const require_webhook = require('./webhook.cjs');
@@ -188,7 +187,6 @@ exports.EventSubscriber = require_event_subscriber_base.EventSubscriber;
188
187
  exports.FileSubscriber = require_file.FileSubscriber;
189
188
  exports.LokiSubscriber = require_loki.LokiSubscriber;
190
189
  exports.MixpanelSubscriber = require_mixpanel.MixpanelSubscriber;
191
- exports.PostHogSubscriber = require_posthog.PostHogSubscriber;
192
190
  exports.SecuritySubscriber = require_security.SecuritySubscriber;
193
191
  exports.SegmentSubscriber = require_segment.SegmentSubscriber;
194
192
  exports.SlackSubscriber = require_slack.SlackSubscriber;
package/dist/index.d.cts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { AmplitudeConfig, AmplitudeSubscriber } from "./amplitude.cjs";
2
2
  import { n as EventPayload, r as EventSubscriber } from "./event-subscriber-base-DpZclJM4.cjs";
3
3
  import { ARCHITECTURE_SNAPSHOT_SPEC, ArchitectureSnapshot, ArchitectureSnapshotConfig, ArchitectureSnapshotSubscriber, EventObservation, extractFieldPaths } from "./architecture-snapshot.cjs";
4
- import { PostHogConfig, PostHogSubscriber } from "./posthog.cjs";
5
4
  import { MixpanelConfig, MixpanelSubscriber } from "./mixpanel.cjs";
6
5
  import { SegmentConfig, SegmentSubscriber } from "./segment.cjs";
7
6
  import { WebhookConfig, WebhookSubscriber } from "./webhook.cjs";
@@ -132,4 +131,4 @@ declare abstract class StreamingEventSubscriber extends EventSubscriber {
132
131
  protected compressPayload(payload: string): Promise<Buffer | string>;
133
132
  }
134
133
  //#endregion
135
- export { ARCHITECTURE_SNAPSHOT_SPEC, type AmplitudeConfig, AmplitudeSubscriber, type ArchitectureSnapshot, type ArchitectureSnapshotConfig, ArchitectureSnapshotSubscriber, type EventObservation, type EventPayload, EventSubscriber, FileSubscriber, type FileSubscriberConfig, type LokiConfig, LokiSubscriber, type MixpanelConfig, MixpanelSubscriber, type PostHogConfig, PostHogSubscriber, type SecurityAlert, type SecurityAlertSeverity, SecuritySubscriber, type SecuritySubscriberConfig, type SegmentConfig, SegmentSubscriber, SlackSubscriber, type SlackSubscriberConfig, StreamingEventSubscriber, type WebhookConfig, WebhookSubscriber, extractFieldPaths };
134
+ export { ARCHITECTURE_SNAPSHOT_SPEC, type AmplitudeConfig, AmplitudeSubscriber, type ArchitectureSnapshot, type ArchitectureSnapshotConfig, ArchitectureSnapshotSubscriber, type EventObservation, type EventPayload, EventSubscriber, FileSubscriber, type FileSubscriberConfig, type LokiConfig, LokiSubscriber, type MixpanelConfig, MixpanelSubscriber, type SecurityAlert, type SecurityAlertSeverity, SecuritySubscriber, type SecuritySubscriberConfig, type SegmentConfig, SegmentSubscriber, SlackSubscriber, type SlackSubscriberConfig, StreamingEventSubscriber, type WebhookConfig, WebhookSubscriber, extractFieldPaths };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { AmplitudeConfig, AmplitudeSubscriber } from "./amplitude.js";
2
2
  import { n as EventPayload, r as EventSubscriber } from "./event-subscriber-base-DpZclJM4.js";
3
3
  import { ARCHITECTURE_SNAPSHOT_SPEC, ArchitectureSnapshot, ArchitectureSnapshotConfig, ArchitectureSnapshotSubscriber, EventObservation, extractFieldPaths } from "./architecture-snapshot.js";
4
- import { PostHogConfig, PostHogSubscriber } from "./posthog.js";
5
4
  import { MixpanelConfig, MixpanelSubscriber } from "./mixpanel.js";
6
5
  import { SegmentConfig, SegmentSubscriber } from "./segment.js";
7
6
  import { WebhookConfig, WebhookSubscriber } from "./webhook.js";
@@ -132,4 +131,4 @@ declare abstract class StreamingEventSubscriber extends EventSubscriber {
132
131
  protected compressPayload(payload: string): Promise<Buffer | string>;
133
132
  }
134
133
  //#endregion
135
- export { ARCHITECTURE_SNAPSHOT_SPEC, type AmplitudeConfig, AmplitudeSubscriber, type ArchitectureSnapshot, type ArchitectureSnapshotConfig, ArchitectureSnapshotSubscriber, type EventObservation, type EventPayload, EventSubscriber, FileSubscriber, type FileSubscriberConfig, type LokiConfig, LokiSubscriber, type MixpanelConfig, MixpanelSubscriber, type PostHogConfig, PostHogSubscriber, type SecurityAlert, type SecurityAlertSeverity, SecuritySubscriber, type SecuritySubscriberConfig, type SegmentConfig, SegmentSubscriber, SlackSubscriber, type SlackSubscriberConfig, StreamingEventSubscriber, type WebhookConfig, WebhookSubscriber, extractFieldPaths };
134
+ export { ARCHITECTURE_SNAPSHOT_SPEC, type AmplitudeConfig, AmplitudeSubscriber, type ArchitectureSnapshot, type ArchitectureSnapshotConfig, ArchitectureSnapshotSubscriber, type EventObservation, type EventPayload, EventSubscriber, FileSubscriber, type FileSubscriberConfig, type LokiConfig, LokiSubscriber, type MixpanelConfig, MixpanelSubscriber, type SecurityAlert, type SecurityAlertSeverity, SecuritySubscriber, type SecuritySubscriberConfig, type SegmentConfig, SegmentSubscriber, SlackSubscriber, type SlackSubscriberConfig, StreamingEventSubscriber, type WebhookConfig, WebhookSubscriber, extractFieldPaths };
package/dist/index.js CHANGED
@@ -1,8 +1,7 @@
1
- import { t as EventSubscriber } from "./event-subscriber-base-Day2ml6V.js";
2
- import { t as PostHogSubscriber } from "./posthog-ByP8BmHb.js";
3
1
  import { MixpanelSubscriber } from "./mixpanel.js";
4
2
  import { SegmentSubscriber } from "./segment.js";
5
3
  import { AmplitudeSubscriber } from "./amplitude.js";
4
+ import { t as EventSubscriber } from "./event-subscriber-base-Day2ml6V.js";
6
5
  import { SlackSubscriber } from "./slack.js";
7
6
  import { SecuritySubscriber } from "./security.js";
8
7
  import { WebhookSubscriber } from "./webhook.js";
@@ -180,4 +179,4 @@ var StreamingEventSubscriber = class extends EventSubscriber {
180
179
  };
181
180
 
182
181
  //#endregion
183
- export { ARCHITECTURE_SNAPSHOT_SPEC, AmplitudeSubscriber, ArchitectureSnapshotSubscriber, EventSubscriber, FileSubscriber, LokiSubscriber, MixpanelSubscriber, PostHogSubscriber, SecuritySubscriber, SegmentSubscriber, SlackSubscriber, StreamingEventSubscriber, WebhookSubscriber, extractFieldPaths };
182
+ export { ARCHITECTURE_SNAPSHOT_SPEC, AmplitudeSubscriber, ArchitectureSnapshotSubscriber, EventSubscriber, FileSubscriber, LokiSubscriber, MixpanelSubscriber, SecuritySubscriber, SegmentSubscriber, SlackSubscriber, StreamingEventSubscriber, WebhookSubscriber, extractFieldPaths };
package/dist/loki.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_webhook_delivery = require('./webhook-delivery-DZeUlZhi.cjs');
2
+ const require_webhook_delivery = require('./webhook-delivery-Bet3Uvss.cjs');
3
3
 
4
4
  //#region src/loki.ts
5
5
  /** Push path appended to {@link LokiConfig.endpoint}. */
@@ -38,12 +38,12 @@ function toLokiTimestamp(timestamp) {
38
38
  */
39
39
  function toLokiLabels(event, config = {}) {
40
40
  const fields = config.labelFields ?? [...DEFAULT_LABEL_FIELDS];
41
- const labels = { ...config.labels };
41
+ const labels = new Map(Object.entries(config.labels ?? {}));
42
42
  for (const field of fields) {
43
43
  const value = event[field];
44
- if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") labels[field] = String(value);
44
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") labels.set(field, String(value));
45
45
  }
46
- return labels;
46
+ return Object.fromEntries(labels);
47
47
  }
48
48
  /**
49
49
  * Group events into streams by label set.
@@ -69,11 +69,13 @@ function buildLokiPayload(events, config = {}) {
69
69
  }
70
70
  /** Auth and tenancy headers for a resolved config. */
71
71
  function toLokiHeaders(config) {
72
- const headers = {};
73
- if (config.user && config.apiKey) headers.Authorization = `Basic ${Buffer.from(`${config.user}:${config.apiKey}`).toString("base64")}`;
74
- else if (config.apiKey) headers.Authorization = `Bearer ${config.apiKey}`;
75
- if (config.tenantId) headers["X-Scope-OrgID"] = config.tenantId;
76
- return headers;
72
+ const headers = /* @__PURE__ */ new Map();
73
+ if (config.user && config.apiKey) {
74
+ const encoded = Buffer.from(`${config.user}:${config.apiKey}`).toString("base64");
75
+ headers.set("Authorization", `Basic ${encoded}`);
76
+ } else if (config.apiKey) headers.set("Authorization", `Bearer ${config.apiKey}`);
77
+ if (config.tenantId) headers.set("X-Scope-OrgID", config.tenantId);
78
+ return Object.fromEntries(headers);
77
79
  }
78
80
  /** Push a batch of events without going through a subscriber. */
79
81
  async function sendBatchToLoki(events, config = {}) {
@@ -169,7 +171,7 @@ var LokiSubscriber = class {
169
171
  name,
170
172
  ...attributes,
171
173
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
172
- ...options?.autotel ? { autotel: options.autotel } : {}
174
+ autotel: options?.autotel
173
175
  });
174
176
  }
175
177
  async trackFunnelStep(funnelName, step, attributes, options) {
@@ -179,7 +181,7 @@ var LokiSubscriber = class {
179
181
  step,
180
182
  ...attributes,
181
183
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
182
- ...options?.autotel ? { autotel: options.autotel } : {}
184
+ autotel: options?.autotel
183
185
  });
184
186
  }
185
187
  async trackOutcome(operationName, outcome, attributes, options) {
@@ -189,7 +191,7 @@ var LokiSubscriber = class {
189
191
  outcome,
190
192
  ...attributes,
191
193
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
192
- ...options?.autotel ? { autotel: options.autotel } : {}
194
+ autotel: options?.autotel
193
195
  });
194
196
  }
195
197
  async trackValue(name, value, attributes, options) {
@@ -199,7 +201,7 @@ var LokiSubscriber = class {
199
201
  value,
200
202
  ...attributes,
201
203
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
202
- ...options?.autotel ? { autotel: options.autotel } : {}
204
+ autotel: options?.autotel
203
205
  });
204
206
  }
205
207
  track(request) {
package/dist/loki.d.cts CHANGED
@@ -49,7 +49,7 @@ interface LokiConfig {
49
49
  enabled?: boolean;
50
50
  }
51
51
  /** One event as it is written to the Loki line. */
52
- type LokiEvent = Record<string, unknown> & {
52
+ type LokiEvent = EventAttributes & {
53
53
  timestamp?: string;
54
54
  };
55
55
  interface LokiStream {