Event Subscribers
autotel-subscribers sends events to multiple product analytics platforms simultaneously.
Track once, send everywhere:
- Primary metrics → OpenTelemetry
- Product events → PostHog / Mixpanel / Amplitude
- Customer data → Segment
- Custom integrations → Webhooks
Installation
Section titled “Installation”npm install autotel autotel-subscribersnpm install posthog-node # For PostHognpm install mixpanel # For MixpanelQuick Start
Section titled “Quick Start”import { init, track } from 'autotel';import { PostHogSubscriber } from 'autotel-subscribers/posthog';
init({ service: 'my-app', events: { subscribers: [new PostHogSubscriber({ apiKey: process.env.POSTHOG_KEY! })], },});
track('user.signup', { userId: '123', plan: 'pro' });Built-in Subscribers
Section titled “Built-in Subscribers”| Subscriber | Import |
| ----------------------- | -------------------------------------------- |
| PostHog | autotel-subscribers/posthog |
| Mixpanel | autotel-subscribers/mixpanel |
| Segment | autotel-subscribers/segment |
| Amplitude | autotel-subscribers/amplitude |
| Webhook | autotel-subscribers/webhook |
| Slack | autotel-subscribers/slack |
| ArchitectureSnapshot | autotel-subscribers/architecture-snapshot |
ArchitectureSnapshotSubscriber
Section titled “ArchitectureSnapshotSubscriber”Records every event your code emits — names, field paths, runtime types,
sample values, producer/consumer edges — into a single snapshot. The
output feeds autotel-eventcatalog
to diff what production does against what your EventCatalog says it does.
import { init } from 'autotel';import { ArchitectureSnapshotSubscriber } from 'autotel-subscribers/architecture-snapshot';
const snapshot = new ArchitectureSnapshotSubscriber({ service: 'my-app' });
init({ service: 'my-app', subscribers: [snapshot] });
// ...run integration tests, then persist the snapshot...await writeFile('snapshot.json', JSON.stringify(snapshot.toSnapshot(), null, 2));For each tracked event the snapshot includes fieldStats — observed
runtime types and sampled primitive values per dotted field path — which
powers type-drift and value-drift detection downstream.
Custom Subscriber
Section titled “Custom Subscriber”import { EventSubscriber, EventPayload } from 'autotel-subscribers';
class MySubscriber extends EventSubscriber { readonly name = 'MySubscriber';
protected async sendToDestination(payload: EventPayload): Promise<void> { await fetch('https://api.example.com/events', { method: 'POST', body: JSON.stringify(payload), }); }}Middleware
Section titled “Middleware”import { applyMiddleware, retryMiddleware, samplingMiddleware, enrichmentMiddleware,} from 'autotel-subscribers/middleware';
const subscriber = applyMiddleware( new MySubscriber(), retryMiddleware({ maxRetries: 3 }), samplingMiddleware({ rate: 0.5 }), enrichmentMiddleware({ region: 'us-east-1' }),);Examples
Section titled “Examples”example-subscribers— PostHog, Slack, and webhook subscribers with event filtering and funnel tracking.
Entry Points
Section titled “Entry Points”autotel-subscribers— Base class + re-exportsautotel-subscribers/posthog— PostHogautotel-subscribers/mixpanel— Mixpanelautotel-subscribers/segment— Segmentautotel-subscribers/amplitude— Amplitudeautotel-subscribers/webhook— Webhookautotel-subscribers/slack— Slackautotel-subscribers/architecture-snapshot— Architecture snapshot for drift detectionautotel-subscribers/middleware— Middleware compositionautotel-subscribers/testing— Test harnesses