Skip to content

Commit

Permalink
Merge pull request #107 from launchdarkly/eb/ch32577/prereq-event-user
Browse files Browse the repository at this point in the history
include user in prereq flag events
  • Loading branch information
eli-darkly authored Mar 1, 2019
2 parents e8860ba + 2800db8 commit 0d0086b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion lib/ldclient-rb/evaluation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ def check_prerequisites(flag, user, store, events, logger)
event = {
kind: "feature",
key: prereq_key,
user: user,
variation: prereq_res.variation_index,
value: prereq_res.value,
version: prereq_flag[:version],
Expand All @@ -272,7 +273,7 @@ def check_prerequisites(flag, user, store, events, logger)
}
events.push(event)
rescue => exn
Util.log_exception(logger, "Error evaluating prerequisite flag \"#{prereq_key}\" for flag \"{flag[:key]}\"", exn)
Util.log_exception(logger, "Error evaluating prerequisite flag \"#{prereq_key}\" for flag \"#{flag[:key]}\"", exn)
prereq_ok = false
end
end
Expand Down
8 changes: 4 additions & 4 deletions spec/evaluation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def boolean_flag_with_clauses(clauses)
detail = LaunchDarkly::EvaluationDetail.new('b', 1,
{ kind: 'PREREQUISITE_FAILED', prerequisiteKey: 'feature1' })
events_should_be = [{
kind: 'feature', key: 'feature1', variation: nil, value: nil, version: 2, prereqOf: 'feature0',
kind: 'feature', key: 'feature1', user: user, variation: nil, value: nil, version: 2, prereqOf: 'feature0',
trackEvents: nil, debugEventsUntilDate: nil
}]
result = evaluate(flag, user, features, logger)
Expand Down Expand Up @@ -159,7 +159,7 @@ def boolean_flag_with_clauses(clauses)
detail = LaunchDarkly::EvaluationDetail.new('b', 1,
{ kind: 'PREREQUISITE_FAILED', prerequisiteKey: 'feature1' })
events_should_be = [{
kind: 'feature', key: 'feature1', variation: 1, value: 'e', version: 2, prereqOf: 'feature0',
kind: 'feature', key: 'feature1', user: user, variation: 1, value: 'e', version: 2, prereqOf: 'feature0',
trackEvents: nil, debugEventsUntilDate: nil
}]
result = evaluate(flag, user, features, logger)
Expand Down Expand Up @@ -189,7 +189,7 @@ def boolean_flag_with_clauses(clauses)
detail = LaunchDarkly::EvaluationDetail.new('b', 1,
{ kind: 'PREREQUISITE_FAILED', prerequisiteKey: 'feature1' })
events_should_be = [{
kind: 'feature', key: 'feature1', variation: 0, value: 'd', version: 2, prereqOf: 'feature0',
kind: 'feature', key: 'feature1', user: user, variation: 0, value: 'd', version: 2, prereqOf: 'feature0',
trackEvents: nil, debugEventsUntilDate: nil
}]
result = evaluate(flag, user, features, logger)
Expand Down Expand Up @@ -218,7 +218,7 @@ def boolean_flag_with_clauses(clauses)
user = { key: 'x' }
detail = LaunchDarkly::EvaluationDetail.new('a', 0, { kind: 'FALLTHROUGH' })
events_should_be = [{
kind: 'feature', key: 'feature1', variation: 1, value: 'e', version: 2, prereqOf: 'feature0',
kind: 'feature', key: 'feature1', user: user, variation: 1, value: 'e', version: 2, prereqOf: 'feature0',
trackEvents: nil, debugEventsUntilDate: nil
}]
result = evaluate(flag, user, features, logger)
Expand Down

0 comments on commit 0d0086b

Please sign in to comment.