-
Notifications
You must be signed in to change notification settings - Fork 88
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
Flush-only disabling for client-specific (e.g., expensive internet) conditions #361
Comments
Hi @cprince-foreflight! It sounds like what you want is a custom flush policy. You can see an example one here: https://github.com/segmentio/analytics-swift/blob/main/Examples/tasks/NetBlockerFlushPolicy.swift There's also the default ones that might be useful as working examples too. Once you've made one, you'd add it to your analytics config like so ... analytics.add(policy: ExpensiveNetworkPolicy) I notice that the flush policy stuff isn't documented terribly well and have filed an internal ticket to improve that. Let me know if you need any assistance, happy to help. |
Thanks. We are solving this right now via a custom flush policy. And within that using a long (infinite) |
No problem! Yeah, we can probably do better than that. I did find a bug in the policies in that they're flushing too often right now. I'm going to fix that, and I'll also come back here in just a bit with an example of how to structure yours. Gimmie just a few and I'll be back. |
Heya @cprince-foreflight, if you could have a look at this example: https://github.com/segmentio/analytics-swift/blob/main/Examples/tasks/UncleFlushPolicy.swift If you try that against main and can verify that meets your needs, lemme know and I'll do a release for you. If you need further changes, etc, I can do that too. I'll leave this issue open till I hear from you. Thanks so much! |
I just needed to do a release for another issue. Please reopen this if necessary. |
Thanks! I'm passing this onto my colleague who was actually looking into this. |
Is your feature request related to a problem? Please describe.
Some of our users have expensive internet connections. They don't want to pay for sending Segment events while only that expensive internet is available.
Describe the solution you'd like
What I'd like is a dynamic means (e.g., a Swift closure) that can be called near here to determine whether or not to flush analytics events. This could be setup in the
Configuration
.Right now, there is a general purpose
enabled
flag, but if that isfalse
, as far as I understand it, that will also disable events from being persisted.What we want is a means to specifically disable flushing, but still have new events persisted.
Describe alternatives you've considered
We are planning to setup our own change (just locally, on top of your SDK) using a long
flushInterval
to effectively disable only flushing.Additional context
This is for an aviation related app.
The text was updated successfully, but these errors were encountered: