in lib/src/usage_impl.dart [301:323]
void _trySendBatches(Completer<void> completer) {
final futures = <Future>[];
while (_batchedEvents.isNotEmpty) {
final batch = <String>[];
final totalLength = 0;
while (true) {
if (_batchedEvents.isEmpty) break;
if (totalLength + _batchedEvents.first.length > _maxBytesPerBatch) {
break;
}
batch.add(_batchedEvents.removeFirst());
if (batch.length == _maxHitsPerBatch) break;
}
if (_bucket.removeDrop()) {
final future = postHandler.sendPost(
batch.length == 1 ? _url : _batchingUrl, batch);
_recordFuture(future);
futures.add(future);
}
}
completer.complete(Future.wait(futures).then((_) {}));
}