Skip to content

Commit ebe0e9f

Browse files
committed
chore: update bucketing lib and use correct eval reasons
1 parent f3c7428 commit ebe0e9f

File tree

5 files changed

+19
-10
lines changed

5 files changed

+19
-10
lines changed

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,16 +195,17 @@ def variable(user, key, default, opts = {})
195195
value = default
196196
type = determine_variable_type(default)
197197
defaulted = true
198-
eval = { reason: DevCycle::EVAL_REASONS::DEFAULT, details: DevCycle::DEFAULT_REASON_DETAILS::USER_NOT_TARGETED }
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)
202202
unless variable_pb.nil?
203203
value = get_variable_value(variable_pb)
204204
defaulted = false
205-
eval = get_eval_reason(variable_pb)
206205
end
206+
eval = get_eval_reason(variable_pb)
207207
else
208+
eval = { reason: DevCycle::DEFAULT_REASONS::DEFAULT, details: DevCycle::DEFAULT_REASON_DETAILS::MISSING_CONFIG }
208209
@logger.warn("Local bucketing not initialized, returning default value for variable #{key}")
209210
variable_event = Event.new({ type: DevCycle::EventTypes[:agg_variable_defaulted], target: key })
210211
bucketed_config = BucketedUserConfig.new({}, {}, {}, {}, {}, {}, [])
@@ -578,11 +579,14 @@ def get_variable_value(variable_pb)
578579
end
579580

580581
def get_eval_reason(variable_pb)
581-
if variable_pb.eval.nil?
582-
{ reason: DevCycle::DEFAULT_REASONS::USER_NOT_TARGETED, details: DevCycle::DEFAULT_REASON_DETAILS::USER_NOT_TARGETED }
582+
if variable_pb.nil?
583+
{ reason: DevCycle::DEFAULT_REASONS::DEFAULT, details: DevCycle::DEFAULT_REASON_DETAILS::USER_NOT_TARGETED}
583584
else
584-
puts ("variable_pb.eval bruh: #{variable_pb.eval}")
585-
{ reason: variable_pb.eval.reason, details: variable_pb.eval.details }
585+
if variable_pb.eval.nil?
586+
{ reason: DevCycle::DEFAULT_REASONS::USER_NOT_TARGETED, details: DevCycle::DEFAULT_REASON_DETAILS::USER_NOT_TARGETED }
587+
else
588+
{ reason: variable_pb.eval.reason, details: variable_pb.eval.details, target_id: variable_pb.eval.target_id }
589+
end
586590
end
587591
end
588592

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module DEFAULT_REASONS
1010
USER_NOT_TARGETED = 'USER_NOT_TARGETED'
1111
INVALID_VARIABLE_TYPE = 'INVALID_VARIABLE_TYPE'
1212
UNKNOWN = 'UNKNOWN'
13+
DEFAULT = 'DEFAULT'
1314
end
1415

1516
# Evaluation reasons for successful evaluations
@@ -53,7 +54,7 @@ module EVAL_REASON_DETAILS
5354
UNKNOWN = 'Unknown'
5455
end
5556

56-
# Default reason details2
57+
# Default reason details
5758
module DEFAULT_REASON_DETAILS
5859
MISSING_CONFIG = 'Missing Config'
5960
MISSING_VARIABLE = 'Missing Variable'
Binary file not shown.

lib/devcycle-ruby-server-sdk/localbucketing/update_wasm.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
BUCKETING_LIB_VERSION="1.40.0"
33
WAT_DOWNLOAD=0
44
rm bucketing-lib.release.wasm
5-
wget "https://unpkg.com/@devcycle/bucketing-assembly-script@$BUCKETING_LIB_VERSION/build/bucketing-lib.release.wasm"
5+
wget "https://unpkg.com/@devcycle/bucketing-assembly-script@$BUCKETING_LIB_VERSION/build/bucketing-lib.release.wasm"

lib/devcycle-ruby-server-sdk/models/feature.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Feature
3434
attr_accessor :variationName
3535

3636
# Evaluation reasoning
37-
attr_accessor :eval
37+
attr_accessor :eval_reason
3838

3939
class EnumAttributeValidator
4040
attr_reader :datatype
@@ -67,7 +67,7 @@ def self.attribute_map
6767
:'_variation' => :'_variation',
6868
:'variationKey' => :'variationKey',
6969
:'variationName' => :'variationName',
70-
:'eval' => :'eval'
70+
:'eval_reason' => :'evalReason'
7171
}
7272
end
7373

@@ -133,6 +133,10 @@ def initialize(attributes = {})
133133
if attributes.key?(:'variationName')
134134
self.variationName = attributes[:'variationName']
135135
end
136+
137+
if attributes.key?(:'eval_reason')
138+
self.eval_reason = attributes[:'eval_reason']
139+
end
136140
end
137141

138142
# Show invalid properties with the reasons. Usually used together with valid?

0 commit comments

Comments
 (0)