/** * Telemetry module for anonymous usage tracking using PostHog * * Purpose: Help maintainers understand which AI issues users are facing * Privacy: No user identification, tracking, or sensitive data collection * * Collected data: * - install_id (random UUID, locally generated on first run) * - cli_version * - os, arch * - target (check type) * - provider_type * - status (success/warning/error) * - duration_bucket * * Note: PostHog automatically adds timestamp to events * * Strictly forbidden: * - Prompts, payloads, request bodies * - API keys, base URLs, file paths * - Repo names, model names * - Any user or company identifiers */ export interface TelemetryEvent { cli_version: string; os: string; arch: string; target: string; provider_type: string; status: 'success' | 'warning' | 'error'; duration_bucket: string; } export interface DoctorChoiceTelemetryEvent { cli_version: string; os: string; arch: string; choice: 'safe_mode' | 'full_mode' | 'diagnose_only'; } /** * Generate a random install_id (UUID v4) */ export declare function generateInstallId(): string; /** * Calculate duration bucket for anonymization * Buckets: <1s, 1-5s, 5-10s, 10-30s, 30-60s, >60s */ export declare function getDurationBucket(durationSeconds: number): string; /** * Check if telemetry is enabled based on multiple opt-out mechanisms * * Respects: * - --no-telemetry flag * - AI_PATCH_TELEMETRY=0 environment variable * - telemetryEnabled=false in config * * Default: enabled (opt-out model) */ export declare function isTelemetryEnabled(noTelemetryFlag: boolean, configTelemetryEnabled: boolean | undefined): boolean; /** * Send telemetry event using PostHog (fire-and-forget) * * - Never blocks or slows the CLI * - Fails silently on network errors * - Never changes CLI exit codes */ export declare function sendTelemetryEvent(installId: string, properties: TelemetryEvent): void; /** * Send telemetry event and wait briefly for flush. * * Uses a short timeout to improve delivery reliability without * adding noticeable latency to CLI exits. */ export declare function sendTelemetryEventAsync(installId: string, properties: TelemetryEvent): Promise; /** * Create and send a doctor_run telemetry event */ export declare function sendDoctorRunEvent(installId: string, cliVersion: string, target: string, provider: string, status: 'success' | 'warning' | 'error', durationSeconds: number): void; /** * Create and send a doctor_run telemetry event and wait briefly for flush. */ export declare function sendDoctorRunEventAsync(installId: string, cliVersion: string, target: string, provider: string, status: 'success' | 'warning' | 'error', durationSeconds: number): Promise; /** * Create and send a doctor_choice telemetry event and wait briefly for flush. */ export declare function sendDoctorChoiceEventAsync(installId: string, cliVersion: string, choice: 'safe_mode' | 'full_mode' | 'diagnose_only'): Promise; //# sourceMappingURL=telemetry.d.ts.map