posthog-ruby 2.0.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/posthog/feature_flags.rb +22 -2
- data/lib/posthog/utils.rb +20 -0
- data/lib/posthog/version.rb +1 -1
- metadata +6 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57e103be9e2b8f115f96e948f0e82fd138b3c9ec9a7fe6fb1e1cff2e0c29b658
|
4
|
+
data.tar.gz: c275ab93b048fda6bd2e5fa65c8e1955296536b6a281405974db2460b941a626
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05cfc7dc4717b287287a37acd50680db1805ef41e42524feaabfd1b3113d96a1d5a90873b453f257e568ff75ce2d6a0e8db4ee82e26210ac280c628970bbed79
|
7
|
+
data.tar.gz: 7ca3acb35caa156e76b06bec03d13494b54a06fb6b727a6601c19d6cbb2e04437bb7873cb3e1e9534303042b84a34bbf35deba36e243bc843a7a89baeef278ac
|
@@ -196,6 +196,14 @@ class PostHog
|
|
196
196
|
override_value.class == value.class && override_value < value
|
197
197
|
when 'lte'
|
198
198
|
override_value.class == value.class && override_value <= value
|
199
|
+
when 'is_date_before', 'is_date_after'
|
200
|
+
parsed_date = PostHog::Utils::convert_to_datetime(value)
|
201
|
+
override_date = PostHog::Utils::convert_to_datetime(override_value)
|
202
|
+
if operator == 'is_date_before'
|
203
|
+
return override_date < parsed_date
|
204
|
+
else
|
205
|
+
return override_date > parsed_date
|
206
|
+
end
|
199
207
|
else
|
200
208
|
logger.error "Unknown operator: #{operator}"
|
201
209
|
false
|
@@ -247,10 +255,22 @@ class PostHog
|
|
247
255
|
is_inconclusive = false
|
248
256
|
result = nil
|
249
257
|
|
250
|
-
|
258
|
+
# Stable sort conditions with variant overrides to the top. This ensures that if overrides are present, they are
|
259
|
+
# evaluated first, and the variant override is applied to the first matching condition.
|
260
|
+
sorted_flag_conditions = flag_conditions.each_with_index.sort_by { |condition, idx| [condition[:variant].nil? ? 1 : -1, idx] }
|
261
|
+
|
262
|
+
sorted_flag_conditions.each do |condition, idx|
|
251
263
|
begin
|
252
264
|
if is_condition_match(flag, distinct_id, condition, properties)
|
253
|
-
|
265
|
+
variant_override = condition[:variant]
|
266
|
+
flag_multivariate = flag_filters[:multivariate] || {}
|
267
|
+
flag_variants = flag_multivariate[:variants] || []
|
268
|
+
if flag_variants.map{|variant| variant[:key]}.include?(condition[:variant])
|
269
|
+
variant = variant_override
|
270
|
+
else
|
271
|
+
variant = get_matching_variant(flag, distinct_id)
|
272
|
+
end
|
273
|
+
result = variant || true
|
254
274
|
break
|
255
275
|
end
|
256
276
|
rescue InconclusiveMatchError => e
|
data/lib/posthog/utils.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
require 'securerandom'
|
2
2
|
|
3
3
|
class PostHog
|
4
|
+
|
5
|
+
class InconclusiveMatchError < StandardError
|
6
|
+
end
|
7
|
+
|
4
8
|
module Utils
|
5
9
|
extend self
|
6
10
|
|
@@ -83,6 +87,22 @@ class PostHog
|
|
83
87
|
]
|
84
88
|
end
|
85
89
|
|
90
|
+
def convert_to_datetime(value)
|
91
|
+
if value.respond_to?(:strftime)
|
92
|
+
parsed_date = value
|
93
|
+
return parsed_date
|
94
|
+
elsif value.respond_to?(:to_str)
|
95
|
+
begin
|
96
|
+
parsed_date = DateTime.parse(value)
|
97
|
+
return parsed_date
|
98
|
+
rescue ArgumentError => e
|
99
|
+
raise InconclusiveMatchError.new("#{value} is not in a valid date format")
|
100
|
+
end
|
101
|
+
else
|
102
|
+
raise InconclusiveMatchError.new("The date provided must be a string or date object")
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
86
106
|
UTC_OFFSET_WITH_COLON = '%s%02d:%02d'
|
87
107
|
UTC_OFFSET_WITHOUT_COLON = UTC_OFFSET_WITH_COLON.sub(':', '')
|
88
108
|
|
data/lib/posthog/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: posthog-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ''
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -17,9 +17,6 @@ dependencies:
|
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1'
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 1.1.10
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -27,9 +24,6 @@ dependencies:
|
|
27
24
|
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '1'
|
30
|
-
- - "<"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: 1.1.10
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: commander
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -169,7 +163,7 @@ homepage: https://github.com/PostHog/posthog-ruby
|
|
169
163
|
licenses:
|
170
164
|
- MIT
|
171
165
|
metadata: {}
|
172
|
-
post_install_message:
|
166
|
+
post_install_message:
|
173
167
|
rdoc_options: []
|
174
168
|
require_paths:
|
175
169
|
- lib
|
@@ -184,8 +178,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
178
|
- !ruby/object:Gem::Version
|
185
179
|
version: '0'
|
186
180
|
requirements: []
|
187
|
-
rubygems_version: 3.1.
|
188
|
-
signing_key:
|
181
|
+
rubygems_version: 3.1.6
|
182
|
+
signing_key:
|
189
183
|
specification_version: 4
|
190
184
|
summary: PostHog library
|
191
185
|
test_files: []
|