generateCrashMetric method

Future<void> generateCrashMetric(
  1. DateTime crashTimestamp
)

Generate a crash metric using the same timestamp as the crash event Uses current session values for fbl, operation, and view (with automatic fallbacks)

Implementation

Future<void> generateCrashMetric(DateTime crashTimestamp) async {
  if (!_isInitialized || _hub == null) {
    ObslyLogger.debug('MetricsController not initialized, skipping crash metric');
    return;
  }

  // Check if metrics is enabled
  final config = ConfigController.instance.config;
  if (!(config?.enableMetrics ?? true)) {
    ObslyLogger.debug('Metrics disabled, ignoring crash metric generation');
    return;
  }

  try {
    // Generate CONTADOR metric with KEY = 'Crash'
    // Don't pass fbl, operation, view - let the system use session values automatically
    await incCounter(
      'Crash', // key
      '', // fbl - empty to use session value
      '', // operation - empty to use session value
      '', // view - empty to use session/navigation value
      'occurred', // state
      date: crashTimestamp.millisecondsSinceEpoch,
      increment: 1,
    );

    ObslyLogger.debug('📊 Crash metric generated: Crash counter +1 (using session context)');
  } catch (e) {
    ObslyLogger.error('Error generating crash metric: $e');
  }
}