Problem reported that StartupFlushPolicy wouldn't send the pending upload events from the previous app launch.
Caused by concurrency: FlushPolicies get initialized before and without awaiting for storage restoration. Futhermore the Queue for upload is managed by the SegmentDestination plugin so there's no explicit way to await for that queue to be restored from the base client itself.
Solution:
Move the flush policy initialization later in the client: after plugins are initialized but before replaying buffered events
Refactor StartupFlushPolicy to mark shouldFlush outside of start (this is to be able to handle it with the manualFlush)
Refactor QueueFlushingPlugin and SegmentDestination to await for queue restoration and settings load when a flush is triggered. This guarantees that if the flush is triggered before the plugins are fully initialized (previous session events loaded) it will await for those operations to complete before uploading any events.
Problem reported that StartupFlushPolicy wouldn't send the pending upload events from the previous app launch.
Caused by concurrency: FlushPolicies get initialized before and without awaiting for storage restoration. Futhermore the Queue for upload is managed by the SegmentDestination plugin so there's no explicit way to await for that queue to be restored from the base client itself.
Solution:
shouldFlush
outside ofstart
(this is to be able to handle it with themanualFlush
)QueueFlushingPlugin
andSegmentDestination
to await for queue restoration and settings load when a flush is triggered. This guarantees that if the flush is triggered before the plugins are fully initialized (previous session events loaded) it will await for those operations to complete before uploading any events.