export interface MetricParsingUpdate { file_type: 'csv' | 'excel'; file_size: number; has_header_row: boolean; parse_started_at: string; parse_time_ms: number; column_count: number; total_rows: number; } export interface MetricValidationUpdate { validation_started_at: string; validation_time_ms: number; } export interface MetricImportCompleted { import_started_at: string; import_total_records: number; import_failed_records: number; import_time_ms: number; completed_at: string; } export interface MetricCreateResponse { id: string; created_at: string; } /** * Centralized service for tracking import metrics via the ImportOK backend API. * Handles all lifecycle stages of an import operation with silent error handling * to ensure metrics tracking never disrupts imports. */ export declare class MetricsTracker { private readonly token; private static instance; private static readonly METRICS_ENDPOINT; private appUrl; private metricId; private isCompleted; private constructor(); /** * Initialize the MetricsTracker singleton with a token. * Must be called before using getInstance(). */ static initialize(token: string): MetricsTracker; /** * Get the singleton instance of MetricsTracker. * Must call initialize() first. */ static getInstance(): MetricsTracker; /** * Reset the singleton instance (mainly for testing purposes). */ static reset(): void; /** * Get the current metric ID if one exists. */ getMetricId(): string | null; /** * Start tracking a new import operation. * This should be called when the user first selects a file or initiates an import. * * @returns Promise that resolves to the metric ID or null if failed */ startImport(): Promise; /** * Parsing has been completed, record the parsing results * * @param update Parsing data (column count, row count, parse time, etc.) * @return Promise that resolves to true if successful, false otherwise */ parsingCompleted(update: MetricParsingUpdate): Promise; /** * Record validation metrics after data validation is complete. * * @param update Validation data (validation time, records to import, etc.) * @returns Promise that resolves to true if successful, false otherwise */ validationCompleted(update: MetricValidationUpdate): Promise; /** * Import completed successfully, mark the import as completed. * * @returns Promise that resolves to true if successful, false otherwise */ importCompleted(update: MetricImportCompleted): Promise; /** * Mark the import as abandoned (user cancelled or navigated away). * Cannot be called after import has been completed. * * @returns Promise that resolves to true if successful, false otherwise */ abandoned(): Promise; /** * Update an existing metric. * * @param payload The data to update * @returns Promise that resolves to true if successful, false otherwise */ private updateMetric; /** * Get common request headers for all API calls. */ private getHeaders; /** * Log errors silently (metrics failures should never disrupt imports). * In production, this could be enhanced to send to an error tracking service. */ private logError; }