devcycle-ruby-server-sdk 3.6.2 → 3.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 914b4bf9e916b2796dcd6ce88be3ecf784b074fd30784bf8f28e2156b0bd8c66
4
- data.tar.gz: dc4a335584b6618b4664203460530bc4421232dfdcc6362399694d7278f34bee
3
+ metadata.gz: c3acf8324fc7606185240c3ea421048f87c8618a3944951ed71ed729ed4cde7a
4
+ data.tar.gz: 763e2632030ffbc90bd365614f158bc960c767e15bcf0d88afd2a2407ff56f24
5
5
  SHA512:
6
- metadata.gz: 6ca7f4b518dfa6bbd6ffa817263df4f625e7583a2ea61ad6b6ead5cd10ce12f2f586e205e457c39dc9d86831aadfd8e1ce7f1346c02362b1427bce7768a9fac0
7
- data.tar.gz: 2d35f58deaa7a1309d8cb1aa6c5e7002e96e957f920d64d49d14a11e03a108051c679fc521acb451c1cd90a5dc32e9caa1754c92f308efecf592cd87da8cb78b
6
+ metadata.gz: 7830aef854188cded6ed20a3667d4fe6dbf2bcd4482e605b823c95023b7d9fb3f30a52d01543346adae4ed260290f25b71cd516a3172679e4209d54d342eac6b
7
+ data.tar.gz: be2f2cb6349a64b95216dd3868642284d917ea4c8db7d2991f550f9beb9e0ddb3f8dae91dc6aa5c817fbf0f2b5f562da1f95fcccee0bddceea67323b96ec783c
@@ -195,6 +195,7 @@ module DevCycle
195
195
  value = default
196
196
  type = determine_variable_type(default)
197
197
  defaulted = true
198
+ eval = { reason: DevCycle::EVAL_REASONS::DEFAULT, details: DevCycle::DEFAULT_REASON_DETAILS::USER_NOT_TARGETED }
198
199
  if local_bucketing_initialized? && @local_bucketing.has_config
199
200
  type_code = variable_type_code_from_type(type)
200
201
  variable_pb = variable_for_user_pb(user, key, type_code)
@@ -202,9 +203,11 @@ module DevCycle
202
203
  value = get_variable_value(variable_pb)
203
204
  defaulted = false
204
205
  end
206
+ eval = get_eval_reason(variable_pb)
205
207
  else
208
+ eval = { reason: DevCycle::EVAL_REASONS::DEFAULT, details: DevCycle::DEFAULT_REASON_DETAILS::MISSING_CONFIG }
206
209
  @logger.warn("Local bucketing not initialized, returning default value for variable #{key}")
207
- variable_event = Event.new({ type: DevCycle::EventTypes[:agg_variable_defaulted], target: key })
210
+ variable_event = Event.new({ type: DevCycle::EventTypes[:agg_variable_defaulted], target: key, metaData: { evalReason: DevCycle::EVAL_REASONS::DEFAULT }})
208
211
  bucketed_config = BucketedUserConfig.new({}, {}, {}, {}, {}, {}, [])
209
212
  @event_queue.queue_aggregate_event(variable_event, bucketed_config)
210
213
  end
@@ -214,7 +217,8 @@ module DevCycle
214
217
  value: value,
215
218
  type: type,
216
219
  defaultValue: default,
217
- isDefaulted: defaulted
220
+ isDefaulted: defaulted,
221
+ eval: eval
218
222
  })
219
223
  end
220
224
 
@@ -574,6 +578,18 @@ module DevCycle
574
578
  end
575
579
  end
576
580
 
581
+ def get_eval_reason(variable_pb)
582
+ if variable_pb.nil?
583
+ { reason: DevCycle::EVAL_REASONS::DEFAULT, details: DevCycle::DEFAULT_REASON_DETAILS::USER_NOT_TARGETED}
584
+ else
585
+ if variable_pb.eval.nil?
586
+ { reason: DevCycle::EVAL_REASONS::DEFAULT, 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
590
+ end
591
+ end
592
+
577
593
  # Adds an eval hook to the client
578
594
  # @param [EvalHook] eval_hook The eval hook to add
579
595
  # @return [void]
@@ -0,0 +1,13 @@
1
+ module DevCycle
2
+ # Evaluation reasons for successful evaluations
3
+ module EVAL_REASONS
4
+ DEFAULT = 'DEFAULT'
5
+ ERROR = 'ERROR'
6
+ end
7
+
8
+ # Default reason details
9
+ module DEFAULT_REASON_DETAILS
10
+ MISSING_CONFIG = 'Missing Config'
11
+ USER_NOT_TARGETED = 'User Not Targeted'
12
+ end
13
+ end
@@ -66,4 +66,12 @@ message SDKVariable_PB {
66
66
  double doubleValue = 5;
67
67
  string stringValue = 6;
68
68
  NullableString evalReason = 7;
69
+ NullableString _feature = 8;
70
+ EvalReason_PB eval = 9;
69
71
  }
72
+
73
+ message EvalReason_PB {
74
+ string reason = 1;
75
+ string details = 2;
76
+ string target_id = 3;
77
+ }
@@ -1,69 +1,34 @@
1
+ # frozen_string_literal: true
1
2
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
3
  # source: variableForUserParams.proto
3
4
 
4
5
  require 'google/protobuf'
5
6
 
6
- Google::Protobuf::DescriptorPool.generated_pool.build do
7
- add_file("variableForUserParams.proto", :syntax => :proto3) do
8
- add_message "proto.NullableString" do
9
- optional :value, :string, 1
10
- optional :isNull, :bool, 2
11
- end
12
- add_message "proto.NullableDouble" do
13
- optional :value, :double, 1
14
- optional :isNull, :bool, 2
15
- end
16
- add_message "proto.CustomDataValue" do
17
- optional :type, :enum, 1, "proto.CustomDataType"
18
- optional :boolValue, :bool, 2
19
- optional :doubleValue, :double, 3
20
- optional :stringValue, :string, 4
21
- end
22
- add_message "proto.NullableCustomData" do
23
- map :value, :string, :message, 1, "proto.CustomDataValue"
24
- optional :isNull, :bool, 2
25
- end
26
- add_message "proto.VariableForUserParams_PB" do
27
- optional :sdkKey, :string, 1
28
- optional :variableKey, :string, 2
29
- optional :variableType, :enum, 3, "proto.VariableType_PB"
30
- optional :user, :message, 4, "proto.DVCUser_PB"
31
- optional :shouldTrackEvent, :bool, 5
32
- end
33
- add_message "proto.DVCUser_PB" do
34
- optional :user_id, :string, 1
35
- optional :email, :message, 2, "proto.NullableString"
36
- optional :name, :message, 3, "proto.NullableString"
37
- optional :language, :message, 4, "proto.NullableString"
38
- optional :country, :message, 5, "proto.NullableString"
39
- optional :appBuild, :message, 6, "proto.NullableDouble"
40
- optional :appVersion, :message, 7, "proto.NullableString"
41
- optional :deviceModel, :message, 8, "proto.NullableString"
42
- optional :customData, :message, 9, "proto.NullableCustomData"
43
- optional :privateCustomData, :message, 10, "proto.NullableCustomData"
44
- end
45
- add_message "proto.SDKVariable_PB" do
46
- optional :_id, :string, 1
47
- optional :type, :enum, 2, "proto.VariableType_PB"
48
- optional :key, :string, 3
49
- optional :boolValue, :bool, 4
50
- optional :doubleValue, :double, 5
51
- optional :stringValue, :string, 6
52
- optional :evalReason, :message, 7, "proto.NullableString"
53
- end
54
- add_enum "proto.VariableType_PB" do
55
- value :Boolean, 0
56
- value :Number, 1
57
- value :String, 2
58
- value :JSON, 3
59
- end
60
- add_enum "proto.CustomDataType" do
61
- value :Bool, 0
62
- value :Num, 1
63
- value :Str, 2
64
- value :Null, 3
7
+
8
+ descriptor_data = "\n\x1bvariableForUserParams.proto\x12\x05proto\"/\n\x0eNullableString\x12\r\n\x05value\x18\x01 \x01(\t\x12\x0e\n\x06isNull\x18\x02 \x01(\x08\"/\n\x0eNullableDouble\x12\r\n\x05value\x18\x01 \x01(\x01\x12\x0e\n\x06isNull\x18\x02 \x01(\x08\"s\n\x0f\x43ustomDataValue\x12#\n\x04type\x18\x01 \x01(\x0e\x32\x15.proto.CustomDataType\x12\x11\n\tboolValue\x18\x02 \x01(\x08\x12\x13\n\x0b\x64oubleValue\x18\x03 \x01(\x01\x12\x13\n\x0bstringValue\x18\x04 \x01(\t\"\x9f\x01\n\x12NullableCustomData\x12\x33\n\x05value\x18\x01 \x03(\x0b\x32$.proto.NullableCustomData.ValueEntry\x12\x0e\n\x06isNull\x18\x02 \x01(\x08\x1a\x44\n\nValueEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12%\n\x05value\x18\x02 \x01(\x0b\x32\x16.proto.CustomDataValue:\x02\x38\x01\"\xa8\x01\n\x18VariableForUserParams_PB\x12\x0e\n\x06sdkKey\x18\x01 \x01(\t\x12\x13\n\x0bvariableKey\x18\x02 \x01(\t\x12,\n\x0cvariableType\x18\x03 \x01(\x0e\x32\x16.proto.VariableType_PB\x12\x1f\n\x04user\x18\x04 \x01(\x0b\x32\x11.proto.DVCUser_PB\x12\x18\n\x10shouldTrackEvent\x18\x05 \x01(\x08\"\x9e\x03\n\nDVCUser_PB\x12\x0f\n\x07user_id\x18\x01 \x01(\t\x12$\n\x05\x65mail\x18\x02 \x01(\x0b\x32\x15.proto.NullableString\x12#\n\x04name\x18\x03 \x01(\x0b\x32\x15.proto.NullableString\x12\'\n\x08language\x18\x04 \x01(\x0b\x32\x15.proto.NullableString\x12&\n\x07\x63ountry\x18\x05 \x01(\x0b\x32\x15.proto.NullableString\x12\'\n\x08\x61ppBuild\x18\x06 \x01(\x0b\x32\x15.proto.NullableDouble\x12)\n\nappVersion\x18\x07 \x01(\x0b\x32\x15.proto.NullableString\x12*\n\x0b\x64\x65viceModel\x18\x08 \x01(\x0b\x32\x15.proto.NullableString\x12-\n\ncustomData\x18\t \x01(\x0b\x32\x19.proto.NullableCustomData\x12\x34\n\x11privateCustomData\x18\n \x01(\x0b\x32\x19.proto.NullableCustomData\"\x85\x02\n\x0eSDKVariable_PB\x12\x0b\n\x03_id\x18\x01 \x01(\t\x12$\n\x04type\x18\x02 \x01(\x0e\x32\x16.proto.VariableType_PB\x12\x0b\n\x03key\x18\x03 \x01(\t\x12\x11\n\tboolValue\x18\x04 \x01(\x08\x12\x13\n\x0b\x64oubleValue\x18\x05 \x01(\x01\x12\x13\n\x0bstringValue\x18\x06 \x01(\t\x12)\n\nevalReason\x18\x07 \x01(\x0b\x32\x15.proto.NullableString\x12\'\n\x08_feature\x18\x08 \x01(\x0b\x32\x15.proto.NullableString\x12\"\n\x04\x65val\x18\t \x01(\x0b\x32\x14.proto.EvalReason_PB\"C\n\rEvalReason_PB\x12\x0e\n\x06reason\x18\x01 \x01(\t\x12\x0f\n\x07\x64\x65tails\x18\x02 \x01(\t\x12\x11\n\ttarget_id\x18\x03 \x01(\t*@\n\x0fVariableType_PB\x12\x0b\n\x07\x42oolean\x10\x00\x12\n\n\x06Number\x10\x01\x12\n\n\x06String\x10\x02\x12\x08\n\x04JSON\x10\x03*6\n\x0e\x43ustomDataType\x12\x08\n\x04\x42ool\x10\x00\x12\x07\n\x03Num\x10\x01\x12\x07\n\x03Str\x10\x02\x12\x08\n\x04Null\x10\x03\x62\x06proto3"
9
+
10
+ pool = Google::Protobuf::DescriptorPool.generated_pool
11
+
12
+ begin
13
+ pool.add_serialized_file(descriptor_data)
14
+ rescue TypeError => e
15
+ # Compatibility code: will be removed in the next major version.
16
+ require 'google/protobuf/descriptor_pb'
17
+ parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data)
18
+ parsed.clear_dependency
19
+ serialized = parsed.class.encode(parsed)
20
+ file = pool.add_serialized_file(serialized)
21
+ warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}"
22
+ imports = [
23
+ ]
24
+ imports.each do |type_name, expected_filename|
25
+ import_file = pool.lookup(type_name).file_descriptor
26
+ if import_file.name != expected_filename
27
+ warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}"
65
28
  end
66
29
  end
30
+ warn "Each proto file must use a consistent fully-qualified name."
31
+ warn "This will become an error in the next major version."
67
32
  end
68
33
 
69
34
  module Proto
@@ -74,6 +39,7 @@ module Proto
74
39
  VariableForUserParams_PB = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("proto.VariableForUserParams_PB").msgclass
75
40
  DVCUser_PB = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("proto.DVCUser_PB").msgclass
76
41
  SDKVariable_PB = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("proto.SDKVariable_PB").msgclass
42
+ EvalReason_PB = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("proto.EvalReason_PB").msgclass
77
43
  VariableType_PB = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("proto.VariableType_PB").enummodule
78
44
  CustomDataType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("proto.CustomDataType").enummodule
79
45
  end
@@ -1,5 +1,5 @@
1
1
  #!/bin/bash
2
- BUCKETING_LIB_VERSION="1.35.1"
2
+ BUCKETING_LIB_VERSION="1.41.0"
3
3
  WAT_DOWNLOAD=0
4
4
  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"
@@ -29,6 +29,9 @@ module DevCycle
29
29
 
30
30
  attr_accessor :defaultValue
31
31
 
32
+ # Variable evaluation details
33
+ attr_accessor :eval
34
+
32
35
  class EnumAttributeValidator
33
36
  attr_reader :datatype
34
37
  attr_reader :allowable_values
@@ -58,7 +61,8 @@ module DevCycle
58
61
  :'type' => :'type',
59
62
  :'value' => :'value',
60
63
  :'defaultValue' => :'defaultValue',
61
- :'isDefaulted' => :'isDefaulted'
64
+ :'isDefaulted' => :'isDefaulted',
65
+ :'eval' => :'eval'
62
66
  }
63
67
  end
64
68
 
@@ -120,6 +124,10 @@ module DevCycle
120
124
  if attributes.key?(:'defaultValue')
121
125
  self.defaultValue = attributes[:'defaultValue']
122
126
  end
127
+
128
+ if attributes.key?(:'eval')
129
+ self.eval = attributes[:'eval']
130
+ end
123
131
  end
124
132
 
125
133
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -1,3 +1,3 @@
1
1
  module DevCycle
2
- VERSION = '3.6.2'
2
+ VERSION = '3.7.0'
3
3
  end
@@ -29,6 +29,7 @@ require 'devcycle-ruby-server-sdk/models/variable'
29
29
  require 'devcycle-ruby-server-sdk/eval_hooks_runner'
30
30
  require 'devcycle-ruby-server-sdk/models/eval_hook'
31
31
  require 'devcycle-ruby-server-sdk/models/eval_hook_context'
32
+ require 'devcycle-ruby-server-sdk/eval_reasons'
32
33
 
33
34
  # APIs
34
35
  require 'devcycle-ruby-server-sdk/api/client'
@@ -21,16 +21,18 @@ describe 'DevCycle::Client' do
21
21
  sdk_key = ENV["DEVCYCLE_SERVER_SDK_KEY"]
22
22
  if sdk_key.nil?
23
23
  puts("SDK KEY NOT SET - SKIPPING INIT")
24
- return
24
+ @skip_tests = true
25
+ else
26
+ # run before each test
27
+ options = DevCycle::Options.new(enable_cloud_bucketing: true)
28
+ @api_instance = DevCycle::Client.new(sdk_key, options)
29
+
30
+ @user = DevCycle::User.new({
31
+ user_id: 'test-user',
32
+ appVersion: '1.2.3'
33
+ })
34
+ @skip_tests = false
25
35
  end
26
- # run before each test
27
- options = DevCycle::Options.new(enable_cloud_bucketing: true)
28
- @api_instance = DevCycle::Client.new(sdk_key, options)
29
-
30
- @user = DevCycle::User.new({
31
- user_id: 'test-user',
32
- appVersion: '1.2.3'
33
- })
34
36
  end
35
37
 
36
38
  after do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devcycle-ruby-server-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.2
4
+ version: 3.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - DevCycleHQ
@@ -166,6 +166,7 @@ files:
166
166
  - lib/devcycle-ruby-server-sdk/api_error.rb
167
167
  - lib/devcycle-ruby-server-sdk/configuration.rb
168
168
  - lib/devcycle-ruby-server-sdk/eval_hooks_runner.rb
169
+ - lib/devcycle-ruby-server-sdk/eval_reasons.rb
169
170
  - lib/devcycle-ruby-server-sdk/localbucketing/bucketed_user_config.rb
170
171
  - lib/devcycle-ruby-server-sdk/localbucketing/bucketing-lib.release.wasm
171
172
  - lib/devcycle-ruby-server-sdk/localbucketing/config_manager.rb