Dynamic Flags – Feature Release

By Ben Rometsch on April 8, 2021

We just launched our latest platform upgrade, Dynamic Flags. We’re super excited about this release as it’s a core addition to the Flagsmith platform. At a high-level, Dynamic Flags enables you to be a lot more expressive with your feature flags and lays the foundations for our upcoming major feature release: Multivariate Flags!

When we first started working on Flagsmith in 2017, we wanted to be able to control more than just boolean flags, and so we built the platform with the ability to manage other primitives too: Strings, Integers, and Floats. We called these flags “Remote Config”.

Up until now, flags had to be one or the other; either Booleans or Remote Config values. With Dynamic Flags, you can leverage both of these concepts together in a single flag. Basically, we merged Booleans and Remote Config together. We call this Dynamic Flags.

Let’s demonstrate this via some code. We can now write something like this:

1int fontSize = 12;
2
3if (flagsmithClient.hasFeatureFlag("override_font_size") {
4
5    fontSize = flagsmithClient.getFeatureFlagValue("override_font_size")
6
7}

Note that we are using the same single feature flag here both to control whether the font size is overridden at all (the boolean) and if so what the font size should be (the config value). 

Let’s jump into a couple of examples. 

  1. You want to be able to control whether a feature is enabled within your product. If the feature is disabled, you also want to be able to control a message to your users with an explanation as to why the feature is missing. Prior to Dynamic Flags, you would have needed to create two flags to achieve this; one to control the feature boolean and the other to manage to message text. With Dynamic Flags, you can manage the feature showing, and the message text directly with one flag.
  2. You’re building an ecommerce store, and want to be able to control flash sales on your site. Feature flags are a perfect use case for this. With Dynamic Flags, you can use the boolean to control whether the flash sale is running, but you could also control the % discount your customers receive within the same flag, as an Integer value.

Dynamic Flags also work perfectly with Segments, so you can override both the boolean and the config value on a per Segment basis too. 

This change was pretty seamless; the SDK clients and SDK REST endpoints don’t need to be upgraded. You can simply call `hasFeatureFlag(“flag_name”)` as well as `getFeatureFlagValue(“flag_name”)`

This has also cleared up our UI a fair amount – you no longer have to worry about what type of flag you want to create up front. Hopefully this allows you to reduce the number of flags within your platform by combining relevant flags that you had in pairs.