trackPurchase method
Implementation
trackPurchase(String trackName, ChabokEvent chabokEvent) {
if (trackName == null || trackName.trim().length == 0) {
throw new Exception(
"trackName is invalid. Please provide a valid name for track");
}
var data = <String, dynamic>{'revenue': chabokEvent.revenue};
if (chabokEvent.currency != null) {
data['currency'] = chabokEvent.currency;
}
var _data = {};
if (chabokEvent.data != null) {
for (var key in chabokEvent.data.keys) {
if (chabokEvent.data[key].runtimeType == DateTime) {
_data['@CHKDATE_' + key] =
chabokEvent.data[key].millisecondsSinceEpoch.toString();
} else {
_data[key] = chabokEvent.data[key];
}
}
data['data'] = _data;
}
var params = <String, dynamic>{'data': data, 'trackName': trackName};
_channel.invokeMethod("trackPurchase", params);
}