Method: LaunchDarkly::LDClient#variation_detail

Defined in:
lib/ldclient-rb/ldclient.rb

#variation_detail(key, context, default) ⇒ EvaluationDetail

Determines the variation of a feature flag for a context, like #variation, but also provides additional information about how this value was calculated.

The return value of ‘variation_detail` is an EvaluationDetail object, which has three properties: the result value, the positional index of this value in the flag’s list of variations, and an object describing the main reason why this value was selected. See EvaluationDetail for more on these properties.

Calling ‘variation_detail` instead of `variation` also causes the “reason” data to be included in analytics events, if you are capturing detailed event data for this flag.

For more information, see the reference guide on [Evaluation reasons](docs.launchdarkly.com/sdk/concepts/evaluation-reasons).

Parameters:

  • key (String)

    the unique feature key for the feature flag, as shown on the LaunchDarkly dashboard

  • context (Hash, LDContext)

    a hash or object describing the context requesting the flag,

  • default

    the default value of the flag; this is used if there is an error condition making it impossible to find or evaluate the flag

Returns:



337
338
339
340
341
342
343
344
345
# File 'lib/ldclient-rb/ldclient.rb', line 337

def variation_detail(key, context, default)
  context = Impl::Context::make_context(context)
  result = evaluate_with_hooks(key, context, default, :variation_detail) do
    detail, _, _ = evaluate_internal(key, context, default, true)
    LaunchDarkly::Impl::EvaluationWithHookResult.new(detail)
  end

  result.evaluation_detail
end