/** * Telemetry plugin for XState machines * * Automatically tracks state transitions and events for analytics. */ import type { Telemetry } from '../utils/telemetry.js'; import type { StateHistoryEntry } from './types.js'; /** * Configuration for telemetry tracking */ export interface TelemetryPluginConfig { /** Telemetry instance to use */ telemetry: Telemetry; /** Machine ID for event naming */ machineId: string; /** States to skip tracking (e.g., transient states) */ skipStates?: string[]; /** Whether to track all events or just state changes */ trackAllEvents?: boolean; } /** * Snapshot type for subscriber (loosely typed for XState compatibility) */ interface MachineSnapshot { value: unknown; context?: unknown; } /** * Creates a telemetry subscriber for a state machine * * Tracks: * - State entry/exit * - State transition timing * - Error states * - Cancellation */ export declare const createTelemetrySubscriber: (config: TelemetryPluginConfig) => (snapshot: MachineSnapshot) => void; /** * Gets the state history from a subscriber * Useful for debugging and error reporting */ export declare const getStateHistory: (_subscriber: ReturnType) => StateHistoryEntry[]; /** * Creates a combined subscriber that handles both telemetry and custom callbacks */ export declare const combineSubscribers: (...subscribers: ((snapshot: MachineSnapshot) => void)[]) => (snapshot: MachineSnapshot) => void; /** * Utility to create a simple state logger for debugging */ export declare const createDebugSubscriber: (machineId: string, logger?: { debug: (msg: string, ...args: unknown[]) => void; }) => (snapshot: MachineSnapshot) => void; export {};