Skip to content

Commit f3c7428

Browse files
committed
chore: add eval reason capability to ruby
1 parent 6ecf03e commit f3c7428

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

.github/workflows/test-harness.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ jobs:
1414
with:
1515
sdks-to-test: ruby
1616
sdk-github-sha: ${{github.event.pull_request.head.sha}}
17+
sdk-capabilities: '{ "Ruby": ["ClientCustomData", "V2Config", "VariableFeatureId", "AllVariables", "AllFeatures", "cloudEvalReason", "evalReason"]}'

lib/devcycle-ruby-server-sdk/api/client.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,16 +195,14 @@ def variable(user, key, default, opts = {})
195195
value = default
196196
type = determine_variable_type(default)
197197
defaulted = true
198-
eval = { reason: DevCycle::DEFAULT_REASONS::UNKNOWN, details: DevCycle::EVAL_REASON_DETAILS::UNKNOWN }
198+
eval = { reason: DevCycle::EVAL_REASONS::DEFAULT, details: DevCycle::DEFAULT_REASON_DETAILS::USER_NOT_TARGETED }
199199
if local_bucketing_initialized? && @local_bucketing.has_config
200200
type_code = variable_type_code_from_type(type)
201201
variable_pb = variable_for_user_pb(user, key, type_code)
202202
unless variable_pb.nil?
203203
value = get_variable_value(variable_pb)
204204
defaulted = false
205205
eval = get_eval_reason(variable_pb)
206-
else
207-
eval = { reason: DevCycle::DEFAULT_REASONS::USER_NOT_TARGETED, details: DevCycle::DEFAULT_REASONS::USER_NOT_TARGETED }
208206
end
209207
else
210208
@logger.warn("Local bucketing not initialized, returning default value for variable #{key}")
@@ -581,7 +579,7 @@ def get_variable_value(variable_pb)
581579

582580
def get_eval_reason(variable_pb)
583581
if variable_pb.eval.nil?
584-
{ reason: DevCycle::DEFAULT_REASONS::UNKNOWN, details: DevCycle::DEFAULT_REASONS::UNKNOWN }
582+
{ reason: DevCycle::DEFAULT_REASONS::USER_NOT_TARGETED, details: DevCycle::DEFAULT_REASON_DETAILS::USER_NOT_TARGETED }
585583
else
586584
puts ("variable_pb.eval bruh: #{variable_pb.eval}")
587585
{ reason: variable_pb.eval.reason, details: variable_pb.eval.details }

lib/devcycle-ruby-server-sdk/eval_reasons.rb

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,19 @@ module EVAL_REASON_DETAILS
5252
DEFAULT = 'Default'
5353
UNKNOWN = 'Unknown'
5454
end
55-
end
55+
56+
# Default reason details2
57+
module DEFAULT_REASON_DETAILS
58+
MISSING_CONFIG = 'Missing Config'
59+
MISSING_VARIABLE = 'Missing Variable'
60+
MISSING_FEATURE = 'Missing Feature'
61+
MISSING_VARIATION = 'Missing Variation'
62+
MISSING_VARIABLE_FOR_VARIATION = 'Missing Variable for Variation'
63+
USER_NOT_IN_ROLLOUT = 'User Not in Rollout'
64+
USER_NOT_TARGETED = 'User Not Targeted'
65+
INVALID_VARIABLE_TYPE = 'Invalid Variable Type'
66+
TYPE_MISMATCH = 'Variable Type Mismatch'
67+
UNKNOWN = 'Unknown'
68+
ERROR = 'Error'
69+
end
70+
end

0 commit comments

Comments
 (0)