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.

In Node.js apps, you will usually want feature flag data to be specific to the request being served, not globally, so that it doesn’t affect requests from other users, who may have different treatments. It should therefore be added to the request-scoped BugSnag client, req.bugsnag, that is added to the request context by BugSnag middleware.

You can either declare the usage using the following methods on the BugSnag client or in a callback on an Event object:


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')

Or for Node.js:

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

Where req is the request context.


Declare multiple feature flags or experiments.

  { name: 'Checkout button color', variant: 'Blue' },
  { name: 'Special offer', variant: 'Free Coffee' },
  { name: 'New checkout flow' },

Or for Node.js:

  { name: 'Checkout button color', variant: 'Blue' },
  { name: 'Special offer', variant: 'Free Coffee' },
  { name: 'New checkout flow' },

Where req is the request context.

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')

Or for Node.js:

req.bugsnag.clearFeatureFlag('Checkout button color')

Where req is the request context.


Remove all feature flags and experiments.


Or for Node.js:


Where req is the request context.

Feature and experiment management tools


To use BugSnag with LaunchDarkly, you need to declare the flag to BugSnag whenever you read it from LaunchDarkly:

const launchDarklyClient = // get LaunchDarkly client

// Boolean flag
const featureEnabled = launchDarklyClient.variation('bool-flag-key', false)

if (featureEnabled) {
} else {

// String flag
const stringFlag = launchDarklyClient.variation('string-flag-key', null)
if (stringFlag !== null) {
  Bugsnag.addFeatureFlag('string-flag-key', stringFlag)
} else {

If your app reacts dynamically to flag changes using LaunchDarkly’s “on change” functionality, you should ensure that you keep BugSnag up-to-date with those changes too.

For more information, please see the LaunchDarkly client-side JavaScript SDK documentation.



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

function bugsnagListener(impressionData) {

const factory = splitio.SplitFactory({ 
  /* ... */
  impressionListener: {
    logImpression: bugsnagListener

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


To use BugSnag with Split, feature flags should be added to the request-scoped BugSnag client:

const factory = SplitFactory(/* ... */)
const client = factory.client()

app.get('/purchase/:productId', function (req, res, next) {
  const treatment = client.getTreatment('key', 'SPLIT_NAME')

  req.bugsnag.addFeatureFlag('SPLIT_NAME', treatment)

  // ...

For more information, please see the Split Node.js SDK documentation.