Skip to content
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

isFeatureEnabled now returns true if multivariant flag #42

Merged
merged 4 commits into from
Oct 9, 2023

Conversation

marandaneto
Copy link
Member

@marandaneto marandaneto commented Oct 8, 2023

💡 Motivation and Context

By doing #41 I noticed that isFeatureEnabled is also wrong.

I also noticed that the iOS SDK never returns false if a flag has a false value.
https://github.com/PostHog/posthog-ios/blob/9298825fe26899a58b976d400254e0b050daa578/PostHog/Classes/PHGPostHog.m#L317
Is it a bug on the iOS SDK I believe, right?

💚 How did you test it?

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

@marandaneto
Copy link
Member Author

Actually, I am a bit confused, the decide API does not return the disabled feature flags.

By disabled I mean this:
Screenshot 2023-10-08 at 08 42 54

so if the flag is within the response payload, it is enabled, always, then the iOS implementation is correct.

Should isFeatureEnabled return false if the flag is within the payload but its value is false? on iOS this is never the case, it will always return true.
The older version of the Android SDK does what this PR is aiming to do.

@neilkakkar mind explaining?

@marandaneto marandaneto marked this pull request as draft October 8, 2023 07:00
@neilkakkar
Copy link

Decide returns all enabled flags, correct.

But just because a flag is enabled doesn't mean that the API will always return true. For example, if you have a filter on Country = X on the flag, the API will return false if you're outside country X.

Same for, say, if the rollout % is not 100%.

@neilkakkar
Copy link

Should isFeatureEnabled return false if the flag is within the payload but its value is false?

Correct, and nice finding!

@@ -25,7 +25,7 @@ configure<JavaPluginExtension> {

buildConfig {
useKotlinOutput()
packageName("com.posthog.internal")
Copy link
Member Author

Choose a reason for hiding this comment

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

@marandaneto marandaneto merged commit 9c7eaab into main Oct 9, 2023
8 checks passed
@marandaneto marandaneto deleted the fix/multivariant-flag branch October 9, 2023 11:30
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.

3 participants