log method
Logs a message or a structured event to Firebase Analytics, facilitating broad and detailed analytics.
message
- The general message to log if no specific event is provided. Treated as the event name in Firebase.
event
- An optional LogEvent providing structured data for logging, allowing for more granified event analysis.
Implementation
@override
Future<void> log({dynamic message, LogEvent? event}) async {
try {
if (shouldLog(event: event)) {
developer.log(
'>>═══════════════════════FIREBASE ANALYTICS LOG STRATEGY [LOG]═══════════════════════<<',
name: 'FirebaseAnalyticsLogStrategy',
);
if (event != null) {
final FirebaseAnalyticsLogEvent analyticsEvent =
event as FirebaseAnalyticsLogEvent;
_analytics.logEvent(
name: analyticsEvent.eventName,
parameters: analyticsEvent.parameters,
);
}
}
} catch (e, stack) {
developer.log(
'Error during Firebase Analytics logging: $e',
name: 'FirebaseAnalyticsLogStrategy',
error: e,
stackTrace: stack,
);
}
}