statsig 2.9.2 → 2.9.3

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: cb1b471ac9aa8827bb59d3dd18801a1d7e663e8e3d25ea44be09753f02953ecf
4
- data.tar.gz: 5d08845dba73c8af7978c38c8519e790361a27dd4ed10f940a8af61d6c1b13e2
3
+ metadata.gz: 5371899fd2582b8e213db4bfc0c0c9252e2a7e16ff1303c94fa7e1cecc43cfda
4
+ data.tar.gz: 786baba109ff66e4c38ffc4c71995fdf5fde54910ac0d7712cdfb9b85ac584f4
5
5
  SHA512:
6
- metadata.gz: ca761ef81609cbd94bec7294109c893c683477c55c39f6475161269b65a7275e416253d8299e7f1995111d38d7bd7d09687aa8091bb90ffa0762daf609141f85
7
- data.tar.gz: 29d1482c76a1d78be0fd6e7c80886068a23c1973683050db19a08fa4d6a0b855a2549f24ebbadb6bc391669e09085b0bedc263db76cee9ea736099cf58b5fd80
6
+ metadata.gz: e4dc2ad08e71c883d41ecfa012f9e592c6ece9e18e8e14b9f0df9c5ef0732140dddf7cd0f6b88e27516efdbfa89e0d7309e2763fb634b73da0de082eb78b84f3
7
+ data.tar.gz: 9fc9b841b4d3f6020b9ea71a87203155a5eef84641ac1f7ff52a1e8913ef1735e3f49ef3730575d67050b1c00b7e61d0953a00b4cfc001af8e5b31277499f6d1
data/lib/network.rb CHANGED
@@ -19,6 +19,14 @@ module Statsig
19
19
 
20
20
  class Network
21
21
 
22
+ # Background config-spec sync retries transient failures with a short, bounded
23
+ # exponential backoff, matching statsig-server-core's background sync strategy
24
+ # (3 retries; 2^n * 100ms => 200ms, 400ms, 800ms). These are fixed rather than
25
+ # user-configurable, mirroring server-core where the values are hardcoded.
26
+ CONFIG_SYNC_RETRY_LIMIT = 3
27
+ CONFIG_SYNC_RETRY_BACKOFF_SECONDS = 0.2
28
+ CONFIG_SYNC_RETRY_BACKOFF_MULTIPLIER = 2
29
+
22
30
  def initialize(server_secret, options, backoff_mult = 10)
23
31
  super()
24
32
  @options = options
@@ -42,7 +50,7 @@ module Statsig
42
50
  if context == 'initialize'
43
51
  return get(dcs_url, @options.initialize_retry_limit)
44
52
  end
45
- get(dcs_url)
53
+ get(dcs_url, CONFIG_SYNC_RETRY_LIMIT, CONFIG_SYNC_RETRY_BACKOFF_SECONDS, CONFIG_SYNC_RETRY_BACKOFF_MULTIPLIER)
46
54
  end
47
55
 
48
56
  def download_config_specs_fallback(since_time, context)
@@ -84,8 +92,8 @@ module Statsig
84
92
  request(:GET, url, nil, 0, 1, false, 0, { 'Range' => "bytes=#{start_byte}-" }, false)
85
93
  end
86
94
 
87
- def get(url, retries = 0, backoff = 1)
88
- request(:GET, url, nil, retries, backoff)
95
+ def get(url, retries = 0, backoff = 1, backoff_multiplier = @backoff_multiplier)
96
+ request(:GET, url, nil, retries, backoff, false, 0, {}, true, backoff_multiplier)
89
97
  end
90
98
 
91
99
  def post(url, body, retries = 0, backoff = 1, zipped = false, event_count = 0)
@@ -106,7 +114,7 @@ module Statsig
106
114
  end
107
115
  end
108
116
 
109
- def request(method, url, body, retries = 0, backoff = 1, zipped = false, event_count = 0, extra_headers = {}, use_statsig_headers = true)
117
+ def request(method, url, body, retries = 0, backoff = 1, zipped = false, event_count = 0, extra_headers = {}, use_statsig_headers = true, backoff_multiplier = @backoff_multiplier)
110
118
  if @local_mode
111
119
  return nil, nil
112
120
  end
@@ -146,7 +154,7 @@ module Statsig
146
154
  return nil, e unless retries.positive?
147
155
 
148
156
  sleep backoff_adjusted
149
- return request(method, url, body, retries - 1, backoff * @backoff_multiplier, zipped, event_count, extra_headers, use_statsig_headers)
157
+ return request(method, url, body, retries - 1, backoff * backoff_multiplier, zipped, event_count, extra_headers, use_statsig_headers, backoff_multiplier)
150
158
  end
151
159
  return res, nil if res.status.success?
152
160
 
@@ -157,7 +165,7 @@ module Statsig
157
165
 
158
166
  ## status code retry
159
167
  sleep backoff_adjusted
160
- request(method, url, body, retries - 1, backoff * @backoff_multiplier, zipped, event_count, extra_headers, use_statsig_headers)
168
+ request(method, url, body, retries - 1, backoff * backoff_multiplier, zipped, event_count, extra_headers, use_statsig_headers, backoff_multiplier)
161
169
  end
162
170
 
163
171
  private
data/lib/statsig.rb CHANGED
@@ -410,7 +410,7 @@ module Statsig
410
410
  def self.get_statsig_metadata
411
411
  {
412
412
  'sdkType' => 'ruby-server',
413
- 'sdkVersion' => '2.9.2',
413
+ 'sdkVersion' => '2.9.3',
414
414
  'languageVersion' => RUBY_VERSION
415
415
  }
416
416
  end
@@ -34,6 +34,7 @@ class StatsigDriver
34
34
  tracker = @diagnostics.track('initialize', 'overall')
35
35
  @options = options || StatsigOptions.new
36
36
  @shutdown = false
37
+ @shutdown_message_logged = false
37
38
  @secret_key = secret_key
38
39
  @net = Statsig::Network.new(secret_key, @options)
39
40
  @logger = Statsig::StatsigLogger.new(@net, @options, @err_boundary, @sdk_configs)
@@ -460,8 +461,10 @@ class StatsigDriver
460
461
  end
461
462
 
462
463
  def check_shutdown
463
- if @shutdown
464
- puts 'SDK has been shutdown. Updates in the Statsig Console will no longer reflect.'
465
- end
464
+ return unless @shutdown
465
+ return if @shutdown_message_logged
466
+
467
+ @shutdown_message_logged = true
468
+ puts '[Statsig]: SDK has been shutdown. Updates in the Statsig Console will no longer reflect.'
466
469
  end
467
470
  end
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: 2.9.2
4
+ version: 2.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Statsig, Inc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-05-11 00:00:00.000000000 Z
11
+ date: 2026-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler