growthbook / growthbook

Open Source Feature Flagging and A/B Testing Platform
https://www.growthbook.io
Other
6.07k stars 489 forks source link

[Feature] Add a column with example values and/or a format to targeting attributes #2511

Open tim06927 opened 4 months ago

tim06927 commented 4 months ago

Description of Feature

Regularly, our users make mistakes in the format and possible values a targeting attribute can contain. It would be great if in the UI there are additional columns for targeting attributes that contain possible and example values and describe the formatting. For example in an attribute like country it is not instantly clear if a user should enter the long name of a country ("United States", "Germany") or something shorter ("us", "de"). Further, in many environments, the field is case-sensitive. Best case, there would be some Regex validation when setting up a rule with an attribute.

jdorn commented 4 months ago

On thing we can do, which is fairly easy, is add more built-in options for string format when configuring attributes. Most obvious are various ISO date and ISO country code formats, but we could also do email, uri, ipv4, etc. These formats can be used for validation, but also providing a better UI (e.g. datetime picker or dropdown with all possible country codes).

A more advanced version, which will be harder to implement, is full JSON Schema support to allow arbitrary regex validation, min/max length, and more.

fabianmarinog commented 4 months ago

@jdorn what if a text field is added to configure the values of the targeting attribute? It would be like typing the only possible and case-sensitive values of the attribute. Of course, this would be optional and the current option would be the default.

jdorn commented 4 months ago

@fabianmarinog I believe what you're asking for already exists. You can set up an "enum" attribute and then list out all the possible values. Users will be shown a drop-down instead of a freeform text box.

christos commented 3 months ago

You can set up an "enum" attribute and then list out all the possible values. Users will be shown a drop-down instead of a freeform text box.

@jdorn We use the enum approach for ISO codes (country/locale) but it breaks down when using the is in the list operator which is free text and doesn't offer the enum values as options.

Even so, when working with ISO codes, some of the country/language values are too similar and easy to confuse. If enums were instead a name/value pair we could use the full name of a country and its matching ISO code.

jdorn commented 2 months ago

I think there are a few small changes we can make for this that should be pretty easy

  1. Allow specifying key/value pairs for enum options
  2. Use the enum values with the in the list operator input
  3. Add 2 new string format options for ISO 2 and 3 digit country codes. This would just be a shortcut so you don't have to manually type out and format 200+ enum name/value pairs