/**
 * Sentry Error Tracking Integration
 *
 * Production error tracking and monitoring:
 * - Automatic error capture
 * - Performance monitoring
 * - Release tracking
 * - User context
 */
import { EventEmitter } from 'events';
export interface SentryConfig {
    /** Sentry DSN */
    dsn: string;
    /** Environment name */
    environment?: string;
    /** Release version */
    release?: string;
    /** Sample rate for errors (0-1) */
    sampleRate?: number;
    /** Sample rate for performance (0-1) */
    tracesSampleRate?: number;
    /** Enable debug mode */
    debug?: boolean;
    /** Tags to add to all events */
    tags?: Record<string, string>;
    /** User information */
    user?: SentryUser;
    /** Before send hook */
    beforeSend?: (event: SentryEvent) => SentryEvent | null;
}
export interface SentryUser {
    id?: string;
    email?: string;
    username?: string;
    ip_address?: string;
}
export interface SentryEvent {
    event_id: string;
    timestamp: string;
    platform: string;
    level: 'fatal' | 'error' | 'warning' | 'info' | 'debug';
    message?: string;
    exception?: {
        values: Array<{
            type: string;
            value: string;
            stacktrace?: {
                frames: Array<{
                    filename: string;
                    function: string;
                    lineno?: number;
                    colno?: number;
                    in_app: boolean;
                }>;
            };
        }>;
    };
    tags?: Record<string, string>;
    extra?: Record<string, unknown>;
    user?: SentryUser;
    contexts?: {
        os?: {
            name: string;
            version: string;
        };
        runtime?: {
            name: string;
            version: string;
        };
        app?: {
            app_name: string;
            app_version: string;
        };
    };
    release?: string;
    environment?: string;
    server_name?: string;
    transaction?: string;
}
export interface SentryBreadcrumb {
    timestamp: number;
    category: string;
    message: string;
    level: 'fatal' | 'error' | 'warning' | 'info' | 'debug';
    data?: Record<string, unknown>;
}
export interface SentryTransaction {
    name: string;
    op: string;
    startTimestamp: number;
    endTimestamp?: number;
    status?: 'ok' | 'cancelled' | 'unknown' | 'aborted' | 'internal_error';
    spans: SentrySpan[];
}
export interface SentrySpan {
    spanId: string;
    parentSpanId?: string;
    op: string;
    description: string;
    startTimestamp: number;
    endTimestamp?: number;
    status?: string;
    data?: Record<string, unknown>;
}
/**
 * Sentry Integration for Code Buddy
 */
export declare class SentryIntegration extends EventEmitter {
    private config;
    private initialized;
    private breadcrumbs;
    private maxBreadcrumbs;
    private transactions;
    private eventQueue;
    private flushInterval;
    constructor(config: SentryConfig);
    /**
     * Initialize Sentry integration
     */
    init(): Promise<void>;
    /**
     * Capture an exception
     */
    captureException(error: Error, options?: {
        level?: SentryEvent['level'];
        tags?: Record<string, string>;
        extra?: Record<string, unknown>;
    }): string;
    /**
     * Capture a message
     */
    captureMessage(message: string, level?: SentryEvent['level'], options?: {
        tags?: Record<string, string>;
        extra?: Record<string, unknown>;
    }): string;
    /**
     * Add a breadcrumb
     */
    addBreadcrumb(breadcrumb: Omit<SentryBreadcrumb, 'timestamp'>): void;
    /**
     * Set user context
     */
    setUser(user: SentryUser | null): void;
    /**
     * Set tag
     */
    setTag(key: string, value: string): void;
    /**
     * Set extra context
     */
    setExtra(key: string, value: unknown): void;
    /**
     * Start a transaction for performance monitoring
     */
    startTransaction(name: string, op: string): string;
    /**
     * Start a span within a transaction
     */
    startSpan(transactionId: string, op: string, description: string): string;
    /**
     * Finish a span
     */
    finishSpan(transactionId: string, spanId: string, status?: string): void;
    /**
     * Finish a transaction
     */
    finishTransaction(transactionId: string, status?: SentryTransaction['status']): void;
    /**
     * Flush pending events to Sentry
     */
    flush(): Promise<void>;
    /**
     * Send event to Sentry
     */
    private sendEvent;
    /**
     * Parse Sentry DSN
     */
    private parseDsn;
    /**
     * Parse error stack trace
     */
    private parseStackTrace;
    /**
     * Get system contexts
     */
    private getContexts;
    /**
     * Generate event ID
     */
    private generateEventId;
    /**
     * Generate span ID
     */
    private generateSpanId;
    /**
     * Close Sentry integration
     */
    close(): Promise<void>;
}
/**
 * Initialize Sentry
 */
export declare function initSentry(config: SentryConfig): SentryIntegration;
/**
 * Get Sentry instance
 */
export declare function getSentry(): SentryIntegration | null;
/**
 * Capture exception helper
 */
export declare function captureException(error: Error, options?: Parameters<SentryIntegration['captureException']>[1]): string;
/**
 * Capture message helper
 */
export declare function captureMessage(message: string, level?: SentryEvent['level'], options?: Parameters<SentryIntegration['captureMessage']>[2]): string;
export default SentryIntegration;
