/**
 * Analytics Dashboard
 *
 * Features:
 * - Usage metrics tracking
 * - Cost estimation and monitoring
 * - Session analytics
 * - Performance metrics
 * - Export to various formats
 *
 * Provides insights into CLI usage patterns and AI costs.
 */
import { EventEmitter } from 'events';
export interface UsageMetrics {
    totalSessions: number;
    totalMessages: number;
    totalTokensInput: number;
    totalTokensOutput: number;
    totalToolCalls: number;
    totalFileEdits: number;
    totalCommands: number;
    averageSessionDuration: number;
    averageMessagesPerSession: number;
}
export interface CostMetrics {
    totalCost: number;
    costByModel: Record<string, number>;
    costByDay: Record<string, number>;
    costByWeek: Record<string, number>;
    costByMonth: Record<string, number>;
    estimatedMonthlyCost: number;
    budgetRemaining?: number;
}
export interface PerformanceMetrics {
    averageResponseTime: number;
    p50ResponseTime: number;
    p90ResponseTime: number;
    p99ResponseTime: number;
    successRate: number;
    errorRate: number;
    timeoutRate: number;
    cacheHitRate: number;
}
export interface SessionMetrics {
    id: string;
    startTime: Date;
    endTime?: Date;
    duration: number;
    messages: number;
    tokensInput: number;
    tokensOutput: number;
    toolCalls: number;
    fileEdits: number;
    cost: number;
    model: string;
    errors: number;
}
export interface ToolMetrics {
    name: string;
    callCount: number;
    successCount: number;
    errorCount: number;
    averageDuration: number;
    totalDuration: number;
}
export interface DailyStats {
    date: string;
    sessions: number;
    messages: number;
    tokensInput: number;
    tokensOutput: number;
    cost: number;
    errors: number;
    activeMinutes: number;
}
export interface AnalyticsEvent {
    type: string;
    timestamp: Date;
    sessionId: string;
    data: Record<string, unknown>;
}
export interface DashboardConfig {
    enabled: boolean;
    retentionDays: number;
    budgetLimit?: number;
    budgetAlertThreshold: number;
    aggregationInterval: 'hourly' | 'daily' | 'weekly';
    exportFormat: 'json' | 'csv' | 'markdown';
}
/**
 * Analytics Dashboard
 */
export declare class AnalyticsDashboard extends EventEmitter {
    private config;
    private dataDir;
    private sessions;
    private tools;
    private events;
    private dailyStats;
    private currentSessionId;
    private autoSaveIntervalId;
    constructor(config?: Partial<DashboardConfig>);
    /**
     * Trim events array to prevent unbounded growth
     */
    private trimEvents;
    /**
     * Initialize analytics
     */
    private initialize;
    /**
     * Load persisted data
     */
    private loadData;
    /**
     * Save data to disk
     */
    private saveData;
    /**
     * Start auto-save interval
     */
    private startAutoSave;
    /**
     * Cleanup old data based on retention policy
     */
    private cleanupOldData;
    /**
     * Start a new session
     */
    startSession(model?: string): string;
    /**
     * End current session
     */
    endSession(): void;
    /**
     * Track a message
     */
    trackMessage(tokensInput: number, tokensOutput: number, model?: string): void;
    /**
     * Track a tool call
     */
    trackToolCall(toolName: string, success: boolean, duration: number, details?: Record<string, unknown>): void;
    /**
     * Track an event
     */
    trackEvent(type: string, data: Record<string, unknown>): void;
    /**
     * Update daily stats
     */
    private updateDailyStats;
    /**
     * Check budget and emit alert if needed
     */
    private checkBudgetAlert;
    /**
     * Get total cost
     */
    getTotalCost(): number;
    /**
     * Get usage metrics
     */
    getUsageMetrics(): UsageMetrics;
    /**
     * Get cost metrics
     */
    getCostMetrics(): CostMetrics;
    /**
     * Get week start date string
     */
    private getWeekStart;
    /**
     * Get performance metrics
     */
    getPerformanceMetrics(): PerformanceMetrics;
    /**
     * Get tool metrics
     */
    getToolMetrics(): ToolMetrics[];
    /**
     * Get daily stats for a date range
     */
    getDailyStats(startDate?: Date, endDate?: Date): DailyStats[];
    /**
     * Get recent sessions
     */
    getRecentSessions(limit?: number): SessionMetrics[];
    /**
     * Export analytics data
     */
    exportData(format?: 'json' | 'csv' | 'markdown'): Promise<string>;
    /**
     * Convert to CSV
     */
    private toCSV;
    /**
     * Convert to Markdown
     */
    private toMarkdown;
    /**
     * Render dashboard in terminal
     */
    renderDashboard(): string;
    /**
     * Set budget limit
     */
    setBudget(amount: number): void;
    /**
     * Save config
     */
    private saveConfig;
    /**
     * Reset all analytics
     */
    reset(): Promise<void>;
    /**
     * Get config
     */
    getConfig(): DashboardConfig;
    /**
     * Update config
     */
    updateConfig(config: Partial<DashboardConfig>): void;
    /**
     * Dispose and clean up resources
     */
    dispose(): void;
}
export declare function getAnalyticsDashboard(config?: Partial<DashboardConfig>): AnalyticsDashboard;
export declare function resetAnalyticsDashboard(): void;
