Skip to content

Removing flush policies doesn't completely prevent upload attempts #179

Closed

Description

@fergushowe-wa

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.

Activity

  1. neelkanth-kaushik commented on Oct 20, 2025

    @neelkanth-kaushik
    Contributor

    Hi @fergushowe-wa , We have worked on the issue of queued events getting lost and released version 1.1.10 with a patch. We recommend you to please update your SDK and let us know if it fixed your problem. Kindly ensure to use storageJson=true when initializing the analytics client.

  2. fergushowe-wa commented on Oct 30, 2025

    @fergushowe-wa
    Author

    Hi @neelkanth-kaushik thanks very much, we've upgraded to 1.1.10 and tested and it's working perfectly now, appreciate the help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions