logEvent method

Future<void> logEvent(
  1. String eventType,
  2. {Map<String, dynamic>? eventProperties,
  3. bool? outOfSession}
)

Tracks an event. Events are saved locally.

Uploads are batched to occur every 30 events or every 30 seconds (whichever comes first), as well as on app close.

eventType The name of the event you wish to track. eventProperties You can attach additional data to any event by passing a Map object with property: value pairs.

Implementation

Future<void> logEvent(String eventType,
    {Map<String, dynamic>? eventProperties, bool? outOfSession}) async {
  Map<String, dynamic> properties = _baseProperties();
  properties['eventType'] = eventType;
  if (eventProperties != null) {
    properties['eventProperties'] = eventProperties;
  }
  if (outOfSession != null) {
    properties['outOfSession'] = outOfSession;
  }

  return await _channel.invokeMethod('logEvent', jsonEncode(properties));
}