identify method
this function is to login user and identify it's data userId is optional or you can send user's unique id or else it will be auto generated
Implementation
Future<void> identify(
{String? userId, required List<Info> attributes}) async {
if (_session.data!.uid == null || _session.data!.uid.toString() == "") {
if (_session.data!.did == null || _session.data!.did.toString() == "") {}
List<Map<String, dynamic>> data = [];
attributes.forEach((element) {
data.add(element.toJson());
});
EventModel event = EventModel(
attributes: jsonEncode(data),
name: userId,
eventTime: DateTime.now().millisecondsSinceEpoch);
_database.insertEvent(event).then((value) async {
if (_session.data!.stime == null ||
_isSessionExpired(_session.data!.stime!)) {
await _createSession();
}
await _flushEvents();
});
}
}