trackEvent method
void
trackEvent(})
Implementation
void trackEvent(
Map? identityId, List<Map>? profile, String? eventName, Map? eventData,
{Function(Object?)? onResponse, Function(Object?)? onFailure}) async {
// print("identityId $identityId");
// print("profile profile");
// print("eventName $eventName");
// print("eventData $eventData");
final result = await _channel.invokeMethod<Map<dynamic, dynamic>>(
Const.trackEvent,
{
"identityId": identityId,
"profile": profile,
"eventName": eventName,
"eventData": eventData,
},
);
if (result != null) {
final input = result['input'] as Object?;
// _log("~~~~~~~~~~~~~monitorEvent: ${jsonEncode(monitorEvent)}");
final isSuccessful = result['isSuccessful'] as bool?;
final code = result['code'] as int?;
final response = result['response'] as Object?;
// _log("~~~~~~~~~~~~~isSuccessful: $isSuccessful");
// _log("~~~~~~~~~~~~~code: $code");
// _log("~~~~~~~~~~~~~response: ${jsonEncode(response)}");
// if (kDebugMode) {
// await Future.delayed(const Duration(seconds: 2));
// }
if (response != null) {
onResponse?.call({
if (input != null) "input": input,
if (isSuccessful != null) "isSuccessful": isSuccessful,
if (code != null) "code": code,
"response": response,
});
}
final error = result['error'] as String?;
if (error != null) {
onFailure?.call({
if (input != null) "input": input,
"error": error,
});
}
}
}