/** * Statistics Service * * Tracks plugin update history, health metrics, and provides insights. * * @since v1.23.0 */ import type { PluginSourceType } from '../types/index.js'; import type { HealthFactors, PluginStats, RecentError, ServerStats, SourceStats, UpdateEvent } from './stats-types.js'; /** * Configuration for the stats service */ export interface StatsConfig { /** Maximum update events to keep per plugin */ maxEventsPerPlugin: number; /** Days to consider for "recent" errors */ recentErrorDays: number; /** Days without update to consider "outdated" */ outdatedDays: number; } /** * Default stats configuration */ export declare const DEFAULT_STATS_CONFIG: StatsConfig; /** * Statistics Service * * Tracks and analyzes plugin management statistics. */ export declare class StatsService { private store; private storagePath; private loaded; private config; constructor(storagePath?: string, config?: Partial); /** * Create an empty store */ private createEmptyStore; /** * Load stats from disk */ load(): Promise; /** * Save stats to disk */ save(): Promise; /** * Record an update check event */ recordUpdateCheck(pluginName: string, source: PluginSourceType, responseTimeMs?: number): Promise; /** * Record an update download event */ recordUpdateDownload(pluginName: string, event: Omit): Promise; /** * Record an error for a plugin */ recordError(pluginName: string, error: string): Promise; /** * Update server statistics */ updateServerStats(stats: Partial): Promise; /** * Get statistics for a specific plugin */ getPluginStats(pluginName: string): PluginStats | null; /** * Get statistics for a specific source */ getSourceStats(source: PluginSourceType): SourceStats | null; /** * Get all source statistics */ getAllSourceStats(): SourceStats[]; /** * Get server statistics */ getServerStats(): ServerStats; /** * Get all plugin statistics */ getAllPluginStats(): PluginStats[]; /** * Get outdated plugins (no update check in X days) */ getOutdatedPlugins(daysSinceCheck?: number): PluginStats[]; /** * Get most frequently updated plugins */ getMostUpdatedPlugins(limit?: number): PluginStats[]; /** * Get recent errors */ getRecentErrors(limit?: number): RecentError[]; /** * Get recent successful updates */ getRecentUpdates(limit?: number): Array; /** * Calculate health score */ calculateHealthScore(): HealthFactors; /** * Get plugin count by source */ getPluginCountBySource(): Record; /** * Clear all statistics */ clear(): Promise; /** * Get the last updated timestamp */ getLastUpdated(): Date | null; /** * Set plugin source for tracking */ setPluginSource(pluginName: string, source: PluginSourceType): Promise; /** * Recalculate total plugins per source */ private recalculateSourcePluginCounts; } /** * Get the singleton stats service instance */ export declare function getStatsService(): StatsService; /** * Reset the singleton (for testing) */ export declare function resetStatsService(): void; //# sourceMappingURL=stats-service.d.ts.map