Skip to content

Executing arbitrary logic when a feature flag status gets retrieved from storage #686

@nicolasiensen

Description

@nicolasiensen

I checked Bugsnag's new feature, where we can now include the enabled feature flags to be part of the error reports.

They updated their Ruby SDK to allow developers to include feature flags as part of the error reports like so:

Bugsnag.add_feature_flag('New checkout flow')

On my team, we disabled Flipper's preload due to performance implications, so we would like to call Bugsnag.add_feature_flag every time we interact with Flipper to retrieve the status of a particular feature flag. Can I do that already?

One way to achieve this would be to make the Feature class observable and register observers in the library like the example below:

class FeatureCheckObserverForBugsnag < Flipper::FeatureCheckObserver
  def call(feature, enabled)
    if enabled
      Bugsnag.add_feature_flag(feature.name)
    else
      Bugsnag.clear_feature_flag(feature.name)
    end
  end
end

Flipper.add_feature_check_observer(FeatureCheckObserverForBugsnag.new)

# Flipper will now include the new observer on every new instance of Feature that it instantiates

Let me know if there is already an approach to get the outcome I'm looking for and if you have any comments about my proposal. I will happily implement it if you think it is worth it.

Cheers!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions