import { FlagAnalytics, FlagAnalyticsConfig } from './flag-analytics'; import { ExposureTracker, ExposureTrackerConfig } from './flag-exposure-tracker'; import { FlagImpactAnalyzer, ImpactAnalyzerConfig } from './flag-impact-analyzer'; /** * @fileoverview Feature flag analytics module exports. * * This module provides comprehensive analytics capabilities for feature flags: * - Usage analytics and metrics collection * - Exposure tracking for experiments and A/B tests * - Impact analysis with statistical significance testing * * @module flags/analytics * * @example * ```typescript * import { * FlagAnalytics, * ExposureTracker, * FlagImpactAnalyzer, * initFlagAnalytics, * initExposureTracker, * initImpactAnalyzer, * } from '@/lib/flags/analytics'; * * // Initialize analytics * const analytics = initFlagAnalytics({ * batchSize: 100, * flushInterval: 30000, * endpoint: 'https://api.example.com/analytics', * }); * * // Track evaluations * analytics.trackEvaluation({ * flagKey: 'new-feature', * variantId: 'enabled', * userId: 'user-123', * }); * * // Initialize exposure tracking * const tracker = initExposureTracker({ * deduplicationWindow: 24 * 60 * 60 * 1000, * onExposure: (exposure) => console.log('Exposed:', exposure), * }); * * // Track exposures * tracker.trackExposure({ * flagKey: 'new-checkout', * variantId: 'variant-b', * userId: 'user-123', * experimentId: 'checkout-experiment', * }); * * // Initialize impact analyzer * const analyzer = initImpactAnalyzer({ * significanceThreshold: 0.05, * minSampleSize: 100, * }); * * // Record metrics * analyzer.recordMetric('conversion_rate', 0.15, { * flagKey: 'new-checkout', * variantId: 'variant-b', * userId: 'user-123', * }); * * // Analyze impact * const impact = analyzer.analyzeImpact('new-checkout'); * console.log(impact?.summary); * ``` */ export { FlagAnalytics, getFlagAnalytics, initFlagAnalytics, resetFlagAnalytics, } from './flag-analytics'; export type { EvaluationEvent, FlagMetrics, FlagAnalyticsConfig, AnalyticsReport, } from './flag-analytics'; export { ExposureTracker, getExposureTracker, initExposureTracker, resetExposureTracker, createExposureContext, } from './flag-exposure-tracker'; export type { ExposureEvent, ExposureRecord, UserExposureSummary, ExposureTrackerConfig, TrackExposureInput, } from './flag-exposure-tracker'; export { FlagImpactAnalyzer, getImpactAnalyzer, initImpactAnalyzer, resetImpactAnalyzer, } from './flag-impact-analyzer'; export type { MetricDataPoint, MetricStats, VariantComparison, FlagImpactAnalysis, ImpactAnalyzerConfig, RecordMetricInput, } from './flag-impact-analyzer'; /** * Configuration for the unified analytics suite. */ export interface AnalyticsSuiteConfig { /** Flag analytics configuration */ readonly analytics?: FlagAnalyticsConfig; /** Exposure tracker configuration */ readonly exposure?: ExposureTrackerConfig; /** Impact analyzer configuration */ readonly impact?: ImpactAnalyzerConfig; /** Enable all analytics by default */ readonly enabled?: boolean; /** Debug mode for all components */ readonly debug?: boolean; } /** * Unified analytics suite combining all analytics capabilities. */ export interface AnalyticsSuite { /** Flag analytics collector */ readonly analytics: FlagAnalytics; /** Exposure tracker */ readonly exposure: ExposureTracker; /** Impact analyzer */ readonly impact: FlagImpactAnalyzer; /** Shutdown all analytics */ shutdown(): Promise; /** Reset all analytics */ reset(): void; /** Set enabled state for all */ setEnabled(enabled: boolean): void; } /** * Create a unified analytics suite with all components configured. * * @param config - Configuration for all analytics components * @returns Unified analytics suite * * @example * ```typescript * const suite = createAnalyticsSuite({ * analytics: { * endpoint: 'https://api.example.com/analytics', * batchSize: 100, * }, * exposure: { * deduplicationWindow: 86400000, * }, * impact: { * significanceThreshold: 0.05, * }, * debug: true, * }); * * // Use the suite * suite.analytics.trackEvaluation({ ... }); * suite.exposure.trackExposure({ ... }); * suite.impact.recordMetric('metric', value, { ... }); * * // Cleanup * await suite.shutdown(); * ``` */ export declare function createAnalyticsSuite(config?: AnalyticsSuiteConfig): AnalyticsSuite; /** * Connect analytics to flag evaluation events. * * @param suite - Analytics suite to connect * @param options - Connection options * @returns Disconnect function * * @example * ```typescript * import { getFlagEngine } from '@/lib/flags/advanced'; * import { createAnalyticsSuite, connectAnalytics } from '@/lib/flags/analytics'; * * const suite = createAnalyticsSuite(); * const engine = getFlagEngine(); * * // Connect analytics to engine * const disconnect = connectAnalytics(suite, { * trackEvaluations: true, * trackExposures: true, * recordMetrics: true, * }); * * // Later: disconnect * disconnect(); * ``` */ export declare function connectAnalytics(suite: AnalyticsSuite, options?: { trackEvaluations?: boolean; trackExposures?: boolean; recordMetrics?: boolean; }): () => void; /** * Get aggregated analytics data from all components. * * @param suite - Analytics suite to aggregate from * @returns Aggregated analytics data */ export declare function getAggregatedAnalytics(suite: AnalyticsSuite): { report: ReturnType; exposureCount: number; impactAnalyses: ReturnType[]; };