// Author: fengshengxiong
// Date: 2024/5/22
// Description: firebase analytics工具类

import 'package:firebase_analytics/firebase_analytics.dart';
import 'package:firebase_crashlytics/firebase_crashlytics.dart';
import 'package:flutter/foundation.dart';

class AnalyticsUtil {
  /// 初始化FlutterFire
  static Future<void> initializeFlutterFire() async {
    // 仅在非调试版本中启用它
    await FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(!kDebugMode);
  }

  /// 广告日志记录
  static logAdImpression(String adId, String adName, int shouldCount, int successCount, int failCount) {
    FirebaseAnalytics.instance.logEvent(
      name: 'ad_impression',
      parameters: {
        'adId': adId,
        'adName': adName,
        'shouldCount': shouldCount,
        'successCount': successCount,
        'failCount': failCount,
      },
    );
  }
}
