/// Sentry 配置
class SentryConfig {
  /// Sentry DSN (Data Source Name)
  /// 格式: http://public_key@host:port/project_id
  /// 从 Sentry 后台创建项目后获取
  final String dsn;

  /// 环境名称 (production, staging, development)
  final String environment;

  /// 应用版本
  final String? release;

  /// 采样率 (0.0 - 1.0)
  /// 1.0 = 100% 上报所有事件
  /// 0.1 = 10% 采样
  final double sampleRate;

  /// 性能追踪采样率 (0.0 - 1.0)
  final double tracesSampleRate;

  /// 是否启用 (可用于远程开关)
  final bool enabled;

  /// 是否在调试模式下启用
  final bool enableInDebug;

  /// 是否启用性能监控
  final bool enablePerformance;

  /// 是否启用用户反馈
  final bool enableUserFeedback;

  /// 是否启用崩溃免费捕获 (ANR, OOM 等)
  final bool enableNativeCrashHandling;

  /// 是否自动收集面包屑 (用户操作轨迹)
  final bool enableBreadcrumbs;

  /// 面包屑最大数量
  final int maxBreadcrumbs;

  /// 是否发送默认 PII (个人身份信息)
  final bool sendDefaultPii;

  const SentryConfig({
    required this.dsn,
    this.environment = 'production',
    this.release,
    this.sampleRate = 1.0,
    this.tracesSampleRate = 0.2,
    this.enabled = true,
    this.enableInDebug = false,
    this.enablePerformance = true,
    this.enableUserFeedback = true,
    this.enableNativeCrashHandling = true,
    this.enableBreadcrumbs = true,
    this.maxBreadcrumbs = 100,
    this.sendDefaultPii = false,
  });

  /// 开发环境配置
  factory SentryConfig.development({required String dsn}) {
    return SentryConfig(
      dsn: dsn,
      environment: 'development',
      sampleRate: 1.0,
      tracesSampleRate: 1.0,
      enableInDebug: true,
    );
  }

  /// 生产环境配置
  factory SentryConfig.production({required String dsn, String? release}) {
    return SentryConfig(
      dsn: dsn,
      environment: 'production',
      release: release,
      sampleRate: 1.0,
      tracesSampleRate: 0.2,
      enableInDebug: false,
    );
  }

  /// 禁用配置 (用于关闭 Sentry)
  factory SentryConfig.disabled() {
    return const SentryConfig(
      dsn: '',
      enabled: false,
    );
  }
}
