import 'dart:developer';

import 'package:firebase_crashlytics/firebase_crashlytics.dart';
import 'package:hub/features/backend/index.dart';

class LogUtil {
  static void requestAPIFailed(String url, String body, String reason,
      dynamic error, StackTrace stack) async {
    final fullUrl = "${PhpGroup.getBaseUrl()}/$url";
    log("URL: $fullUrl");
    log("Body: $body");
    log("Reason: $reason");
    log("Error: ${error.toString()}");
    log("Stack: ${stack.toString()}");

    FirebaseCrashlytics.instance.setCustomKey('URL', fullUrl);
    FirebaseCrashlytics.instance.setCustomKey('Body', body);

    await FirebaseCrashlytics.instance
        .recordError(error, stack, reason: reason);
  }
}
