bugsnag / bugsnag-ruby

BugSnag error monitoring & reporting software for rails, sinatra, rack and ruby
https://docs.bugsnag.com/platforms/ruby
MIT License
246 stars 174 forks source link

Add support for feature flags #758

Closed imjoehaines closed 1 year ago

imjoehaines commented 1 year ago

Goal

This PR adds support for feature flags to Bugsnag-ruby

The new APIs are available on both the Bugsnag module and invidiual events (via on_error callbacks):

add_feature_flag

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

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

add_feature_flags

Declare multiple feature flags or experiments.

Bugsnag.add_feature_flags(
  [
    Bugsnag::FeatureFlag.new('Checkout button color', 'Blue')
    Bugsnag::FeatureFlag.new('New checkout flow')
  ]
)

If add_feature_flags is called again, the new data will be merged with any existing feature flags with the newer variant values taking precedence.

clear_feature_flag

Remove a single feature flag or experiment.

Bugsnag.clear_feature_flag('Checkout button color')

clear_feature_flags

Remove all feature flags and experiments.

Bugsnag.clear_feature_flags