Repository navigation
feat!: remove PostHogConfig.onFeatureFlags in favor of the listener - #695
Merged
turnipdabeets merged 12 commits intoNov 3, 2026
Merged
turnipdabeets merged 12 commits into
turnipdabeets merged 12 commits into
Conversation
Posthog().onFeatureFlags() can be registered before setup() and removed, so the config field no longer adds anything. Android now drives Dart from the posthog-android listener like iOS does, which also fires after a manual reload, so the Dart-side Android reload delivery goes away.
Contributor
posthog-flutter Compliance ReportDate: 2026-11-03T18:47:01.670156+00:00 ✅ All Tests Passed!47/47 tests passed Capture Tests✅ 30/30 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
|
…r' into phase3/695 # Conflicts: # .changeset/v6-posthog-ios-4.md
marandaneto
reviewed
Nov 2, 2026
marandaneto
left a comment
Member
There was a problem hiding this comment.
Automated advisory code review.
eli-r-ph
reviewed
Nov 2, 2026
5 of 6 tasks
…-feature-flags Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
5 of 6 tasks
…r' into feat/v6-remove-config-on-feature-flags
5 of 6 tasks
…-feature-flags Keeps 2cd9136's stop when a listener's reset() or close() clears a load. deliver() returns void again, since no config callback reads its result. Co-Authored-By: Claude Opus 5.5 <[email protected]>
4 of 11 tasks
eli-r-ph
approved these changes
Nov 3, 2026
turnipdabeets
merged commit Nov 3, 2026
e9a2ab0
into
feat/v6-on-feature-flags-listener
20 of 23 checks passed
turnipdabeets
added a commit
that referenced
this pull request
Nov 3, 2026
* chore!: adopt posthog-ios 4.0 - Require posthog-ios 4.x. - Adapt to the reloadFeatureFlags(_:) callback that now passes a PostHogFeatureFlagsLoaded (PostHog/posthog-ios#913). - Note the payload decoding changes from PostHog/posthog-ios#903. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * docs(changeset): note posthog-ios 4.0 drops lifecycle version and build PostHog/posthog-ios#905 removes the legacy version/build properties from lifecycle events in 4.0, so Flutter iOS and macOS apps stop sending them. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * chore(ios): drive onFeatureFlags from the posthog-ios onFeatureFlags listener posthog-ios 4.0 removes the didReceiveFeatureFlags notification. * chore!: adopt posthog-android 4.0 (#663) * chore!: adopt posthog-android 4.0 * chore!: pass the loaded flags to onFeatureFlags and reloadFeatureFlags (#664) * chore!: pass the loaded flags to onFeatureFlags and reloadFeatureFlags onFeatureFlags and reloadFeatureFlags now carry a PostHogFeatureFlagsLoaded with the enabled flags, their values and whether loading failed, matching posthog-ios 4.0 and posthog-android 4.0. On web, reloadFeatureFlags completes right away with the flags loaded so far, because posthog-js doesn't report when a reload finishes. * fix: complete the web reloadFeatureFlags with the reloaded flags Wait for the next posthog-js onFeatureFlags call instead of returning the flags already loaded, so a failed reload reports errorsLoading. Complete right away when flags are disabled, and after twice the flags request timeout when posthog-js skips the request without calling back. * chore: use PostHogFeatureFlagsCallback from posthog-android 4.0 * chore: fix ktlint function-signature * fix: await posthog-js reloadFeatureFlagsAsync on web The next onFeatureFlags callback can carry a response from a request already in flight, so reloadFeatureFlags() could complete with flags from before the reload. posthog-js 1.438.2+ settles reloadFeatureFlagsAsync() after this reload's own request; use it when present and keep the callback path for older posthog-js. * docs: pass the loaded flags in the setup example * docs: drop best-effort web note from the person and group property methods * fix(web): wait for posthog-js flags retries before reporting a reload failure posthog-js retries a timed-out /flags request once by default, 500 ms later, inside the same reload. The older-JS deadline of twice the request timeout reported cached flags with errorsLoading set before a successful retry landed. * docs: note where onFeatureFlags and errorsLoading differ on Android and web * docs: describe the older posthog-js reload timeout as the full retry budget Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]> * docs(changeset): fold the posthog-android 4.0 and flags-loaded entries into one changeset Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat: add an onFeatureFlags listener you can unsubscribe * fix: isolate failing flag listeners, skip web registration without onFeatureFlags, update API snapshot * fix: deliver flag loads to onFeatureFlags listeners before the config callback A config callback that threw kept listeners from getting the load, and a reset() or close() it started was undone when the load was cached after it. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(web): stop flag registrations left by close() or the posthog-js loader A registration whose unsubscribe isn't stored yet (close() during the synchronous replay) or never arrives (the loader snippet's stub) now goes inert once setup() or close() runs again. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix: drop native flag loads sent before a reset or close reached native Dart bumps a generation when reset() or close() clears the listener registry and sends it with setup, reset and close. Android and iOS tag each onFeatureFlags notification with the generation they had when it fired, and Dart drops ones from an earlier generation, so the previous user's flags can't repopulate the replay cache. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix: start receiving native flag loads when the first listener is added With native auto-init, Posthog().onFeatureFlags() can be the app's only Dart SDK call, and nothing created the platform that installs the channel handler, so native loads never reached the listener. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix: deliver Android reloadFeatureFlags results to onFeatureFlags listeners posthog-android passes a manual reload only to its completion, so no onFeatureFlagsCallback arrives and listeners missed the load while new ones replayed the older snapshot. A reload that finishes after a reset or close is still dropped. Co-Authored-By: Claude Opus 5.5 <[email protected]> * chore: stop passing RRStyle to replay screenshot frames (#684) posthog-android 4.0 drops RRStyle and the wireframe tree fields from the internal RRWireframe; screenshot frames don't need a style. Co-authored-by: Claude Opus 5.5 <[email protected]> * fix(web): clear replayed flags when a queued reset reaches posthog-js Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs: fold #670 release notes into the 6.0 docs * fix: don't throw when SDK calls run before the Flutter binding exists Posthog() creates PosthogFlutterIO, whose constructor set the channel handler and aborted without a binding. Retry the install instead, and fail native calls with a PlatformException so each caller's existing fallback applies. * fix: stop delivering a flags load that a listener's reset() or close() cleared The listeners after it and the config callback no longer get the old flags. Claude-Session: https://claude.ai/code/session_019xLynws83apuXa9LfRy9Aq * feat!: remove PostHogConfig.onFeatureFlags in favor of the listener (#695) * feat!: remove PostHogConfig.onFeatureFlags in favor of the listener Posthog().onFeatureFlags() can be registered before setup() and removed, so the config field no longer adds anything. Android now drives Dart from the posthog-android listener like iOS does, which also fires after a manual reload, so the Dart-side Android reload delivery goes away. * docs: fold #695 release notes into the 6.0 docs * test: use the onFeatureFlags listener in desktop tests from the base merge * fix(example): initialize the binding before registering the flags listener * docs: show the removed onFeatureFlags constructor argument in the migration guide * test: use the flags listener in the #694 desktop tests Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
turnipdabeets
added a commit
that referenced
this pull request
Nov 3, 2026
… platform (#701) * docs: link the capture v1 SDK upgrade guide Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs: cover capture v1 on Windows and Linux and align the 6.0 guide with the backend SDK guides Claude-Session: https://claude.ai/code/session_019xLynws83apuXa9LfRy9Aq * docs: lone surrogates on Windows and Linux (#703) Claude-Session: https://claude.ai/code/session_019xLynws83apuXa9LfRy9Aq * docs: identify ignores a distinct ID with a lone surrogate (#703) Claude-Session: https://claude.ai/code/session_019xLynws83apuXa9LfRy9Aq * docs: complete the platform interface changes and the upgrade checklist Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs: document the final 6.0 state in the guide and one grouped changeset Folds in the MIGRATION.md and changeset text of #682, #698, #703, #670, #695 and #699 so landing this PR last is "take this side". Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs: describe lone surrogates as repaired on Windows and Linux Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs: cover the /flags request in the lone surrogate changeset entry Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs: note the /flags request in the lone surrogate guide line Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs: say the SDK keeps lone-surrogate ids as passed and repairs what it sends Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs: drop the confirmed capture v1 default TODOs from the guide Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs: say $locale follows a per-app language picked in macOS Settings too Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
💡 Motivation and Context
Stacked on #670. Ships with PostHog/posthog-android#918, which removes the field natively. #918 is merged into posthog-android's
chore/v4-remove-deprecatedbut not yetfeat/v4-capture-v1. This PR still builds againstfeat/v4-capture-v1, because the plugin only stops reading the field (built on Nov 3 through #699, which contains this PR). MakesPosthog().onFeatureFlags(callback)the only flag-load listener, matching iOS 4, Android 4 and posthog-js.Breaking: removes
PostHogConfig.onFeatureFlags. Migration: callPosthog().onFeatureFlags((loaded) { ... })beforesetup().PostHog.onFeatureFlagson engine attach and unsubscribes on detach, as the iOS/macOS plugin does.💚 How did you test it?
flutter analyze,flutter test(1318 passed, 1 skipped),scripts/check-api-dart.sh.flutter test --platform chromeon the two web files: the 3app versiontests fail, as reported on the base; the rest pass.Ran through the Flutter example with local posthog-android and posthog-ios against a local mock server (Android emulator API 37, iOS 26.4 simulator). Temporary overrides lived in a throwaway worktree.
setup()gets the first load (cold start){known-on, checkout},errorsLoading=false{boot-flag, boot-variant}, then the/flagsvalues/flags500 on relauncherrorsLoading=true🧪 How to test locally (for agents and reviewers)
CI's
build-androidandbuild-applejobs can't pass until posthog-ios and posthog-android 4.0 are released, because no 4.x version resolves yet. To test now, build against the nativefeat/v4-capture-v1branches. Don't commit these overrides.Android: check out
feat/v4-capture-v1of posthog-android, then:Add
mavenLocal()as the first repository inexample/android/build.gradle.kts. Use a new version for each republish, because Gradle can reuse a stale one.iOS/macOS: check out
feat/v4-capture-v1of posthog-ios and pointposthog_flutter/darwin/posthog_flutter/Package.swiftat it:Build: from
example/, with Swift Package Manager enabled (flutter config --enable-swift-package-manager), runflutter build apk --debugandflutter build ios --simulator --debug.Local server: set
config.hosttohttp://127.0.0.1:<port>.android:usesCleartextTraffic="true"to<application>and runadb reverse tcp:<port> tcp:<port>.NSAppTransportSecurity>NSAllowsArbitraryLoadsinRunner/Info.plist.{"hasFeatureFlags": true}from/array/<token>/config. Otherwise Android skips/flagsand reports empty flags.Run tests on a device with
flutter test integration_test/<file>.dart -d <device>.What to check on this PR: the same listener scenarios as #670, using its test and server, with listeners replacing
config.onFeatureFlags.📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
🤖 Generated with Claude Code