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:


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.

    new \Bugsnag\FeatureFlag('Checkout button color', 'Blue'),
    new \Bugsnag\FeatureFlag('Special offer', 'Free Coffee'),
    new \Bugsnag\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.


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:

$launchDarklyClient = // get LaunchDarkly client
$launchDarklyUser = // get LaunchDarkly user

// Boolean flag
$featureEnabled = $launchDarklyClient->variation('bool-flag-key', $launchDarklyUser, false);

if ($featureEnabled) {
} else {

// String flag
$stringFlag = $launchDarklyClient->variation('string-flag-key', $launchDarklyUser, null);

if ($stringFlag !== null) {
    $bugsnag->addFeatureFlag('string-flag-key', $stringFlag);
} else {

For more information, please see the LaunchDarkly PHP SDK documentation.


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

class BugsnagImpressionListener implements \SplitIO\Sdk\ImpressionListener
    private $bugsnag;

    public function __construct(\Bugsnag\Client $bugsnag)
        $this->bugsnag = $bugsnag;

    public function logImpression($impressionData)

$splitFactory = \SplitIO\Sdk::factory(
        /* ... */
        'impressionListener' => new BugsnagImpressionListener($bugsnag),

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