statsig 1.24.3 → 1.24.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/spec_store.rb +1 -1
- data/lib/statsig.rb +1 -1
- data/lib/statsig_logger.rb +39 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34ed13d83f7fc34162c3bec12058f7c0be928bf6057a0ecdf941526c8e768ec5
|
4
|
+
data.tar.gz: 9c309e3ec1430e0269d3a085aa1f3ce54d634c6c2ff3959f9c94a26dc0a14aca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc65c21d8a98879fe5b14a63ed3558e2b114cddaa829231ac5bae1f7e5b969563b8936c6c928890cc69a611c907227285fdcba98fd8a3c6ceab27e7b6ac1ca65
|
7
|
+
data.tar.gz: ae77abf8f573ca3de37133749a77f290f7d9b087846c9e612386f708b389fd2dd44279b8d26ba291f63c87d1d866b987ebcff9a98ac9d3acb1db4be5903fcdd1
|
data/lib/spec_store.rb
CHANGED
@@ -290,7 +290,7 @@ module Statsig
|
|
290
290
|
begin
|
291
291
|
server_id_lists = JSON.parse(response)
|
292
292
|
process_id_lists(server_id_lists, init_diagnostics)
|
293
|
-
save_id_lists_to_adapter(response)
|
293
|
+
save_id_lists_to_adapter(response.body.to_s)
|
294
294
|
rescue
|
295
295
|
# Ignored, will try again
|
296
296
|
end
|
data/lib/statsig.rb
CHANGED
data/lib/statsig_logger.rb
CHANGED
@@ -6,7 +6,7 @@ $gate_exposure_event = 'statsig::gate_exposure'
|
|
6
6
|
$config_exposure_event = 'statsig::config_exposure'
|
7
7
|
$layer_exposure_event = 'statsig::layer_exposure'
|
8
8
|
$diagnostics_event = 'statsig::diagnostics'
|
9
|
-
|
9
|
+
$ignored_metadata_keys = ['serverTime', 'configSyncTime', 'initTime', 'reason']
|
10
10
|
module Statsig
|
11
11
|
class StatsigLogger
|
12
12
|
def initialize(network, options)
|
@@ -23,6 +23,8 @@ module Statsig
|
|
23
23
|
)
|
24
24
|
|
25
25
|
@background_flush = periodic_flush
|
26
|
+
@deduper = Concurrent::Set.new()
|
27
|
+
@interval = 0
|
26
28
|
end
|
27
29
|
|
28
30
|
def log_event(event)
|
@@ -35,12 +37,15 @@ module Statsig
|
|
35
37
|
def log_gate_exposure(user, gate_name, value, rule_id, secondary_exposures, eval_details, context = nil)
|
36
38
|
event = StatsigEvent.new($gate_exposure_event)
|
37
39
|
event.user = user
|
38
|
-
|
40
|
+
metadata = {
|
39
41
|
'gate' => gate_name,
|
40
42
|
'gateValue' => value.to_s,
|
41
43
|
'ruleID' => rule_id,
|
42
44
|
}
|
45
|
+
return false if not is_unique_exposure(user, $gate_exposure_event, metadata)
|
46
|
+
event.metadata = metadata
|
43
47
|
event.statsig_metadata = Statsig.get_statsig_metadata
|
48
|
+
|
44
49
|
event.secondary_exposures = secondary_exposures.is_a?(Array) ? secondary_exposures : []
|
45
50
|
|
46
51
|
safe_add_eval_details(eval_details, event)
|
@@ -51,10 +56,12 @@ module Statsig
|
|
51
56
|
def log_config_exposure(user, config_name, rule_id, secondary_exposures, eval_details, context = nil)
|
52
57
|
event = StatsigEvent.new($config_exposure_event)
|
53
58
|
event.user = user
|
54
|
-
|
59
|
+
metadata = {
|
55
60
|
'config' => config_name,
|
56
61
|
'ruleID' => rule_id,
|
57
62
|
}
|
63
|
+
return false if not is_unique_exposure(user, $config_exposure_event, metadata)
|
64
|
+
event.metadata = metadata
|
58
65
|
event.statsig_metadata = Statsig.get_statsig_metadata
|
59
66
|
event.secondary_exposures = secondary_exposures.is_a?(Array) ? secondary_exposures : []
|
60
67
|
|
@@ -74,13 +81,15 @@ module Statsig
|
|
74
81
|
|
75
82
|
event = StatsigEvent.new($layer_exposure_event)
|
76
83
|
event.user = user
|
77
|
-
|
84
|
+
metadata = {
|
78
85
|
'config' => layer.name,
|
79
86
|
'ruleID' => layer.rule_id,
|
80
87
|
'allocatedExperiment' => allocated_experiment,
|
81
88
|
'parameterName' => parameter_name,
|
82
89
|
'isExplicitParameter' => String(is_explicit),
|
83
90
|
}
|
91
|
+
return false if not is_unique_exposure(user, $layer_exposure_event, metadata)
|
92
|
+
event.metadata = metadata
|
84
93
|
event.statsig_metadata = Statsig.get_statsig_metadata
|
85
94
|
event.secondary_exposures = exposures.is_a?(Array) ? exposures : []
|
86
95
|
|
@@ -101,6 +110,8 @@ module Statsig
|
|
101
110
|
loop do
|
102
111
|
sleep @options.logging_interval_seconds
|
103
112
|
flush
|
113
|
+
@interval++
|
114
|
+
@deduper.clear if @interval % 2 == 0
|
104
115
|
end
|
105
116
|
end
|
106
117
|
end
|
@@ -157,5 +168,29 @@ module Statsig
|
|
157
168
|
event.metadata['isManualExposure'] = 'true'
|
158
169
|
end
|
159
170
|
end
|
171
|
+
|
172
|
+
def is_unique_exposure(user, event_name, metadata)
|
173
|
+
return true if user.nil?
|
174
|
+
@deduper.clear if @deduper.size > 10000
|
175
|
+
custom_id_key = ''
|
176
|
+
if user.custom_ids.is_a?(Hash)
|
177
|
+
custom_id_key = user.custom_ids.values.join(',')
|
178
|
+
end
|
179
|
+
|
180
|
+
metadata_key = ''
|
181
|
+
if metadata.is_a?(Hash)
|
182
|
+
metadata_key = metadata.reject { |key, _| $ignored_metadata_keys.include?(key) }.values.join(',')
|
183
|
+
end
|
184
|
+
|
185
|
+
user_id_key = ''
|
186
|
+
unless user.user_id.nil?
|
187
|
+
user_id_key = user.user_id
|
188
|
+
end
|
189
|
+
key = [user_id_key, custom_id_key, event_name, metadata_key].join(',')
|
190
|
+
|
191
|
+
return false if @deduper.include?(key)
|
192
|
+
@deduper.add(key)
|
193
|
+
true
|
194
|
+
end
|
160
195
|
end
|
161
196
|
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: 1.24.
|
4
|
+
version: 1.24.4
|
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-
|
11
|
+
date: 2023-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|