posthog-ruby 2.4.0 → 2.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/posthog/client.rb +31 -0
- data/lib/posthog/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b0fe64cbfa7e53a76fdd9241fb1eff4b428babe557ae8ee1ce62c2a287e42a5
|
4
|
+
data.tar.gz: afc4e5c842f2b38e8c2f9fa0247dfb4a01db2021ffccbb8d3e62f6acc904bf88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23134246b45ee9c507e4fb52aca1539ecf2af4b036976f7f5a6c6fbe2dafc20f3a3da677014019f5366243b10f5c2b29521dc81e4911ea2820d966d21b5c54ea
|
7
|
+
data.tar.gz: 72dea55baf64ca45b28d5642e8881004a6f0f2dc5f9f43e30d27a3392949a3994a16d805ce20e7bf2ac9f94ddce3d1817df33b152664b0dc582170281f03587d
|
data/lib/posthog/client.rb
CHANGED
@@ -174,6 +174,7 @@ class PostHog
|
|
174
174
|
# group_properties: {"organization": {"name": "PostHog", "employees": 11}}
|
175
175
|
# ```
|
176
176
|
def get_feature_flag(key, distinct_id, groups: {}, person_properties: {}, group_properties: {}, only_evaluate_locally: false, send_feature_flag_events: true)
|
177
|
+
person_properties, group_properties = add_local_person_and_group_properties(distinct_id, groups, person_properties, group_properties)
|
177
178
|
feature_flag_response, flag_was_locally_evaluated = @feature_flags_poller.get_feature_flag(key, distinct_id, groups, person_properties, group_properties, only_evaluate_locally)
|
178
179
|
|
179
180
|
feature_flag_reported_key = "#{key}_#{feature_flag_response}"
|
@@ -204,6 +205,7 @@ class PostHog
|
|
204
205
|
#
|
205
206
|
# @return [Hash] String (not symbol) key value pairs of flag and their values
|
206
207
|
def get_all_flags(distinct_id, groups: {}, person_properties: {}, group_properties: {}, only_evaluate_locally: false)
|
208
|
+
person_properties, group_properties = add_local_person_and_group_properties(distinct_id, groups, person_properties, group_properties)
|
207
209
|
return @feature_flags_poller.get_all_flags(distinct_id, groups, person_properties, group_properties, only_evaluate_locally)
|
208
210
|
end
|
209
211
|
|
@@ -218,6 +220,7 @@ class PostHog
|
|
218
220
|
# @option [Boolean] only_evaluate_locally
|
219
221
|
#
|
220
222
|
def get_feature_flag_payload(key, distinct_id, match_value: nil, groups: {}, person_properties: {}, group_properties: {}, only_evaluate_locally: false)
|
223
|
+
person_properties, group_properties = add_local_person_and_group_properties(distinct_id, groups, person_properties, group_properties)
|
221
224
|
@feature_flags_poller.get_feature_flag_payload(key, distinct_id, match_value, groups, person_properties, group_properties, only_evaluate_locally)
|
222
225
|
end
|
223
226
|
|
@@ -230,6 +233,7 @@ class PostHog
|
|
230
233
|
# @option [Boolean] only_evaluate_locally
|
231
234
|
#
|
232
235
|
def get_all_flags_and_payloads(distinct_id, groups: {}, person_properties: {}, group_properties: {}, only_evaluate_locally: false)
|
236
|
+
person_properties, group_properties = add_local_person_and_group_properties(distinct_id, groups, person_properties, group_properties)
|
233
237
|
@feature_flags_poller.get_all_flags_and_payloads(distinct_id, groups, person_properties, group_properties, only_evaluate_locally)
|
234
238
|
end
|
235
239
|
|
@@ -288,5 +292,32 @@ class PostHog
|
|
288
292
|
def worker_running?
|
289
293
|
@worker_thread && @worker_thread.alive?
|
290
294
|
end
|
295
|
+
|
296
|
+
def add_local_person_and_group_properties(distinct_id, groups, person_properties, group_properties)
|
297
|
+
|
298
|
+
groups ||= {}
|
299
|
+
person_properties ||= {}
|
300
|
+
group_properties ||= {}
|
301
|
+
|
302
|
+
symbolize_keys! groups
|
303
|
+
symbolize_keys! person_properties
|
304
|
+
symbolize_keys! group_properties
|
305
|
+
|
306
|
+
group_properties.each do |key, value|
|
307
|
+
symbolize_keys! value
|
308
|
+
end
|
309
|
+
|
310
|
+
all_person_properties = { "$current_distinct_id" => distinct_id }.merge(person_properties)
|
311
|
+
|
312
|
+
all_group_properties = {}
|
313
|
+
if groups
|
314
|
+
groups.each do |group_name, group_key|
|
315
|
+
all_group_properties[group_name] = {
|
316
|
+
"$group_key" => group_key}.merge(group_properties&.dig(group_name) || {})
|
317
|
+
end
|
318
|
+
end
|
319
|
+
|
320
|
+
return all_person_properties, all_group_properties
|
321
|
+
end
|
291
322
|
end
|
292
323
|
end
|
data/lib/posthog/version.rb
CHANGED