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.

This documentation is for version 7 of the Bugsnag JavaScript notifier. If you are using older versions, we recommend upgrading to the latest release using our Upgrade guide. Documentation for the previous release can be found on our legacy pages.

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:


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

Bugsnag.addFeatureFlag('Checkout button color', 'Blue')
Bugsnag.addFeatureFlag('New checkout flow')


Declare multiple feature flags or experiments.

  { name: 'Checkout button color', variant: 'Blue' },
  { name: 'Special offer', variant: 'Free Coffee' },
  { name: '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.


Remove a single feature flag or experiment.

Bugsnag.clearFeatureFlag('Checkout button color')


Remove all feature flags and experiments.


Feature and experiment management tools


To use Bugsnag with LaunchDarkly, you need to declare the flag to Bugsnag whenever you read it from LaunchDarkly. If using withLDConsumer or a LaunchDarkly hook, you should wrap the flag access so you can declare to Bugsnag.

For example, using the useFlags hook:

import { useFlags } from 'launchdarkly-react-client-sdk'

const App = () => {
  const flags = useFlags()

  const getBooleanFlag = (key) => {
    const booleanFlag = flags[key]

    if (booleanFlag) {
    } else {

    return booleanFlag

  const getStringFlag = (key) => {
    const stringFlag = flags[key]

    if (stringFlag !== null) {
      Bugsnag.addFeatureFlag(key, stringFlag)
    } else {

    return stringFlag

  return (
      <p>{getBooleanFlag('booleanFlagKey') ? 'On' : 'Off'}</p>



To use Bugsnag with Split, we recommend adding an impression listener to keep Bugsnag updated with the active experiments:

function bugsnagListener(impressionData) {

const sdkConfig = {
  /* ... */
  impressionListener: {
    logImpression: bugsnagListener

const App = () => (
  <SplitFactory config={sdkConfig}>
    <MyApp />

For more information, please see the Split React SDK documentation.