flush method
Delivers queued events in batches of batchSize, and returns how many deliveries succeeded.
Consent is checked again as each event leaves: one withdrawn since it was tracked is dropped, not sent. A sink that throws keeps its events for the next flush and does not hold the others back.
Implementation
Future<int> flush({Set<String>? sinks}) async {
await idle;
return _serial(() async {
int sent = 0;
final List<DVAnalyticsSink> all = <DVAnalyticsSink>[store, ...providers];
for (final DVAnalyticsSink sink in all) {
if (sinks != null && !sinks.contains(sink.name)) continue;
sent += await _flushSink(sink);
}
return sent;
});
}