statsig 1.23.0 → 1.24.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 89aaef291fd8cbd82af8bcf380894ea554588988b2de66507482420b475c8367
4
- data.tar.gz: 3f535a1ce2a9af6e811c77df334b3b58a3c2503857f74bbf5b280764cfb041f1
3
+ metadata.gz: d0f95c8f4ce514c74570b095d81959705153201640821ba25179d24cd34ed4ec
4
+ data.tar.gz: c162910dc417b4f7311d91665d7240956a2eb1b58040050503bb8bb22b19cf12
5
5
  SHA512:
6
- metadata.gz: 16074e02fd22c2d0bc64e8adbd4b2551d46509e60f161b9ff5009ea28e13a995f13e0abd89c48c1c737d80dad1a869b8f15de8ac2b896a47ad6da54cdadbdd70
7
- data.tar.gz: ac6e8241c8132844a0ee5e8858578ab3475cb227e48847fb840d4ef15219828f58c38f24d2c2e5e2bfe26714bda07f8c1068f9a15af675d4320e4a90c6c2a7c6
6
+ metadata.gz: b1e085f8fbdcfb6020060f331b53767a68bda85f24669b6f710701ca0e9562ff4ca2fa873cce2a0917f48e64767f87c1489e1c792b695933c31a7ed8b71efd17
7
+ data.tar.gz: 9cf5e1ead6e76546d24d6042b2fe5f7dcbc5d1f9eae5423b4c7bca839174c1c8992d4c04ce61e21b53162872c99a619f86ea2b8c01f3d8485d9a35b67bcdf2e9
data/lib/config_result.rb CHANGED
@@ -11,6 +11,8 @@ module Statsig
11
11
  attr_accessor :explicit_parameters
12
12
  attr_accessor :is_experiment_group
13
13
  attr_accessor :evaluation_details
14
+ attr_accessor :group_name
15
+ attr_accessor :id_type
14
16
 
15
17
  def initialize(
16
18
  name,
@@ -21,7 +23,9 @@ module Statsig
21
23
  config_delegate = '',
22
24
  explicit_parameters = [],
23
25
  is_experiment_group: false,
24
- evaluation_details: nil)
26
+ evaluation_details: nil,
27
+ group_name: nil,
28
+ id_type: '')
25
29
  @name = name
26
30
  @gate_value = gate_value
27
31
  @json_value = json_value
@@ -32,6 +36,8 @@ module Statsig
32
36
  @explicit_parameters = explicit_parameters
33
37
  @is_experiment_group = is_experiment_group
34
38
  @evaluation_details = evaluation_details
39
+ @group_name = group_name
40
+ @id_type = id_type
35
41
  end
36
42
  end
37
43
  end
@@ -20,11 +20,19 @@ class DynamicConfig
20
20
  sig { returns(String) }
21
21
  attr_accessor :rule_id
22
22
 
23
- sig { params(name: String, value: T::Hash[String, T.untyped], rule_id: String).void }
24
- def initialize(name, value = {}, rule_id = '')
23
+ sig { returns(T.nilable(String)) }
24
+ attr_accessor :group_name
25
+
26
+ sig { returns(String) }
27
+ attr_accessor :id_type
28
+
29
+ sig { params(name: String, value: T::Hash[String, T.untyped], rule_id: String, group_name: T.nilable(String), id_type: String).void }
30
+ def initialize(name, value = {}, rule_id = '', group_name = nil, id_type = '')
25
31
  @name = name
26
32
  @value = value
27
33
  @rule_id = rule_id
34
+ @group_name = group_name
35
+ @id_type = id_type
28
36
  end
29
37
 
30
38
  sig { params(index: String, default_value: T.untyped).returns(T.untyped) }
data/lib/evaluator.rb CHANGED
@@ -53,14 +53,20 @@ module Statsig
53
53
  end
54
54
 
55
55
  def get_config(user, config_name)
56
- if @config_overrides.has_key?(config_name)
56
+ if @config_overrides.key?(config_name)
57
+ id_type = @spec_store.has_config?(config_name) ? @spec_store.get_config(config_name)['idType'] : ''
57
58
  return Statsig::ConfigResult.new(
58
59
  config_name,
59
60
  false,
60
61
  @config_overrides[config_name],
61
62
  'override',
62
63
  [],
63
- evaluation_details: EvaluationDetails.local_override(@spec_store.last_config_sync_time, @spec_store.initial_config_sync_time))
64
+ evaluation_details: EvaluationDetails.local_override(
65
+ @spec_store.last_config_sync_time,
66
+ @spec_store.initial_config_sync_time
67
+ ),
68
+ id_type: id_type
69
+ )
64
70
  end
65
71
 
66
72
  if @spec_store.init_reason == EvaluationReason::UNINITIALIZED
@@ -68,7 +74,13 @@ module Statsig
68
74
  end
69
75
 
70
76
  unless @spec_store.has_config?(config_name)
71
- return Statsig::ConfigResult.new(config_name, evaluation_details: EvaluationDetails.unrecognized(@spec_store.last_config_sync_time, @spec_store.initial_config_sync_time))
77
+ return Statsig::ConfigResult.new(
78
+ config_name,
79
+ evaluation_details: EvaluationDetails.unrecognized(
80
+ @spec_store.last_config_sync_time,
81
+ @spec_store.initial_config_sync_time
82
+ )
83
+ )
72
84
  end
73
85
 
74
86
  eval_spec(user, @spec_store.get_config(config_name))
@@ -159,8 +171,14 @@ module Statsig
159
171
  pass ? result.json_value : config['defaultValue'],
160
172
  result.rule_id,
161
173
  exposures,
162
- evaluation_details: EvaluationDetails.new(@spec_store.last_config_sync_time, @spec_store.initial_config_sync_time, @spec_store.init_reason),
174
+ evaluation_details: EvaluationDetails.new(
175
+ @spec_store.last_config_sync_time,
176
+ @spec_store.initial_config_sync_time,
177
+ @spec_store.init_reason
178
+ ),
163
179
  is_experiment_group: result.is_experiment_group,
180
+ group_name: result.group_name,
181
+ id_type: config['idType']
164
182
  )
165
183
  end
166
184
 
@@ -176,7 +194,14 @@ module Statsig
176
194
  config['defaultValue'],
177
195
  default_rule_id,
178
196
  exposures,
179
- evaluation_details: EvaluationDetails.new(@spec_store.last_config_sync_time, @spec_store.initial_config_sync_time, @spec_store.init_reason))
197
+ evaluation_details: EvaluationDetails.new(
198
+ @spec_store.last_config_sync_time,
199
+ @spec_store.initial_config_sync_time,
200
+ @spec_store.init_reason
201
+ ),
202
+ group_name: nil,
203
+ id_type: config['idType']
204
+ )
180
205
  end
181
206
 
182
207
  private
@@ -206,8 +231,14 @@ module Statsig
206
231
  rule['returnValue'],
207
232
  rule['id'],
208
233
  exposures,
209
- evaluation_details: EvaluationDetails.new(@spec_store.last_config_sync_time, @spec_store.initial_config_sync_time, @spec_store.init_reason),
210
- is_experiment_group: rule["isExperimentGroup"] == true)
234
+ evaluation_details: EvaluationDetails.new(
235
+ @spec_store.last_config_sync_time,
236
+ @spec_store.initial_config_sync_time,
237
+ @spec_store.init_reason
238
+ ),
239
+ is_experiment_group: rule["isExperimentGroup"] == true,
240
+ group_name: rule['groupName']
241
+ )
211
242
  end
212
243
 
213
244
  def eval_delegate(name, user, rule, exposures)
data/lib/statsig.rb CHANGED
@@ -227,7 +227,7 @@ module Statsig
227
227
  def self.get_statsig_metadata
228
228
  {
229
229
  'sdkType' => 'ruby-server',
230
- 'sdkVersion' => '1.23.0',
230
+ 'sdkVersion' => '1.24.0',
231
231
  }
232
232
  end
233
233
 
@@ -245,7 +245,7 @@ class StatsigDriver
245
245
  end
246
246
  end
247
247
 
248
- DynamicConfig.new(res.name, res.json_value, res.rule_id)
248
+ DynamicConfig.new(res.name, res.json_value, res.rule_id, res.group_name, res.id_type)
249
249
  end
250
250
 
251
251
  def validate_user(user)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: statsig
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.23.0
4
+ version: 1.24.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Statsig, Inc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-16 00:00:00.000000000 Z
11
+ date: 2023-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler