import { AmplitudeConfig } from "./amplitude.js"; import { i as PostHogConfig } from "./posthog-DLBf2UJJ.js"; import { MixpanelConfig } from "./mixpanel.js"; import { SegmentConfig } from "./segment.js"; import { WebhookConfig } from "./webhook.js"; import { SlackSubscriberConfig } from "./slack.js"; import { EventAttributes, EventSubscriber, FunnelStatus, OutcomeStatus } from "autotel/event-subscriber"; //#region src/mock-event-subscriber.d.ts /** * Captured event data */ interface CapturedEvent { type: 'event' | 'funnel' | 'outcome' | 'value'; name: string; attributes?: EventAttributes; funnel?: string; step?: FunnelStatus; operation?: string; outcome?: OutcomeStatus; value?: number; timestamp: string; } /** * Mock subscriber for testing * * Captures all events calls in memory for test assertions. * Does not make any real API calls. */ declare class MockEventSubscriber implements EventSubscriber { readonly name = "MockEventSubscriber"; readonly version = "1.0.0"; /** * All captured events */ events: CapturedEvent[]; /** * Track if shutdown was called */ shutdownCalled: boolean; trackEvent(name: string, attributes?: EventAttributes): Promise; trackFunnelStep(funnelName: string, step: FunnelStatus, attributes?: EventAttributes): Promise; trackOutcome(operationName: string, outcome: OutcomeStatus, attributes?: EventAttributes): Promise; trackValue(name: string, value: number, attributes?: EventAttributes): Promise; shutdown(): Promise; /** * Reset captured events (useful between tests) */ reset(): void; /** * Get events by type */ getEventsByType(type: 'event' | 'funnel' | 'outcome' | 'value'): CapturedEvent[]; /** * Get events by name */ getEventsByName(name: string): CapturedEvent[]; /** * Get funnel events for a specific funnel */ getFunnelEvents(funnelName: string): CapturedEvent[]; /** * Get outcome events for a specific operation */ getOutcomeEvents(operationName: string): CapturedEvent[]; /** * Get value events by metric name */ getValueEvents(metricName: string): CapturedEvent[]; /** * Assert that an event was tracked */ assertEventTracked(name: string, attributes?: Partial): void; /** * Assert that a funnel step was tracked */ assertFunnelStepTracked(funnelName: string, step: FunnelStatus, attributes?: Partial): void; /** * Assert that an outcome was tracked */ assertOutcomeTracked(operationName: string, outcome: OutcomeStatus, attributes?: Partial): void; /** * Pretty print all captured events (useful for debugging) */ printEvents(): void; } //#endregion //#region src/factories.d.ts /** Create a PostHog events subscriber */ declare function createPostHogSubscriber(config: { apiKey: string; host?: string; enabled?: boolean; }): EventSubscriber; /** Create a Mixpanel events subscriber */ declare function createMixpanelSubscriber(config: { token: string; enabled?: boolean; }): EventSubscriber; /** Create an Amplitude events subscriber */ declare function createAmplitudeSubscriber(config: { apiKey: string; enabled?: boolean; }): EventSubscriber; /** Create a Segment events subscriber */ declare function createSegmentSubscriber(config: { writeKey: string; enabled?: boolean; }): EventSubscriber; /** Create a Webhook events subscriber with retry and timeout support */ declare function createWebhookSubscriber(config: { url: string; method?: 'POST' | 'PUT'; headers?: Record; enabled?: boolean; maxRetries?: number; timeoutMs?: number; retryDelayMs?: number; }): EventSubscriber; /** Create a Slack events subscriber */ declare function createSlackSubscriber(config: { webhookUrl: string; channel?: string; enabled?: boolean; }): EventSubscriber; /** Create a mock events subscriber for testing */ declare function createMockSubscriber(): MockEventSubscriber; /** * Strategy for composing multiple subscribers * * - `parallel`: Send to all subscribers concurrently, fail if any fails * - `failover`: Try subscribers in order until one succeeds * - `round-robin`: Cycle through subscribers sequentially * - `random`: Pick a random subscriber each time * - `race`: Send to all, succeed when any succeeds * - `mirrored`: Send to primary, mirror to others (primary failure fails all) */ type ComposeSubscriberStrategy = 'parallel' | 'failover' | 'round-robin' | 'random' | 'race' | 'mirrored'; /** Configuration options for composing multiple subscribers */ type ComposeSubscribersOptions = { name?: string; strategy?: ComposeSubscriberStrategy; maxAttemptsPerSubscriber?: number; initialRetryDelayMs?: number; maxRetryDelayMs?: number; isRetriable?: (error: unknown) => boolean; logger?: Pick; }; /** * Compose multiple subscribers into one with a specified strategy * * @example * ```typescript * const multiSubscriber = composeSubscribers( * [ * createPostHogSubscriber({ apiKey: '...' }), * createWebhookSubscriber({ url: '...' }) * ], * { strategy: 'parallel' } * ) * ``` * * @param subscribers - Array of subscribers to compose * @param options - Configuration for composition strategy and retry behavior * @returns A composite EventSubscriber that applies the strategy */ declare function composeSubscribers(subscribers: EventSubscriber[], options?: ComposeSubscribersOptions): EventSubscriber; //#endregion export { type AmplitudeConfig, ComposeSubscriberStrategy, ComposeSubscribersOptions, type MixpanelConfig, type PostHogConfig, type SegmentConfig, type SlackSubscriberConfig, type WebhookConfig, composeSubscribers, createAmplitudeSubscriber, createMixpanelSubscriber, createMockSubscriber, createPostHogSubscriber, createSegmentSubscriber, createSlackSubscriber, createWebhookSubscriber }; //# sourceMappingURL=factories.d.ts.map