trackEvent method

Future<void> trackEvent(
  1. String eventName, [
  2. Map<String, dynamic>? props
])

Records an event with the given name and optional properties.

Implementation

Future<void> trackEvent(
  String eventName, [
  Map<String, dynamic>? props,
]) async {
  if (_appKey.isEmpty || _apiUrl == null) {
    _logInfo("Tracking is disabled!");

    return;
  }

  final body = json.encode({
    "timestamp": DateTime.now().toUtc().toIso8601String(),
    "sessionId": _evalSessionId(),
    "eventName": eventName,
    "systemProps": await _systemProps(),
    "props": props,
  });

  await _storage.add(body);
}