engage method
Sends a request to engage a specific event.
Requests will be sent immediately. If you want to batch the events use MixpanelAnalytics.batch instead.
operation
is the operation update as per MixpanelUpdateOperations.
value
is a map with the properties to be sent.
time
is the date that will be added in the event. If not provided, current time will be used.
ip
is the ip
property as explained in mixpanel documentation
ignoreTime
is the $ignore_time
property as explained in mixpanel documentation
ignoreAlias
is the $ignore_alias
property as explained in mixpanel documentation
Implementation
Future<bool> engage({
required MixpanelUpdateOperations operation,
required Map<String, dynamic> value,
DateTime? time,
String? ip,
bool? ignoreTime,
bool? ignoreAlias,
}) async {
final engageEvent = _createEngageEvent(
operation, value, time ?? DateTime.now(), ip, ignoreTime, ignoreAlias);
if (isBatchMode) {
// TODO: this should be place within an init() along within the constructor.
// This is not perfect, as we are waiting for the caller to send an event before sending the stored in memory.
// But doing it on an init() would be a breaking change.
// To be executed only the first time user tries to send an event
if (!_isQueuedEventsReadFromStorage) {
await _restoreQueuedEventsFromStorage();
_isQueuedEventsReadFromStorage = true;
}
_engageEvents.add(engageEvent);
return _saveQueuedEventsToLocalStorage();
}
final base64Event = _base64Encoder(engageEvent);
return _sendEngageEvent(base64Event);
}