Feature flags & experiments

Monitor errors as you roll out features or run experiments and A/B tests by declaring your feature flag and experiment usage in the Bugsnag client. You can use the Features dashboard to identify whether these features have introduced errors into your app.

Declaring active feature flags and experiments

You should declare feature flag and experiment usage to Bugsnag at the time a feature or experiment is activated in your app. This ensures that subsequent errors will be associated with the feature flag or experiment usage accurately.

These operations are also available in configuration options. If feature or experiment usage is known at the time you initialize Bugsnag, you may wish to declare it in configuration, then update it later in the same app session if required.

You can declare the usage using the following methods on the Bugsnag client:

addFeatureFlag

Declare a single feature flag or experiment with variant as an optional second parameter.

await bugsnag.addFeature('Checkout button color', 'Blue');
await bugsnag.addFeature('New checkout flow');

addFeatureFlags

Declare multiple feature flags or experiments.

await bugsnag.addFeatureFlags(const [
  FeatureFlag('Checkout button color', 'Blue'),
  FeatureFlag('Special offer', 'Free Coffee'),
  FeatureFlag('New checkout flow'),
]);

If addFeatureFlags is called again, the new data will be merged with any existing feature flags with the newer variant values taking precedence.

If you are declaring many Feature Flags at the same time we recommend using addFeatureFlags as it is significantly more efficient than doing them one-at-a-time.

clearFeatureFlag

Remove a single feature flag or experiment.

await bugsnag.clearFeatureFlag('Special offer');

clearFeatureFlags

Remove all feature flags and experiments.

await button.clearFeatureFlags();