Skip to content

Commit 85c7215

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

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ 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::DEFAULT_REASONS::USER_NOT_TARGETED, 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)
@@ -204,7 +204,7 @@ def variable(user, key, default, opts = {})
204204
defaulted = false
205205
eval = get_eval_reason(variable_pb)
206206
else
207-
eval = { reason: DevCycle::DEFAULT_REASONS::USER_NOT_TARGETED, details: DevCycle::DEFAULT_REASONS::USER_NOT_TARGETED }
207+
eval = { reason: DevCycle::DEFAULT_REASONS::USER_NOT_TARGETED, details: DevCycle::DEFAULT_REASON_DETAILS::USER_NOT_TARGETED }
208208
end
209209
else
210210
@logger.warn("Local bucketing not initialized, returning default value for variable #{key}")
@@ -581,7 +581,7 @@ def get_variable_value(variable_pb)
581581

582582
def get_eval_reason(variable_pb)
583583
if variable_pb.eval.nil?
584-
{ reason: DevCycle::DEFAULT_REASONS::UNKNOWN, details: DevCycle::DEFAULT_REASONS::UNKNOWN }
584+
{ reason: DevCycle::DEFAULT_REASONS::USER_NOT_TARGETED, details: DevCycle::DEFAULT_REASON_DETAILS::USER_NOT_TARGETED }
585585
else
586586
puts ("variable_pb.eval bruh: #{variable_pb.eval}")
587587
{ 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)