File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -305,6 +305,26 @@ EvaluationDetail<T> ClientImpl::VariationInternal(FlagKey const& key,
305305 auto const & flag = *(desc->item );
306306 auto const & detail = flag.Detail ();
307307
308+ // The Prerequisites vector represents the evaluated prerequisites of
309+ // this flag. We need to generate events for both this flag and its
310+ // prerequisites (recursively), which is necessary to ensure LaunchDarkly
311+ // analytics functions properly.
312+ //
313+ // We're using JsonVariation because the type of the
314+ // prerequisite is both unknown and irrelevant to emitting the events.
315+ //
316+ // We're passing Value::Null() to match a server-side SDK's behavior when
317+ // evaluating prerequisites.
318+ //
319+ // NOTE: if "hooks" functionality is implemented into this SDK, take care
320+ // that evaluating prerequisites does not trigger hooks. This may require
321+ // refactoring the code below to not use JsonVariation.
322+ if (auto const prereqs = flag.Prerequisites ()) {
323+ for (auto const & prereq : *prereqs) {
324+ JsonVariation (prereq, Value::Null ());
325+ }
326+ }
327+
308328 if (check_type && default_value.Type () != Value::Type::kNull &&
309329 detail.Value ().Type () != default_value.Type ()) {
310330 auto error_reason =
You can’t perform that action at this time.
0 commit comments