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

Feature flag support for Strings #13144

Closed
MarkLyck opened this issue Dec 5, 2022 · 7 comments
Closed

Feature flag support for Strings #13144

MarkLyck opened this issue Dec 5, 2022 · 7 comments
Labels
enhancement New feature or request feature/feature-flags Feature Tag: Feature Flags

Comments

@MarkLyck
Copy link

MarkLyck commented Dec 5, 2022

Is your feature request related to a problem?

I'm trying to migrate from LaunchDarkly but the current limitations with feature flags in PostHog is making that very difficult. The biggest of which is being unable to have a feature flag as a String or JSON

I have tried the Multivariate flags which allows a feature flag to be a "key", but that "key" is very limited. For example I'm not able to put a URL as a key because it violates some special key requirements.

Same issue with stringified JSON

Describe the solution you'd like

Allow multivariate feature flags (or any type of feature flag) that can hold a value such as a String.

Describe alternatives you've considered

Alternatively make a new feature flag type that can hold a value, similar to how FlagSmith does it.

Thank you for your feature request – we love each and every one!

@MarkLyck MarkLyck added the enhancement New feature or request label Dec 5, 2022
@MarkLyck MarkLyck changed the title Feature flag support Strings Feature flag support for Strings Dec 5, 2022
@weyert
Copy link
Contributor

weyert commented Dec 5, 2022

Yeah, this would be great to have

@mariusandra
Copy link
Collaborator

I'm really not sure why we have these requirements.

I mean... I even had to hack around this to store JSON as base64 encoded multivariate keys just to get around this ridiculous limitation :D.

I don't think there will be much friction to merge something like that if someone comes up with a PR... 🤔

@benjackwhite benjackwhite added the feature/feature-flags Feature Tag: Feature Flags label Dec 6, 2022
@weyert
Copy link
Contributor

weyert commented Dec 7, 2022

@mariusandra Do you have any tips, which changes would be necessary to accomplish this?

@neilkakkar
Copy link
Collaborator

There's no limitation on the backend @weyert , the API accepts any strings, so would mean going into the form and removing the condition here: https://github.com/PostHog/posthog/blob/master/frontend/src/scenes/feature-flags/featureFlagLogic.ts#L185 & then testing it works well.

This should work pretty well for basic strings. We're planning a bigger chunk of work for Q1 to allow arbitrary JSON payloads

@wallinslax
Copy link

I think it is a good practice to keep feature flag as toggle for simplicity.
Instead, treating string flag as structuralized feature flags might be a good direction.

For example:

instead of

if color == 'yellow':
  # do task 1
elif color == 'green':
  # do task 2
elif color == 'red':
  # do task 3

we can do

color = 'yellow'
isRed, isGreen = getFlags(color)
if isRed and isGreen:
  # do task 1
elif isGreen:
  # do task 2
elif isRed:
  # do task 3

@EDsCODE
Copy link
Member

EDsCODE commented Feb 7, 2023

Hey all! The first iteration of this has been released and is currently in beta with posthog-js/posthog-node support. Payloads are configurable for both boolean flags and multivariate flags.

Please send me an email at eric@posthog.com with your Posthog Cloud email if you want to give it a try!

@neilkakkar
Copy link
Collaborator

This is now available for general availability now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature/feature-flags Feature Tag: Feature Flags
Projects
None yet
Development

No branches or pull requests

7 participants