posthog-ruby 3.10.0 → 3.11.0

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: caf866cb91c9fb07b894b6af005decf79644ddc3c2a7c2f84dc3dd59ac9350b1
4
- data.tar.gz: 6aace1e7809b8f2c6f8529086aaaf8cceb44d5f47b515222d0eeb0e757a66617
3
+ metadata.gz: 334d837a2faf144afce1125f198607af7d4078b34329c394df8e4e221bf1ab89
4
+ data.tar.gz: 62c48db3c45c0a962294546c06b485ace4e4d6f40bd5178f6c393f61e4243344
5
5
  SHA512:
6
- metadata.gz: ec98d033a36bd7069b001e957fd5a395d54225f505717c45322faa8ce157d00a8fdb1275b5ac4f098e3c51e78a8b2b13a11a94d76be7d50be9b87ab469da3285
7
- data.tar.gz: c0122abe71ac22a9075236b167c4a136c156f8af6853252f0caf18e4c7f41f8ccdd4b2132481d1138a6ec44793efef8d14ed35c3b7aa5769f45b20babd1ebae9
6
+ metadata.gz: 2e23767920c9f2169e45dfae59515e15bb17df9d6c69d08caaea786b4ee3a84f2e47aac6ac0f677b9193862eaf571c6657f1975142b749d8766fb49fcbf4c2c4
7
+ data.tar.gz: 7e51f30ec5ff951e639ce97efba159fa63a419897b12b5ca6418149323fd7a2ae469bbca2ba13eb9fa02cf8071cf0e39453cd96282eaadf4bdf1331e4269ae6e
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Portions of this file are derived from getsentry/sentry-ruby by Software, Inc. dba Sentry
4
- # Licensed under the MIT License
3
+ # Portions of this file are derived from getsentry/sentry-ruby
4
+ # Copyright (c) 2020 Sentry
5
+ # Licensed under the MIT License: https://github.com/getsentry/sentry-ruby/blob/master/LICENSE
5
6
  # - sentry-ruby/lib/sentry/interfaces/single_exception.rb
6
7
  # - sentry-ruby/lib/sentry/interfaces/stacktrace_builder.rb
7
8
  # - sentry-ruby/lib/sentry/backtrace.rb
@@ -961,6 +961,7 @@ module PostHog
961
961
 
962
962
  flag_conditions = flag_filters[:groups] || []
963
963
  flag_aggregation = flag_filters[:aggregation_group_type_index]
964
+ early_exit = flag_filters[:early_exit] == true
964
965
  is_inconclusive = false
965
966
  result = nil
966
967
 
@@ -997,8 +998,9 @@ module PostHog
997
998
  end
998
999
  end
999
1000
 
1000
- if condition_match(flag, effective_bucketing, condition, effective_properties, evaluation_cache,
1001
- cohort_properties)
1001
+ case condition_match_outcome(flag, effective_bucketing, condition, effective_properties, evaluation_cache,
1002
+ cohort_properties)
1003
+ when :match
1002
1004
  variant_override = condition[:variant]
1003
1005
  flag_multivariate = flag_filters[:multivariate] || {}
1004
1006
  flag_variants = flag_multivariate[:variants] || []
@@ -1009,6 +1011,8 @@ module PostHog
1009
1011
  end
1010
1012
  result = variant || true
1011
1013
  break
1014
+ when :out_of_rollout_bound
1015
+ break if early_exit
1012
1016
  end
1013
1017
  rescue RequiresServerEvaluation
1014
1018
  # Static cohort or other missing server-side data - must fallback to API
@@ -1030,6 +1034,18 @@ module PostHog
1030
1034
  end
1031
1035
 
1032
1036
  def condition_match(flag, distinct_id, condition, properties, evaluation_cache, cohort_properties = {})
1037
+ condition_match_outcome(flag, distinct_id, condition, properties, evaluation_cache,
1038
+ cohort_properties) == :match
1039
+ end
1040
+
1041
+ # Evaluates a single condition group and returns a tri-state outcome:
1042
+ # :match - property filters matched AND the rollout included the user
1043
+ # :no_match - a property filter did NOT match
1044
+ # :out_of_rollout_bound - property filters matched (or there were none) but the
1045
+ # rollout percentage excluded the user
1046
+ # Distinguishing :no_match from :out_of_rollout_bound lets the caller implement the
1047
+ # early_exit behavior (mirrors the server-side Rust evaluation engine).
1048
+ def condition_match_outcome(flag, distinct_id, condition, properties, evaluation_cache, cohort_properties = {})
1033
1049
  rollout_percentage = condition[:rollout_percentage]
1034
1050
 
1035
1051
  unless (condition[:properties] || []).empty?
@@ -1040,15 +1056,17 @@ module PostHog
1040
1056
  FeatureFlagsPoller.match_property(prop, properties, cohort_properties)
1041
1057
  end
1042
1058
  end
1043
- return false
1059
+ return :no_match
1044
1060
  end
1045
1061
 
1046
- return true if rollout_percentage.nil?
1062
+ return :match if rollout_percentage.nil?
1047
1063
  end
1048
1064
 
1049
- return false if !rollout_percentage.nil? && (_hash(flag[:key], distinct_id) > (rollout_percentage.to_f / 100))
1065
+ if !rollout_percentage.nil? && (_hash(flag[:key], distinct_id) > (rollout_percentage.to_f / 100))
1066
+ return :out_of_rollout_bound
1067
+ end
1050
1068
 
1051
- true
1069
+ :match
1052
1070
  end
1053
1071
 
1054
1072
  # This function takes a distinct_id and a feature flag key and returns a float between 0 and 1.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PostHog
4
- VERSION = '3.10.0'
4
+ VERSION = '3.11.0'
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.10.0
4
+ version: 3.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''