track method
name
should be less than 120 char. You can add any custom event name. Add list of info for detailed
event record. To get user details for custom event login the user first
Implementation
Future<void> track({required String name, required List<Info> info}) async {
List<Map<String, dynamic>> data = [];
Set raw = Set();
info.forEach((element) {
data.add(element.toJson());
raw.add(element.toJson());
});
EventModel event = EventModel(
properties: jsonEncode(data),
name: name,
rawProperties: jsonEncode(
data.toString().replaceAll("[", "{").replaceAll("]", "}")),
eventTime: DateTime.now().millisecondsSinceEpoch);
_database.insertEvent(event).then((value) async {
if (_session.data!.stime == null ||
_isSessionExpired(_session.data!.stime!)) {
await _createSession();
}
await _flushEvents();
});
}