Feature management [prod]

[prod] - this CodeBud feature is also available in production mode.

What is feature management

Traditionally, shipping a new application feature requires a complete redeployment of the application itself. Testing a feature often requires multiple deployments of the application. Each deployment might change the feature or expose the feature to different customers for testing.

Feature management is a modern software-development practice that decouples feature release from code deployment and enables quick changes to feature availability on demand. It uses a technique called feature flags (also known as feature toggles and feature switches) to dynamically administer a feature's lifecycle.

Feature management helps developers address the following problems:

  • Code branch management: Use feature flags to wrap new application functionality currently under development. Such functionality is "hidden" by default. You can safely ship the feature, even though it's unfinished, and it will stay dormant in production. Using this approach, called dark deployment, you can release all your code at the end of each development cycle. You no longer need to maintain code branches across multiple development cycles because a given feature requires more than one cycle to complete.
  • Test in production: Use feature flags to grant early access to new functionality in production. For example, you can limit access to team members or to internal beta testers. These users will experience the full-fidelity production experience instead of a simulated or partial experience in a test environment.
  • Flighting: Use feature flags to incrementally roll out new functionality to end users. You can target a small percentage of your user population first and increase that percentage gradually over time.
  • Instant kill switch: Feature flags provide an inherent safety net for releasing new functionality. You can turn application features on and off without redeploying any code. If necessary, you can quickly disable a feature without rebuilding and redeploying your application.

Learn more about feature management here: https://learn.microsoft.com/en-us/azure/azure-app-configuration/concept-feature-management

Basic Feature Management with CodeBud

Feature management is done with remote settings object. You can edit remote settings on the Control tab in GUI. CodeBud provides you 3 environments for your feature flags: "dev", "stg" and "prod".

First, setup CodeBud project and pass project id to init method.

CodeBud provides you several ways to get Remote Settings state on client side:

remoteSettings getter Returns remote settings objects for each env

const remoteSettings = CodeBud.remoteSettings; // {dev: {...}, stg: {...}, prod: {...}}

getRemoteSettingsByEnv method Returns single remote settings object for chosen env

const remoteSettingsDev = CodeBud.getRemoteSettingsByEnv("dev"); // {...}

refreshRemoteSettings method Forces CodeBud to re-fetch your feature flags, has callback.

CodeBud.refreshRemoteSettings((remoteSettings) => {
  console.log('Here remoteSettings', remoteSettings); // {dev: {...}, stg: {...}, prod: {...}}
}

useRemoteSettings hook

You can learn more about this hook on this page

About preferable flags

CodeBud remote settings feature is currently in Beta. So 100% server uptime is not guaranteed. Therefore, you might want to use remote settings only while in development and not in production. This is possible with "preferable" setting.

"Preferable" setting toogle is located in top-right corner of Control tab in GUI.

"Preferable" setting toogle is located in top-right corner of Control tab in GUI.

This setting is personal (bonded to your apiKey). So it won't affect other members of selected project experience.
You can choose different "preferable" setting for each of your project.

Usage examples:
In order to choose between different feature flags sets (or between any data) depending on preferable setting, you can use following methods:

getIsRemoteSettingsPreferableForSelectedProject method
Returns true if CodeBud remote settings are currently preferable for your project and false - otherwise. Note: if package mode is "prod", false will be returned.

const preferableFlag = CodeBud.getIsRemoteSettingsPreferableForSelectedProject() ? flagFromCodeBud : flagFromOtherProvider;

getPersonalPreferableValueForSelectedProject method
Takes 2 args and returns one of them depending on package mode and your personal "preferable" setting for chosen projectId.

const preferableFlag = CodeBud.getPersonalPreferableValueForSelectedProject(flagFromCodeBud, flagFromOtherProvider);
const preferableFeatureFlagsSet = CodeBud.getPersonalPreferableValueForSelectedProject(codebudRemoteSettings, allFlagsFromOtherProvider);

refreshPersonalProjectsSettings method
Forces CodeBud to re-fetch your personal projects settings (including "preferable" setting), has callback.

  CodeBud.refreshPersonalProjectsSettings((settings) => {
    console.log("Settings:", settings); // {
                                        //   '<project_id_1>': { ... },
                                        //   '<project_id_2>': { ... },
                                        //   ...,
                                        //   '<project_id_n>': { ... }
                                        // }
  });

Was this page helpful?