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 or in a callback on a BugsnagEvent:


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

[Bugsnag addFeatureFlagWithName:@"Checkout button color" variant:@"Blue"];
[Bugsnag addFeatureFlagWithName:@"New checkout flow"];
Bugsnag.addFeatureFlag(name: "Checkout button color", variant: "Blue")
Bugsnag.addFeatureFlag(name: "New checkout flow")


Declare multiple feature flags or experiments.

[Bugsnag addFeatureFlags:@[
    [BugsnagFeatureFlag flagWithName:@"Checkout button color" variant:@"Blue"],
    [BugsnagFeatureFlag flagWithName:@"Special offer" variant:@"Free Coffee"],
    [BugsnagFeatureFlag flagWithName:@"New checkout flow"]]];
    BugsnagFeatureFlag(name: "Checkout button color", variant: "Blue"),
    BugsnagFeatureFlag(name: "Special offer", variant: "Free Coffee"),
    BugsnagFeatureFlag(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 clearFeatureFlagWithName:@"Checkout button color"];
Bugsnag.clearFeatureFlag(name: "Checkout button color")


Remove all feature flags and experiments.

[Bugsnag clearFeatureFlags];

Feature and experiment management tools


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

LDClient *client = [LDClient get];

// Boolean flag
BOOL featureEnabled = [client boolVariationForKey:@"bool-flag-key" defaultValue:NO];
if (featureEnabled) {
    [Bugsnag addFeatureFlagWithName:@"bool-flag-key"];
} else {
    [Bugsnag clearFeatureFlagWithName:@"bool-flag-key"];

// String flag
NSString *stringFlag = [client stringVariationForKey:@"string-flag-key" defaultValue:nil];
if (stringFlag != nil) {
    [Bugsnag addFeatureFlagWithName:@"string-flag-key" variant:stringFlag];
} else {
    [Bugsnag clearFeatureFlagWithName:@"string-flag-key"];
let client = LDClient.get()

// Boolean flag
let featureEnabled = client.variation(forKey: "bool-flag-key", defaultValue: false)
if featureEnabled {
    Bugsnag.addFeatureFlag(name: "bool-flag-key")
} else {
    Bugsnag.clearFeatureFlag(name: "bool-flag-key")

// String flag
let stringFlag: String? = client.variation(forKey: "string-flag-key")
if let stringFlag = stringFlag {
    Bugsnag.addFeatureFlag(name: "string-flag-key", variant: stringFlag)
} else {
    Bugsnag.clearFeatureFlag(name: "string-flag-key")

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

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


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

SplitClientConfig *splitConfig = [[SplitClientConfig alloc] init];
splitConfig.impressionListener = ^(Impression *impression) {
    if (impression.feature) {
        [Bugsnag addFeatureFlagWithName:impression.feature
let splitConfig = SplitClientConfig()
splitConfig.impressionListener = {
    if let feature = $0.feature {
        Bugsnag.addFeatureFlag(name: feature, variant: $0.treatment)

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