Flags
Use flags to remotely control the behavior of your application.
Confidence Flags in Portal lets you remotely control the behavior in your application, like a website or a mobile app. For example, use flags to control the visibility of a feature, the behavior of a feature, or the behavior of a service.
Create a Flag
Follow these steps to create a flag:
- Go to your Portal instance and select Confidence flags on the left sidebar.
- Click + Create to create a new flag.
- Give the flag a name that can be used to uniquely identify it. It can't be changed later, so choose wisely.
- Select the clients that can use the flag.
Use a name that is understandable and memorable. For example, new-navbar
.
Avoid too long names, and don't include the configuration in the name itself.
For example, don't use new-navbar-mobile-experience
, or new-navbar-enabled
as the name of the flag.
The last step of the flag creation process is to associate the flag with clients. Not all clients should have access to all flags. For example, some flags might be sensitive and should only be available to clients that are running in an trusted environment.
Mobile apps and websites batch resolve flags to reduce the number of requests made to Confidence. Associate a flag with a few clients as possible to limit the number of resolved flags.
To find instructions on how to use the SDKs for a particular flag, you can use Confidence's code snippet feature.
- Go to your Portal instance and select Confidence flags on the left sidebar.
- Go to the flag you want to preview the code for.
- Click Code snippets on the right sidebar.
- Select client and credential that you want to preview the code for.
- Pick the SDK you're interested in.
The code snippet shows you how to install, initialize, and resolve using the Confidence SDK.
You can associate a flag with more clients by following these steps:
- Go to your Portal instance and select Confidence flags on the left sidebar.
- Select the flag you want to add a client to.
- Click the icon next to Clients on the right sidebar to open up the clients dialog.
- Select the clients that should be able to resolve the flag.
- Click Save.
Archive a Flag
When a flag is no longer needed, you can archive it. Archiving a flag prevents clients from resolving and using it.
- Go to your Portal instance, and select Confidence flags on the left sidebar.
- Select the flag you want to archive.
- Click Archive in the right menu.
Edit Schema
Flags don't just describe a boolean decision to enable or disable a feature. Instead, flags have multiple properties that you use to control multiple aspects of the experience. The flag schema defines the available properties and their data type. The schema lets applications consume the flag value while knowing what to expect.
Confidence supports the following data types in the schema:
Type | Description | Example values |
---|---|---|
String | A string | "HELO" |
Integer | An integer | 42 , 199932 |
Double | A double | 3.14 , 50.0 |
Boolean | Boolean | true , false |
Struct | Nested structure | { age: 23, country: "SE } |
- Use short and descriptive name of the properties. For example,
color
is great. - Use boolean properties to represent the state of a feature. For example, use
enable
to represent if you should enable a feature or not. - Use kebab-case for property names:
result-count
is better thanresultCount
. - Avoid putting too much information in the name. For example,
color
is better thanbgColor
.
You can always add new properties to the schema.
Program your clients so that they can always handle the presence of new properties in flag value.
You can change the name of a property if no variant sets a value for that particular property. The same is true for deleting a property from the schema. You can only delete a property if no variant sets a value for it. A lock icon next to the property in the schema editor dialog indicates if at least one property uses a variant.
To edit the schema for a flag, follow these steps.
- Go to your Portal instance.
- On the left sidebar, select Confidence flags.
- Go to the flag you want to edit the schema for.
- Click the edit icon next to Schema at the right sidebar of the flag detail page.
- Click Add property to add a new field to the schema.
- Select the type of the field, and give it a name.
Create a Variant
Use variants to implement different experiences of a flag.
A variant is a named set of values for the properties of the flag.
To create a variant, follows these steps.
- Go to your Portal instance.
- On the left sidebar, select Confidence flags.
- Go to the flag you want to add a variant to.
- Click Create variant on the flag page.
- Enter a name for the variant, and click Next.
- Optional. Enter a description, and input values for the properties of the flag.
Use short and descriptive names, informed by the provided experience. Use
kebab-case, like blue
instead of Blue
, and don't include too much
information: use blue
instead of blue-button-color
. Avoid including the
name of the flag in the variant name.
If a variant doesn't specify the value of a property, the SDK uses the default value specified when a client resolves the flag.