AvoBatcher constructor
AvoBatcher({
- required AvoNetworkCallsHandler networkCallsHandler,
- required AvoSessionTracker sessionTracker,
- required String avoInstallationId,
Implementation
AvoBatcher(
{required this.sharedPreferences,
required this.networkCallsHandler,
required this.sessionTracker,
required this.avoInstallationId})
: this._batchFlushAttemptTimestamp =
DateTime.now().millisecondsSinceEpoch {
_events = sharedPreferences
.getStringList(diskBatcherStorageCacheKey)
?.map((String savedItem) {
Map<String, dynamic> eventMap = jsonDecode(savedItem);
if (eventMap["type"] == "sessionStarted") {
return SessionStartedBody.fromJson(eventMap);
} else {
return EventSchemaBody.fromJson(eventMap);
}
}).toList() ??
[];
_checkIfBatchNeedsToBeSent();
}