2023-10-31 17:42:25 +00:00
|
|
|
import 'package:firebase_analytics/firebase_analytics.dart';
|
|
|
|
import 'package:firebase_core/firebase_core.dart';
|
2024-01-27 22:20:53 +00:00
|
|
|
import 'package:firebase_crashlytics/firebase_crashlytics.dart';
|
2023-10-31 17:42:25 +00:00
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
import 'package:lightmeter/data/analytics/api/analytics_api_interface.dart';
|
|
|
|
|
|
|
|
class LightmeterAnalyticsFirebase implements ILightmeterAnalyticsApi {
|
|
|
|
const LightmeterAnalyticsFirebase();
|
|
|
|
|
|
|
|
@override
|
2024-01-27 22:20:53 +00:00
|
|
|
Future<void> logEvent(
|
|
|
|
String eventName, {
|
2023-10-31 17:42:25 +00:00
|
|
|
Map<String, dynamic>? parameters,
|
|
|
|
}) async {
|
|
|
|
try {
|
|
|
|
await FirebaseAnalytics.instance.logEvent(
|
2024-01-27 22:20:53 +00:00
|
|
|
name: eventName,
|
2023-10-31 17:42:25 +00:00
|
|
|
parameters: parameters,
|
|
|
|
);
|
|
|
|
} on FirebaseException catch (e) {
|
|
|
|
debugPrint('Firebase Analytics Exception: $e');
|
|
|
|
} catch (e) {
|
|
|
|
debugPrint(e.toString());
|
|
|
|
}
|
|
|
|
}
|
2024-01-27 22:20:53 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Future<void> logCrash(
|
|
|
|
dynamic exception,
|
|
|
|
StackTrace? stackTrace, {
|
|
|
|
dynamic reason,
|
|
|
|
Iterable<Object> information = const [],
|
|
|
|
}) async {
|
|
|
|
FirebaseCrashlytics.instance.recordError(
|
|
|
|
exception,
|
|
|
|
stackTrace,
|
|
|
|
reason: reason,
|
|
|
|
information: information,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Future<void> setCustomKey(String key, String value) async {
|
|
|
|
await FirebaseCrashlytics.instance.setCustomKey(key, value);
|
|
|
|
}
|
2023-10-31 17:42:25 +00:00
|
|
|
}
|