/** * Built-in analytics adapter implementations. * * Each adapter translates Segment-shaped events into a specific backend's * HTTP API format. All adapters are stateless — they send events immediately * via `fetch()`. For batching, wrap with a buffering layer or use the * backend's own batching SDK. * * @example * ```ts * import { createAnalyticsRouter, createPostHogAdapter } from "@polkadot-apps/host-sdk"; * * const router = createAnalyticsRouter(); * router.register("com.example.app", createPostHogAdapter({ * apiKey: "phc_abc123", * host: "https://us.i.posthog.com", * })); * ``` */ import type { AnalyticsAdapter } from "./telemetry.js"; /** Configuration for the PostHog adapter. */ export interface PostHogAdapterOptions { /** PostHog project API key (e.g. "phc_abc123..."). */ apiKey: string; /** * PostHog instance host. Default: "https://us.i.posthog.com". * Use "https://eu.i.posthog.com" for EU cloud, or your self-hosted URL. */ host?: string; /** * Called when a request to PostHog fails. * Default: silent (errors are swallowed). */ onError?: (error: unknown) => void; } /** * Create a PostHog analytics adapter. * * Maps Segment-shaped events to PostHog's `/capture` and `/engage` APIs. * * @see https://posthog.com/docs/api/capture */ export declare function createPostHogAdapter(options: PostHogAdapterOptions): AnalyticsAdapter; /** Configuration for the generic webhook adapter. */ export interface WebhookAdapterOptions { /** HTTPS endpoint that accepts POST requests with JSON body. */ endpoint: string; /** * Optional headers to include in every request. * Use for API keys, auth tokens, etc. * * @example * ```ts * { "Authorization": "Bearer token123" } * ``` */ headers?: Record; /** * Called when a request to the webhook fails. * Default: silent (errors are swallowed). */ onError?: (error: unknown) => void; } /** * Create a generic webhook adapter. * * Sends Segment-shaped events as-is (JSON POST) to any HTTPS endpoint. * Compatible with RudderStack, Jitsu, Segment HTTP API, or any custom * backend that accepts Segment-format payloads. * * @example * ```ts * const adapter = createWebhookAdapter({ * endpoint: "https://my-api.example.com/v1/events", * headers: { "Authorization": "Bearer secret" }, * }); * ``` */ export declare function createWebhookAdapter(options: WebhookAdapterOptions): AnalyticsAdapter; /** * Create a console adapter for development/debugging. * * Logs all analytics events to `console.debug` with a `[telemetry]` prefix. * Useful for verifying that products emit the expected events without * configuring a backend. * * @example * ```ts * const router = createAnalyticsRouter(); * router.register("my-product", createConsoleAdapter()); * ``` */ export declare function createConsoleAdapter(): AnalyticsAdapter; //# sourceMappingURL=adapters.d.ts.map