Skip to content

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
Terminal window
npm install autotel autotel-subscribers
npm install posthog-node # For PostHog
npm install mixpanel # For Mixpanel
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' });

| 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 |

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.

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),
});
}
}
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' }),
);
  • example-subscribers — PostHog, Slack, and webhook subscribers with event filtering and funnel tracking.
  • autotel-subscribers — Base class + re-exports
  • autotel-subscribers/posthog — PostHog
  • autotel-subscribers/mixpanel — Mixpanel
  • autotel-subscribers/segment — Segment
  • autotel-subscribers/amplitude — Amplitude
  • autotel-subscribers/webhook — Webhook
  • autotel-subscribers/slack — Slack
  • autotel-subscribers/architecture-snapshot — Architecture snapshot for drift detection
  • autotel-subscribers/middleware — Middleware composition
  • autotel-subscribers/testing — Test harnesses