trackEvent method
Future<Map<String, bool> >
trackEvent({
- required String eventName,
- required VWOContext vwoContext,
- Map<
String, dynamic> ? eventProperties,
override
Tracks an event.
eventName
The name of the event.
context The user context for the event.
eventProperties
Optional properties associated with the event.
Returns a Future that resolves to a map indicating the success status of the event tracking.
Implementation
@override
Future<Map<String, bool>> trackEvent({
required String eventName,
required VWOContext vwoContext,
Map<String, dynamic>? eventProperties,
}) async {
try {
final result = await methodChannel.invokeMethod<Map<Object?, Object?>>(
'trackEvent',
{
'eventName': eventName,
'context': vwoContext.toMap(),
'eventProperties': eventProperties,
},
);
if (result == null) {
throw Exception("No data returned from native code.");
}
// Convert dynamic map to typed Map<String, bool>
return Map<String, bool>.from(result);
} on PlatformException catch (e) {
// Handle errors from the native side
throw Exception("Error: ${e.code}, ${e.message}");
}
}