-
Notifications
You must be signed in to change notification settings - Fork 57
Description
I'm working on an app that allows users to connect to hardware devices via WiFi. As a result, internet conection is not always available during app use, so to ensure no analytics events / screen views are lost, we're calling
analytics.removeFlushPolicy(analytics.getFlushPolicies());
before internet connection is lost. This works for the most part - while we're not connected to the internet, no analytics data is uploaded. But for some reason, when there's a change in the network state (ie when the user disconnects from one of our hardware devices) Segment attempts a flush, regardless of flush policy. This flush usually fails (because normal internet connection hasn't been reestablished) and those events / screen views are then lost. The logs look like this
I/flutter ( 4797): │ #0 SystemLogger.parseLog (package:segment_analytics/logger.dart:80:16)
I/flutter ( 4797): │ #1 log (package:segment_analytics/logger.dart:106:23)
I/flutter ( 4797): │ ⛔ Segment: Error uploading request ClientException with SocketException: Software caused connection abort (OS Error: Software caused connection abort, errno = 103), address = api.segment.io, port = 49182, uri=https://api.segment.io/v1/b
I/flutter ( 4797): │ #0 SystemLogger.parseLog (package:segment_analytics/logger.dart:74:16)
I/flutter ( 4797): │ #1 log (package:segment_analytics/logger.dart:106:23)
I/flutter ( 4797): │ 🐛 Segment: Sent 8 events
I/flutter ( 4797): │ #0 SystemLogger.parseLog (package:segment_analytics/logger.dart:80:16)
I/flutter ( 4797): │ #1 log (package:segment_analytics/logger.dart:106:23)
I/flutter ( 4797): │ ⛔ Segment: Failed to send 8 events
I can't see a way to avoid this. I can confirm that at the time the above logs are appearing, analytics.getFlushPolicies()
returns an empty list. I've also tried using a custom flush policy that is designed to never flush, but the same thing happens.
This is a problem for us as we want our analytics tracking to be as reliable and complete as possible. Any help would be greatly appreciated.