statsig 1.16.0 → 1.16.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/statsig.rb +1 -1
- data/lib/statsig_driver.rb +1 -2
- data/lib/statsig_event.rb +4 -0
- data/lib/statsig_logger.rb +26 -18
- data/lib/statsig_user.rb +10 -0
- metadata +20 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4dcb84e4bc8ba66021edba175badb275faf6adfd25ca69f662a8b66a1c1cee64
|
4
|
+
data.tar.gz: e4564a84d37ce348006eddbc6e7ff6371e1493e0a4e13e9ad987653b1f0b266a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c33220e646b1af64499f40989ac4bccffbaf1cbd352f3ab6efc13a0d5246e726a37b95f2bce2c912fcb7b3fb8ed67d487ff9da07f28d01917178cfd8fba2293
|
7
|
+
data.tar.gz: 2ea4f85caede773fc57f84934946f3fde39002d524326e9134ed2cc3410ed02258034b3a81808bc438c7a6d200dfeb5268c16c57a36bcbdce1956424257e1141
|
data/lib/statsig.rb
CHANGED
data/lib/statsig_driver.rb
CHANGED
@@ -94,7 +94,7 @@ class StatsigDriver
|
|
94
94
|
|
95
95
|
def shutdown
|
96
96
|
@shutdown = true
|
97
|
-
@logger.
|
97
|
+
@logger.shutdown
|
98
98
|
@evaluator.shutdown
|
99
99
|
end
|
100
100
|
|
@@ -115,7 +115,6 @@ class StatsigDriver
|
|
115
115
|
|
116
116
|
def maybe_restart_background_threads
|
117
117
|
@evaluator.maybe_restart_background_threads
|
118
|
-
@logger.maybe_restart_background_threads
|
119
118
|
end
|
120
119
|
|
121
120
|
private
|
data/lib/statsig_event.rb
CHANGED
data/lib/statsig_logger.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'statsig_event'
|
2
|
+
require 'concurrent-ruby'
|
2
3
|
|
3
4
|
$gate_exposure_event = 'statsig::gate_exposure'
|
4
5
|
$config_exposure_event = 'statsig::config_exposure'
|
@@ -9,14 +10,23 @@ module Statsig
|
|
9
10
|
def initialize(network, options)
|
10
11
|
@network = network
|
11
12
|
@events = []
|
12
|
-
@background_flush = periodic_flush
|
13
13
|
@options = options
|
14
|
+
|
15
|
+
@logging_pool = Concurrent::ThreadPoolExecutor.new(
|
16
|
+
min_threads: [2, Concurrent.processor_count].min,
|
17
|
+
max_threads: [2, Concurrent.processor_count].max,
|
18
|
+
# max jobs pending before we start dropping
|
19
|
+
max_queue: [2, Concurrent.processor_count].max * 5,
|
20
|
+
fallback_policy: :discard,
|
21
|
+
)
|
22
|
+
|
23
|
+
@background_flush = periodic_flush
|
14
24
|
end
|
15
25
|
|
16
26
|
def log_event(event)
|
17
27
|
@events.push(event)
|
18
28
|
if @events.length >= @options.logging_max_buffer_size
|
19
|
-
|
29
|
+
flush_async
|
20
30
|
end
|
21
31
|
end
|
22
32
|
|
@@ -83,10 +93,20 @@ module Statsig
|
|
83
93
|
end
|
84
94
|
end
|
85
95
|
|
86
|
-
def
|
87
|
-
|
88
|
-
|
96
|
+
def shutdown
|
97
|
+
@background_flush&.exit
|
98
|
+
@logging_pool.shutdown
|
99
|
+
@logging_pool.wait_for_termination(timeout = 3)
|
100
|
+
flush
|
101
|
+
end
|
102
|
+
|
103
|
+
def flush_async
|
104
|
+
@logging_pool.post do
|
105
|
+
flush
|
89
106
|
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def flush
|
90
110
|
if @events.length == 0
|
91
111
|
return
|
92
112
|
end
|
@@ -94,19 +114,7 @@ module Statsig
|
|
94
114
|
@events = []
|
95
115
|
flush_events = events_clone.map { |e| e.serialize }
|
96
116
|
|
97
|
-
|
98
|
-
@network.post_logs(flush_events)
|
99
|
-
else
|
100
|
-
Thread.new do
|
101
|
-
@network.post_logs(flush_events)
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
def maybe_restart_background_threads
|
107
|
-
if @background_flush.nil? or !@background_flush.alive?
|
108
|
-
@background_flush = periodic_flush
|
109
|
-
end
|
117
|
+
@network.post_logs(flush_events)
|
110
118
|
end
|
111
119
|
|
112
120
|
private
|
data/lib/statsig_user.rb
CHANGED
@@ -19,6 +19,16 @@ class StatsigUser
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def initialize(user_hash)
|
22
|
+
@user_id = nil
|
23
|
+
@email = nil
|
24
|
+
@ip = nil
|
25
|
+
@user_agent = nil
|
26
|
+
@country = nil
|
27
|
+
@locale = nil
|
28
|
+
@app_version = nil
|
29
|
+
@custom = nil
|
30
|
+
@private_attributes = nil
|
31
|
+
@custom_ids = nil
|
22
32
|
@statsig_environment = Hash.new
|
23
33
|
if user_hash.is_a?(Hash)
|
24
34
|
@user_id = user_hash['userID'] || user_hash['user_id']
|
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.16.
|
4
|
+
version: 1.16.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Statsig, Inc
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '2.
|
19
|
+
version: '2.0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '2.
|
26
|
+
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: webmock
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,6 +114,20 @@ dependencies:
|
|
114
114
|
- - '='
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: 0.1.1
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: concurrent-ruby
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - "~>"
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '1.1'
|
124
|
+
type: :runtime
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - "~>"
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '1.1'
|
117
131
|
description: Statsig server SDK for feature gates and experimentation in Ruby
|
118
132
|
email: support@statsig.com
|
119
133
|
executables: []
|
@@ -149,14 +163,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
149
163
|
requirements:
|
150
164
|
- - ">="
|
151
165
|
- !ruby/object:Gem::Version
|
152
|
-
version: 2.5.
|
166
|
+
version: 2.5.0
|
153
167
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
168
|
requirements:
|
155
169
|
- - ">="
|
156
170
|
- !ruby/object:Gem::Version
|
157
171
|
version: '0'
|
158
172
|
requirements: []
|
159
|
-
rubygems_version: 3.3.
|
173
|
+
rubygems_version: 3.3.22
|
160
174
|
signing_key:
|
161
175
|
specification_version: 4
|
162
176
|
summary: Statsig server SDK for Ruby
|