sendLogEvents method
Implementation
@override
Stream<void> sendLogEvents(
List<LogEntry> logEntries, Map<String, String> userProperties) {
final cancelToken = CancelToken();
final streamController = StreamController<void>(onCancel: () {
cancelToken.cancel();
});
streamController.onListen = () {
sendLogEventsWithDio(logEntries, userProperties, cancelToken).then((val) {
if (!streamController.isClosed) {
streamController.add(null);
streamController.close();
}
}).catchError((dynamic err, StackTrace stackTrace) {
var message = err.runtimeType.toString();
if (err is DioException) {
if (err.response != null) {
message = 'response:${err.response!.data}';
}
_logger.warning(
'Error while sending logs. $message', err, stackTrace);
if (!streamController.isClosed) {
streamController.addError(err, stackTrace);
streamController.close();
}
}
});
};
return streamController.stream;
}