posthog-ruby 3.28.1 → 3.28.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: 8c845018be0215ef9e7b28c605f4ed856815d4eb63076c2b76aa307a04fa5a47
4
- data.tar.gz: 9e0779372eea8be6e073c3d200159f7f1ac31986b3390147987368935f4710f4
3
+ metadata.gz: a2189eb3619aa39696f1c4ed7518dfb29f1c9fe0fc160a1ca147fce3476fb80d
4
+ data.tar.gz: ef16793b7d292cf30d8f41b3e4e17b4c387611230797044ae3b876041838f470
5
5
  SHA512:
6
- metadata.gz: 74eff3ba167884c7059a1dfed30ac4774d17bac42885096373f6949cead1bbb4d81c226ff8dd1c59361b824760c046027fa5470bf65fb416002a8c564f2b577f
7
- data.tar.gz: 42b6c6c956e45ab5352c1e9f93a5210c188fa129df7c24da1ca8efec6781baa820564a1bce965fc00176c69ab25273e8873c1220c821899ee14ce210c267bee4
6
+ metadata.gz: b3d512d5d6f4c99063f0896b49e37db3356bbacf48708409b28feeaca9371018cda8a16d546c4bf4c3e2e43246081d8a6fa76885f8034d8a8f834ea58d55fbd9
7
+ data.tar.gz: b8974fc38931e0f215e8cb777d533b4cf32a9a358ba1133db24ea850d21541a767f5eb01ab2470c6067da0b1f2cc07bba89f3ff3a833c0cab28f6a1d09c13186
@@ -689,6 +689,11 @@ module PostHog
689
689
  end.downcase
690
690
  end
691
691
 
692
+ def self.string_operand(value)
693
+ value.nil? ? 'null' : value.to_s
694
+ end
695
+ private_class_method :string_operand
696
+
692
697
  def self.exact_property_match?(filter, value, property_matching_version)
693
698
  return legacy_truthy?(filter) == legacy_truthy?(value) if property_matching_version != 2 && boolean_like?(filter)
694
699
  return legacy_truthy?(value) if filter.is_a?(Array) && filter.empty?
@@ -733,21 +738,21 @@ module PostHog
733
738
  when 'is_set'
734
739
  property_values.key?(key)
735
740
  when 'icontains'
736
- override_value.to_s.downcase(:ascii).include?(value.to_s.downcase(:ascii))
741
+ string_operand(override_value).downcase(:ascii).include?(value.to_s.downcase(:ascii))
737
742
  when 'not_icontains'
738
- !override_value.to_s.downcase(:ascii).include?(value.to_s.downcase(:ascii))
743
+ !string_operand(override_value).downcase(:ascii).include?(value.to_s.downcase(:ascii))
739
744
  when 'starts_with'
740
- override_value.to_s.downcase(:ascii).start_with?(value.to_s.downcase(:ascii))
745
+ string_operand(override_value).downcase(:ascii).start_with?(value.to_s.downcase(:ascii))
741
746
  when 'not_starts_with'
742
- !override_value.to_s.downcase(:ascii).start_with?(value.to_s.downcase(:ascii))
747
+ !string_operand(override_value).downcase(:ascii).start_with?(value.to_s.downcase(:ascii))
743
748
  when 'ends_with'
744
- override_value.to_s.downcase(:ascii).end_with?(value.to_s.downcase(:ascii))
749
+ string_operand(override_value).downcase(:ascii).end_with?(value.to_s.downcase(:ascii))
745
750
  when 'not_ends_with'
746
- !override_value.to_s.downcase(:ascii).end_with?(value.to_s.downcase(:ascii))
751
+ !string_operand(override_value).downcase(:ascii).end_with?(value.to_s.downcase(:ascii))
747
752
  when 'regex'
748
- PostHog::Utils.is_valid_regex(value.to_s) && !Regexp.new(value.to_s).match(override_value.to_s).nil?
753
+ PostHog::Utils.is_valid_regex(value.to_s) && !Regexp.new(value.to_s).match(string_operand(override_value)).nil?
749
754
  when 'not_regex'
750
- PostHog::Utils.is_valid_regex(value.to_s) && Regexp.new(value.to_s).match(override_value.to_s).nil?
755
+ PostHog::Utils.is_valid_regex(value.to_s) && Regexp.new(value.to_s).match(string_operand(override_value)).nil?
751
756
  when 'gt', 'gte', 'lt', 'lte'
752
757
  parsed_value = parse_finite_number(value)
753
758
  raise InconclusiveMatchError, 'Invalid numeric condition' if parsed_value.nil?
@@ -26,6 +26,7 @@ module PostHog
26
26
  # @return [Array<Hash>, nil]
27
27
  def <<(message)
28
28
  begin
29
+ message = normalize_non_finite_numbers(message)
29
30
  message_json = message.to_json
30
31
  rescue StandardError => e
31
32
  raise JSONGenerationError, "Serialization error: #{e}"
@@ -57,6 +58,39 @@ module PostHog
57
58
 
58
59
  private
59
60
 
61
+ def normalize_non_finite_numbers(message)
62
+ copies = {}.compare_by_identity
63
+ pending = []
64
+ normalized = copy_json_value(message, copies, pending)
65
+
66
+ # Traverse iteratively so circular/deep containers still reach the JSON encoder's error handling.
67
+ until pending.empty?
68
+ container = pending.pop
69
+ if container.is_a?(Hash)
70
+ container.transform_values! { |value| copy_json_value(value, copies, pending) }
71
+ else
72
+ container.map! { |value| copy_json_value(value, copies, pending) }
73
+ end
74
+ end
75
+ normalized
76
+ end
77
+
78
+ def copy_json_value(value, copies, pending)
79
+ case value
80
+ when Float
81
+ value.finite? ? value : nil
82
+ when Hash, Array
83
+ copies.fetch(value) do
84
+ copy = value.clone(freeze: false)
85
+ copies[value] = copy
86
+ pending << copy
87
+ copy
88
+ end
89
+ else
90
+ value
91
+ end
92
+ end
93
+
60
94
  def item_count_exhausted?
61
95
  @messages.length >= @max_message_count
62
96
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PostHog
4
- VERSION = '3.28.1'
4
+ VERSION = '3.28.3'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: posthog-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.28.1
4
+ version: 3.28.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''