Comments (7)
Hi @grzegorzkrukowski! We looked into how we'd like to address this a little more and we think a stackable flush policy is probably the way to go, along with some access to the storage made public. I don't currently have an ETA on when this will be complete yet. It does look like you have a temporary workaround going at the moment though. We've made a ticket internally that links back to here and will continue moving forward.
from analytics-swift.
Happy to report this is fixed now.
Please see Analytics-Swift 1.4.4; Specifically there's an example flush policy implementation here: https://github.com/segmentio/analytics-swift/blob/main/Examples/tasks/NetBlockerFlushPolicy.swift
You can see it in use in the MacExample application.
from analytics-swift.
Looking at this today.
from analytics-swift.
@grzegorzkrukowski could you have a look at or maybe try the PR above and see if it resolves the issue for you? Thanks!
from analytics-swift.
hey @bsneed I am afraid it won't really help in our case at least. Spikes will still happen every time application goes from background to foreground when flush
is triggering independently from the timer itself.
The main problem I think is inside a flush
execution itself. It opens all existing cached files and creates a network request for every single one. Those requests are then canceled straight away by Little Snitch.
If I keep going from background -> foreground that triggers flush()
- it's a never-ending growing problem.
I think the logic should be rebuilt to handle a huge amount of events that will be never send properly - that's our case.
And currently, it leads to growing infinitely growing Storage and the flush
method freezing the application when it executes. I am afraid it has nothing to do with a timer itself, sorry.
I think what will fix spikes is as suggested:
- take one event only, try to send it, and then if that worked, send another batch - instead of reading all existing cached batches and creating thousands of network requests at once
- on top of that to resolve a problem of infinite storage - I think there should be a maximum amount of files allowed only and in case of cache grow over it when creating new files some of the old ones should be discarded.
from analytics-swift.
Thanks for the quick response @grzegorzkrukowski, I'll revisit this and see how to make that happen. It's likely though that we'll separate out the storage thing into something else. We have SLAs around data loss and capping it would result in that so will continue thinking on how to best solve that problem separately.
from analytics-swift.
Ok, I understand your perspective. At the moment the biggest issue at least for us is flush
method logic that is really heavy if you try to resend every cached batch on each flush
call - creating all those network calls.
From my debugging process, it seems that it's more about network calls themselves being recreated so often and in such a huge amount when all of 1500 requests created fail straight away.
On top of that, each background/foreground switch triggers it again.
So for me, an acceptable solution would be to just avoid that and rewrite logic that will handle a huge amount of cached batches better than the current one - using fewer resources.
You can easily reproduce the problem by installing any network blocking software, blocking segment.io traffic, and then tracking a huge amount of events. Once you have that setup, calling flush
and observing the activity monitor will show the mentioned problem. On top of that, we are also getting tons of network requests killed because they are created in a for-each loop that is for some of our users over a few thousand requests each time :/
My perspective is that we will never get any tracking from those users, but we don't want to have any performance issues because of their decision to block traffic. Even if we will lose some tracking by opt-in for some "limit" settings - it would be fine for me.
from analytics-swift.
Related Issues (20)
- Crash inside DestinationMetadataPlugin during Analytics.update call HOT 12
- JSON encoding: lots of Codable-conforming types that crash in JSON encoding HOT 3
- SEGIntegration and SEGIntegrationFactory HOT 2
- Build fails: `isUnitTesting` only available in DEBUG mode HOT 2
- Question: Is it supported multiple instance write key? HOT 1
- Infinite loop of network failures contacting https://api.segment.io/v1/b HOT 13
- Some logs are uploaded with corrupted JSON/inline garbage data HOT 7
- Vendored Framework: "... is not a member type of ..." error HOT 9
- Traits payload is not attached to "track" events HOT 1
- Loosing events after upgrading to 1.5.7 HOT 11
- Adding a plugin to Analytics causes a circular reference HOT 6
- Rename of `JSONSafeEncoder` -> `JSONSafeEncoding` has broken previous releases HOT 4
- Force closing the app or updating to a newer version, causes the Segment.Analytics.init(configuration:) to call fatalError() HOT 11
- What's happened to 1.5.10? HOT 1
- Segment package versioning HOT 1
- Library does not automatically collect IAP Order Completed events, despite what docs say HOT 4
- iOSLifecycleEvents.application(didFinishLaunchingWithOptions:) is Compiled for More than 400 ms HOT 3
- 'shared' is inaccessible due to 'internal' protection level HOT 5
- Modify some context from Plugin HOT 1
- Crash at "specialized iOSVendorSystem.deviceModel()" HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from analytics-swift.