Repository navigation
chore!: pass the loaded flags to onFeatureFlags and reloadFeatureFlags #664
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
Merged
turnipdabeets
merged 10 commits into
chore/v6-adopt-posthog-android-4
from
chore/v6-flags-loaded-result
Oct 28, 2026
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
705c311
chore!: pass the loaded flags to onFeatureFlags and reloadFeatureFlags
turnipdabeets 0fe81a2
fix: complete the web reloadFeatureFlags with the reloaded flags
turnipdabeets bde0b01
chore: use PostHogFeatureFlagsCallback from posthog-android 4.0
turnipdabeets 0c7aea5
chore: fix ktlint function-signature
turnipdabeets 17d0d81
fix: await posthog-js reloadFeatureFlagsAsync on web
turnipdabeets d1e15d4
docs: pass the loaded flags in the setup example
turnipdabeets 0a7ab2a
docs: drop best-effort web note from the person and group property me…
turnipdabeets a406020
fix(web): wait for posthog-js flags retries before reporting a reload…
turnipdabeets 0e8a97b
docs: note where onFeatureFlags and errorsLoading differ on Android a…
turnipdabeets 288fce2
docs: describe the older posthog-js reload timeout as the full retry …
turnipdabeets File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "posthog_flutter": major | ||
| --- | ||
|
|
||
| - **Breaking:** `PostHogConfig.onFeatureFlags` now receives a `PostHogFeatureFlagsLoaded` with the enabled flags, their values and whether loading failed. Update callbacks from `() { ... }` to `(loaded) { ... }` (or `(_) { ... }`) | ||
| - **Breaking:** `reloadFeatureFlags()` now returns a `Future<PostHogFeatureFlagsLoaded>` with the reloaded flags |
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| /// The feature flags passed to [PostHogConfig.onFeatureFlags] and returned by | ||
| /// [Posthog.reloadFeatureFlags]. | ||
| /// | ||
| /// Only enabled flags are included. When the latest load failed, | ||
| /// [errorsLoading] is `true` and the flags are the last known values, which | ||
| /// can be empty. | ||
| /// | ||
| /// **Example:** | ||
| /// ```dart | ||
| /// final config = PostHogConfig('<project_token>') | ||
| /// ..onFeatureFlags = (loaded) { | ||
| /// if (loaded.errorsLoading) { | ||
| /// // The values are the last known (cached) flags. | ||
| /// } | ||
| /// if (loaded.variants['new-checkout'] == 'test') { | ||
| /// // Show the test variant. | ||
| /// } | ||
| /// }; | ||
| /// ``` | ||
| class PostHogFeatureFlagsLoaded { | ||
| /// The keys of the enabled feature flags. | ||
| List<String> get flags => List.unmodifiable(variants.keys); | ||
|
|
||
| /// The values of the enabled feature flags, keyed by flag key. | ||
| /// | ||
| /// A value is `true` for an enabled boolean flag, or the variant [String] | ||
| /// for a multivariate flag. Disabled flags are not included. | ||
| final Map<String, Object> variants; | ||
|
|
||
| /// Whether the latest attempt to load feature flags failed. | ||
| /// | ||
| /// When it did, [flags] and [variants] hold the last known values. | ||
| /// | ||
| /// **Flutter web:** when [PostHogConfig.onFeatureFlags] is first set, it is | ||
| /// called right away with the current flags and `false`, even if | ||
| /// posthog-js's last load before that failed. | ||
| final bool errorsLoading; | ||
|
|
||
| /// Creates the loaded feature flags from [variants], keeping only enabled | ||
| /// flags: `true`, or a non-empty variant string. | ||
| PostHogFeatureFlagsLoaded({ | ||
| required Map<String, Object?> variants, | ||
| required this.errorsLoading, | ||
| }) : variants = Map.unmodifiable({ | ||
| for (final MapEntry(:key, :value) in variants.entries) | ||
| if (value == true || (value is String && value.isNotEmpty)) | ||
| key: value!, | ||
| }); | ||
|
|
||
| @override | ||
| String toString() => | ||
| 'PostHogFeatureFlagsLoaded(variants: $variants, errorsLoading: $errorsLoading)'; | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.