import type { ServiceAdapter } from '../core/service-adapter.js'; import type { BaseAdapterOptions } from './shared.js'; /** * PostHog analytics adapter. * * Integrates PostHog's opt-in/opt-out mechanism with Keksmeister. * * @see https://posthog.com/docs/libraries/js#opt-users-out * * Documented API methods (from PostHog docs): * - `posthog.opt_in_capturing()` — enable capturing * - `posthog.opt_out_capturing()` — disable capturing * - `posthog.has_opted_in_capturing()` — check if opted in * - `posthog.has_opted_out_capturing()` — check if opted out * * PostHog should be initialized with `opt_out_capturing_by_default: true` * so no data is captured before consent: * * ```js * posthog.init('phc_...', { * api_host: 'https://eu.i.posthog.com', * opt_out_capturing_by_default: true, * }); * ``` * * Then register the adapter: * * ```js * import { ServiceRegistry } from 'keksmeister'; * import { createPostHogAdapter } from 'keksmeister/adapters/posthog'; * * registry.register(createPostHogAdapter(posthog)); * ``` */ /** Minimal PostHog instance interface (only what we need). */ export interface PostHogLike { opt_in_capturing: (options?: Record) => void; opt_out_capturing: () => void; has_opted_in_capturing: () => boolean; has_opted_out_capturing: () => boolean; } export interface PostHogAdapterOptions extends BaseAdapterOptions { } /** * Create a PostHog service adapter. * * @param posthog - The PostHog instance (window.posthog or imported) * @param options - Optional category and id overrides */ export declare function createPostHogAdapter(posthog: PostHogLike, options?: PostHogAdapterOptions): ServiceAdapter;