You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: flush events on app pause and make close() awaitable - #110
Part of Flagsmith/flagsmith-private#302 (epic Flagsmith/flagsmith-private#362). Covers the background flush and the awaitable close().
Changes
Buffered events are flushed when the app becomes hidden, paused or detached. inactive is skipped because it fires on Control Center and incoming calls. If the client is created before the Flutter binding is initialised, the lifecycle hook is skipped with a debug log instead of throwing.
close() returns Future<void> and takes an optional timeout (10 s by default). It completes once the final POST finishes or the timeout passes, and never throws. Events tracked after close() are still dropped (fix: drop events tracked after close() #97).
README documents when events are flushed, the best-effort limits (iOS suspension, force-quit, web unload) and shutdown.
API change
close() changes from void to Future<void>. Existing client.close(); calls still compile. Subclasses that override close() and fakes that implement FlagsmithClient need to update their signature.
Tests
Background flush on hidden/paused/detached; no flush on inactive.
await close() waits for the POST; close(timeout:) returns when a slow POST outlasts the timeout.
close() removes the lifecycle listener.
Creating a client before the Flutter binding exists doesn't throw (own test file, so it doesn't depend on test order).
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: ASSERTIVE
Plan: Advanced
Run ID: 147b7047-b096-4d21-84b9-ca99034dd865
Commits
Reviewing files that changed from the base of the PR and between e2a0f46 and 67e9eb0.
Files selected for processing: 3
lib/src/flagsmith_client.dart
test/fg/flagsmith_experiments_test.dart
test/fg/flagsmith_no_binding_test.dart
Walkthrough
The event processor’s stop() method now returns a future that completes after its flush. FlagsmithClient registers a lifecycle observer when events are enabled and flushes buffered events on hidden, paused and detached. Its asynchronous close() waits for the final flush up to a configurable timeout and performs client cleanup. Tests cover lifecycle flushing and close timing. The README documents these behaviours and the updated close() signature.
Shutdown correctly waits for pending uploads within its timeout, but a throwing custom logger can make close fail despite its non-throwing contract. This narrow issue warrants a bounded fix or owner acceptance.
- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Buffered events are flushed when the app becomes hidden, paused or
detached. close() now returns Future<void> that completes once the final
POST finishes or the timeout (10 s by default) passes. Subclasses that
override close() must update their signature.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: ASSERTIVE
Plan: Advanced
Run ID: 39201eab-1fe1-46e8-b913-d27660b344c1
Commits
Reviewing files that changed from the base of the PR and between ad7295e and e2a0f46.
Files selected for processing: 4
README.md
lib/src/core/events/event_processor.dart
lib/src/flagsmith_client.dart
test/fg/flagsmith_experiments_test.dart
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of Flagsmith/flagsmith-private#302 (epic Flagsmith/flagsmith-private#362). Covers the background flush and the awaitable
close().Changes
hidden,pausedordetached.inactiveis skipped because it fires on Control Center and incoming calls. If the client is created before the Flutter binding is initialised, the lifecycle hook is skipped with a debug log instead of throwing.close()returnsFuture<void>and takes an optionaltimeout(10 s by default). It completes once the final POST finishes or the timeout passes, and never throws. Events tracked afterclose()are still dropped (fix: drop events tracked after close() #97).API change
close()changes fromvoidtoFuture<void>. Existingclient.close();calls still compile. Subclasses that overrideclose()and fakes that implementFlagsmithClientneed to update their signature.Tests
hidden/paused/detached; no flush oninactive.await close()waits for the POST;close(timeout:)returns when a slow POST outlasts the timeout.close()removes the lifecycle listener.