Skip to content

feat!: remove PostHogConfig.onFeatureFlags in favor of the listener - #918

Merged
turnipdabeets merged 5 commits into
chore/v4-remove-deprecatedfrom
feat/v4-remove-config-on-feature-flags
Nov 2, 2026
Merged

turnipdabeets merged 5 commits into
chore/v4-remove-deprecatedfrom
feat/v4-remove-config-on-feature-flags

Conversation

@turnipdabeets

Copy link
Copy Markdown
Contributor

💡 Motivation and Context

Stacked on #917. Makes PostHog.onFeatureFlags(callback) the only flag-load listener, matching posthog-ios 4.0 and posthog-js. The listener already does what the config field did: it can be registered before setup(), gets bootstrapped flags, and can also be removed.

Breaking: removes PostHogConfig.onFeatureFlags. Migration: call PostHog.onFeatureFlags { ... } before setup(). reloadFeatureFlags(callback) stays.

Behavior differences for anyone migrating:

  • The callback runs on the main thread on Android (the field ran on a background thread).
  • Bootstrapped flags arrive just after setup() is called, not synchronously inside it.
  • A reload on a disabled SDK doesn't call listeners. It did call the field with errorsLoading=true; reloadFeatureFlags(callback) still gets that.

posthog-server keeps its own onFeatureFlags config, which is a separate callback.

💚 How did you test it?

  • :posthog:test, :posthog-android:testReleaseUnitTest, :posthog-server:test, :posthog-server-openfeature:test, :posthog-android-surveys-compose:testDebugUnitTest, samples compile, apiCheck, spotlessCheck.
  • Config-field tests moved to the listener where they guarded a distinct risk. Mutation-checked: using the current generation instead of the one captured in setup() fails the close-from-an-integration test.

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.

Question Android iOS
Listener registered before setup() gets the first load (cold start) {known-on, checkout}, errorsLoading=false same
Bootstrap values reach it, before the network load {boot-flag, boot-variant}, then the /flags values same
/flags 500 on relaunch last known flags, errorsLoading=true same
Late listener gets current flags once once, then once per reload same

📝 Checklist

  • All commits are signed (see Commit signing)
  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

If releasing new changes

  • Ran pnpm changeset to generate a changeset file

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

🤖 Generated with Claude Code

The canonical client signature has no default and iOS, Flutter and RN have
none. A fallback was also reported as the flag value in $feature_flag_called.
A disabled SDK now returns null; isFeatureEnabled keeps its defaultValue.
The onFeatureFlags() listener can be registered before setup(), gets bootstrapped
flags, and is removable, so the config field no longer adds anything. iOS and
posthog-js only have the listener form.

@marandaneto marandaneto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good; no qualifying findings. Verdict: correct.

Base automatically changed from feat/v4-remove-get-feature-flag-default to chore/v4-remove-deprecated November 2, 2026 15:08
@turnipdabeets
turnipdabeets merged commit f106ead into chore/v4-remove-deprecated Nov 2, 2026
12 checks passed
@turnipdabeets
turnipdabeets deleted the feat/v4-remove-config-on-feature-flags branch November 2, 2026 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants