track method

void track(
  1. String eventName, {
  2. Map<String, dynamic>? properties,
  3. DateTime? dateTime,
  4. String? timeZone,
})

Tracks an event.

eventName is required for this function. In addition you can pass a Map<String, dynamic> as the event's properties.

By default, the event time will be set to the device time with default time zone settings. You can pass a dateTime and a valid timeZone name to set the event time.

Implementation

void track(String eventName,
    {Map<String, dynamic>? properties,
    DateTime? dateTime,
    String? timeZone}) {
  Map<String, dynamic> finalProperties = new Map<String, dynamic>();
  if (this._getDynamicSuperProperties != null) {
    finalProperties = this._getDynamicSuperProperties!();
  }

  if (properties != null) {
    finalProperties.addAll(properties);
  }
  _searchDate(finalProperties);

  Map<String, dynamic> params = {
    'appId': this._appId,
    'eventName': eventName,
    'properties': finalProperties,
  };

  if (null != dateTime) {
    params['timestamp'] = dateTime.millisecondsSinceEpoch;
  }

  if (null != timeZone) {
    params['timeZone'] = timeZone;
  }

  _channel.invokeMethod<void>('track', params);
}