posthog-ruby 3.35.0 → 3.35.2

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: 74ded46673020dda3dfaaf97e5911e0075f34b3c9eb482ba5ba3af9f2c67207a
4
- data.tar.gz: 4a8609d238306cccbc1b80dd263dec54dd9a7317461cce2e15abfea9d1d2fac6
3
+ metadata.gz: eb2187d8e83284c2141a23c6d303dca23cf6a1db04e2224314a225e101bc12cc
4
+ data.tar.gz: 2459aa316cd0e2888e272eb43497d42a45e28d12a7134d4dcb24cfda753fd0d1
5
5
  SHA512:
6
- metadata.gz: 57ebfdb7c813f13604d5ba589d16188076609e5945cba79b7bfd822380800b7aba81f9d41c085fcd20974c0a489b2cad32b13c9b73cc993b3cffdf6c022134d3
7
- data.tar.gz: b02e0e22a71a2e2af00b31498f4ca05b137b4468500cce5966c8fb5fd22a6a90084f2ed0c43930e96bd957b35783da82b19d54222a42ee49d5313df449724bd6
6
+ metadata.gz: 15711d84f77965e1df866202700a77e5f46b91905e69b9b270b9887eafaeb8eef2be1da11e0da03a36e636876862c97e5763f7f2a4d6c9deb947928376fed0ad
7
+ data.tar.gz: cc108fc3d9841c6e86ea85037b3adc50b89fd54595edab8ac8e575df595e34082ef94382b773fb82e68c68d148ce12cc2e2ea65b0a8d1e56fad2bad56ad5e727
@@ -767,6 +767,8 @@ module PostHog
767
767
  property_matching_version: property_matching_version)
768
768
  end
769
769
 
770
+ assert_property_filter_type_supported(property)
771
+
770
772
  begin
771
773
  match_property_value(property, property_values, property_matching_version)
772
774
  rescue InconclusiveMatchError => e
@@ -866,6 +868,25 @@ module PostHog
866
868
  end
867
869
  private_class_method :match_property_value
868
870
 
871
+ # Filter types matched against the person or group properties the call passes. A missing, null, or empty
872
+ # type is a person filter. Cohort and flag filters have their own matching. Any other type, such as
873
+ # person_metadata (a value the flags service reads from the persons table, not from person properties),
874
+ # can't be evaluated locally: matching it against a caller property with the same key could disagree
875
+ # with the flags service.
876
+ PROPERTY_FILTER_TYPES = [nil, '', 'person', 'group'].freeze
877
+ private_constant :PROPERTY_FILTER_TYPES
878
+
879
+ def self.assert_property_filter_type_supported(property)
880
+ type = extract_value(property, :type)
881
+ # A cohort group checks a flag filter as an ordinary property, so it keeps that matching here.
882
+ return if PROPERTY_FILTER_TYPES.include?(type) || type == 'flag'
883
+
884
+ raise InconclusiveMatchError.new(
885
+ "Can't evaluate a '#{type}' filter on '#{extract_value(property, :key)}' locally",
886
+ reason: UnresolvedFlagReason::UNSUPPORTED_DEFINITION
887
+ )
888
+ end
889
+
869
890
  # Raises an unsupported_definition error when local evaluation cannot use the filter, whatever
870
891
  # the call passes: an unknown operator, or a filter value that the operator cannot parse.
871
892
  def self.assert_filter_supported(property)
@@ -1366,6 +1387,7 @@ module PostHog
1366
1387
  end
1367
1388
 
1368
1389
  def self.unsupported_filter?(property)
1390
+ assert_property_filter_type_supported(property)
1369
1391
  assert_filter_supported(property)
1370
1392
  false
1371
1393
  rescue InconclusiveMatchError
@@ -1373,7 +1395,8 @@ module PostHog
1373
1395
  end
1374
1396
 
1375
1397
  private_class_method :extract_value, :find_cohort_property, :nested_property_group?,
1376
- :property_group_items_match?, :assert_filter_supported,
1398
+ :property_group_items_match?, :assert_property_filter_type_supported,
1399
+ :assert_filter_supported,
1377
1400
  :unsupported_property?, :unsupported_property_group?, :unsupported_filter?
1378
1401
 
1379
1402
  # Publish/capture all matching state together so a poll cannot switch semantics
@@ -1867,8 +1890,8 @@ module PostHog
1867
1890
 
1868
1891
  logger.warn(
1869
1892
  "[FEATURE FLAGS] #{unsupported_definition_keys.length} flag(s) use something local evaluation doesn't " \
1870
- 'support, such as a static cohort, an unknown operator, a malformed value, or a missing or circular flag ' \
1871
- "dependency (reason: #{UnresolvedFlagReason::UNSUPPORTED_DEFINITION}): " \
1893
+ 'support, such as a static cohort, an unknown operator or filter type, a malformed value, or a missing or ' \
1894
+ "circular flag dependency (reason: #{UnresolvedFlagReason::UNSUPPORTED_DEFINITION}): " \
1872
1895
  "#{unsupported_definition_keys.join(', ')}. Evaluating them makes a remote request when evaluation " \
1873
1896
  'reaches that part, or leaves them unresolved with only_evaluate_locally: true. To evaluate them ' \
1874
1897
  'locally, change these flags in PostHog or upgrade posthog-ruby.'
@@ -7,7 +7,7 @@ module PostHog
7
7
  # Reason values:
8
8
  # EXPERIENCE_CONTINUITY: The flag has experience continuity enabled, which local evaluation never resolves
9
9
  # UNSUPPORTED_DEFINITION: The flag uses something local evaluation does not support, such as a static
10
- # cohort, an unknown operator, a malformed value, or a missing or circular flag dependency
10
+ # cohort, an unknown operator or filter type, a malformed value, or a missing or circular flag dependency
11
11
  # UNRESOLVED_DEPENDENCY: A flag this flag depends on has a loaded definition but was unresolved
12
12
  # MISSING_CONTEXT: The call did not pass a property or group property the flag needs, or passed it in a
13
13
  # form local evaluation cannot use
data/lib/posthog/utils.rb CHANGED
@@ -70,9 +70,9 @@ module PostHog
70
70
  def datetime_in_iso8601(datetime)
71
71
  case datetime
72
72
  when Time
73
- time_in_iso8601 datetime
73
+ time_in_iso8601 datetime.getutc
74
74
  when DateTime
75
- time_in_iso8601 datetime.to_time
75
+ datetime.new_offset(0).strftime('%Y-%m-%dT%H:%M:%S.%LZ')
76
76
  when Date
77
77
  date_in_iso8601 datetime
78
78
  else
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PostHog
4
- VERSION = '3.35.0'
4
+ VERSION = '3.35.2'
5
5
  end
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: posthog-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.35.0
4
+ version: 3.35.2
5
5
  platform: ruby
6
6
  authors:
7
- - ''
7
+ - PostHog
8
8
  bindir: bin
9
9
  cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z