Skip to content

If event upload fails, try to upload the event again #72

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Jay-57blocks opened this issue Apr 18, 2024 · 1 comment
Closed

If event upload fails, try to upload the event again #72

Jay-57blocks opened this issue Apr 18, 2024 · 1 comment

Comments

@Jay-57blocks
Copy link

Since I am developing the LOT project, most of the time it interacts with hardware devices and cannot access the Internet. I want to monitor the availability of the network and let it upload all events. My current code is like this. Is there a more recommended way to write it?

   _connectivity.onConnectivityChanged.listen((event) {
      final accessNetwork = event == ConnectivityResult.mobile;
      _onAccessNetworkChanged(accessNetwork);
  });

 void _onAccessNetworkChanged(bool accessNetwork) {
    if (accessNetwork) {
      _analytics.addFlushPolicy([ImmediatelyFlushPolicy()]);
    } else {
      _analytics.removeFlushPolicy(_analytics.getFlushPolicies());
    }
  }


class ImmediatelyFlushPolicy extends FlushPolicy {
  @override
  start() {
    shouldFlush = true;
  }
}

I found that if uploading an event fails, it will not retransmit the event. Is there any way to upload the event again? Or can you know whether each event was uploaded successfully and re-upload these events through custom code?

image
@edsonjab
Copy link
Contributor

Hi @Jay-57blocks you can create your own plugin or policy to identify that part of process, you can check our documentation about that HERE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants