Skip to content

Conversation

@dustinbyrne
Copy link
Contributor

Adds getFeatureFlagResult() method that returns both the feature flag value and payload in a single call while emitting $feature_flag_called.

Related to PostHog/posthog#43520

Changes

  • New FeatureFlagResult class with methods:

    • isEnabled() - whether the flag is enabled
    • getVariant() - the variant string for multivariate flags
    • getPayload() - the decoded JSON payload
    • getValue() - returns variant if set, otherwise the enabled boolean (matches getFeatureFlag() format)
  • New getFeatureFlagResult() method on both Client and PostHog classes

    • Returns FeatureFlagResult|null
    • Sends $feature_flag_called event for usage tracking
    • Supports all existing parameters (groups, personProperties, onlyEvaluateLocally, etc.)
  • Refactored getFeatureFlag() to delegate to getFeatureFlagResult() internally

  • Deprecated getFeatureFlagPayload() - it doesn't send the $feature_flag_called event, leading to missing usage analytics and confusion. Users should migrate to getFeatureFlagResult().

@dustinbyrne dustinbyrne marked this pull request as ready for review January 26, 2026 20:58
@dustinbyrne dustinbyrne requested a review from a team January 26, 2026 20:59
@posthog-project-board-bot posthog-project-board-bot bot moved this to In Review in Feature Flags Jan 26, 2026
Copy link
Contributor

@dmarticus dmarticus left a comment

Choose a reason for hiding this comment

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

also clean

@github-project-automation github-project-automation bot moved this from In Review to Approved in Feature Flags Jan 27, 2026
@dustinbyrne dustinbyrne merged commit 9be5ec5 into master Jan 27, 2026
14 checks passed
@github-project-automation github-project-automation bot moved this from Approved to Done in Feature Flags Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants