Skip to content

feat: Add getFeatureFlagResult API#279

Open
dustinbyrne wants to merge 5 commits intomainfrom
feat/get-feature-flag-result
Open

feat: Add getFeatureFlagResult API#279
dustinbyrne wants to merge 5 commits intomainfrom
feat/get-feature-flag-result

Conversation

@dustinbyrne
Copy link

@dustinbyrne dustinbyrne commented Feb 5, 2026

💡 Motivation and Context

Add a getFeatureFlagResult API that returns a unified PostHogFeatureFlagResult object containing the flag key, enabled state, variant (for multivariate flags), and payload in a single call. Previously, getting full flag information required separate calls to getFeatureFlag and getFeatureFlagPayload. This also supports a sendEvent parameter to suppress the $feature_flag_called event when only the payload is needed.

getFeatureFlagPayload is now deprecated in favor of this new method.

💚 How did you test it?

  • Added unit tests for PostHogFeatureFlagResult (fromValueAndPayload, fromMap, equality, toString, null/edge cases)
  • Added integration tests via a fake platform interface covering boolean flags, multivariate flags, payloads, null values, and sendEvent parameter forwarding
  • Updated the example app to exercise getFeatureFlagResult
  • Manually verified native Android and iOS implementations serialize the result map correctly via method channels

📝 Checklist

  • 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.

@dustinbyrne dustinbyrne requested a review from a team as a code owner February 5, 2026 18:38
@dustinbyrne dustinbyrne force-pushed the feat/get-feature-flag-result branch from 6458f44 to 7bf8fa6 Compare February 5, 2026 18:40
@dustinbyrne
Copy link
Author

CI will fail until PostHog/posthog-ios#459 is released

@dustinbyrne dustinbyrne changed the title feat: Add getFeatureFlagPayload API feat: Add getFeatureFlagResult API Feb 5, 2026
@dustinbyrne dustinbyrne force-pushed the feat/get-feature-flag-result branch from 7bf8fa6 to 483265d Compare February 5, 2026 19:03
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.

1 participant