trackEvent static method
Track an analytics event
eventName
Name of the event
properties
Event properties
Throws GoMailerException if SDK is not initialized or event name is empty
Implementation
static Future<void> trackEvent({
required String eventName,
Map<String, dynamic>? properties,
}) async {
_checkInitialization();
if (eventName.isEmpty) {
throw GoMailerException('Event name cannot be empty');
}
try {
await _channel.invokeMethod('trackEvent', {
'eventName': eventName,
'properties': properties ?? {},
});
_log('Event tracked: $eventName', GoMailerLogLevel.debug);
} catch (e) {
_log('Failed to track event $eventName: $e', GoMailerLogLevel.error);
throw GoMailerException('Failed to track event: $e');
}
}