posthog-ruby 3.7.0 → 3.8.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: afcf66d4afc793e15c83b53e455ef605218def4581460279d45721b82c1f73f2
4
- data.tar.gz: 96f13bf72ddc840302d71c21072db26bdd098b73fd862455dc65b745357dc7d2
3
+ metadata.gz: a21b0cf7196c00dff9b6ad23c7ee12e54b9984b9e2e7639d0f4371f419de80c2
4
+ data.tar.gz: 643244ae98a7d9879e64c905133aafba69e0e5e710e49766bdd38db24f28032d
5
5
  SHA512:
6
- metadata.gz: 8b3e3871c5be034db9928b012cc0a3417121dc6f1ab4e7c5ece24e1c637dc04959ef50e4f551de598e11c4922d4f54048a9438bb03c86eb1e0eac67eabefdf7d
7
- data.tar.gz: 3bf3128f6333b9678aa9c3a616494fcbff369ece30a0b0c422468cdab8856902a4184a560da84d6dbadb3dc935555b7402fe63d9158ea1da62589115247e7357
6
+ metadata.gz: f3e4329938912befad0b58c463dd5e82ff606e381c4f306e4a1d2e509963a613cff41acc5af853cd7a4f01033af283ee7a5f77324dd31e58c605b3f84a4d9d1b
7
+ data.tar.gz: e331c6d025c837c2c2764d4dcccbf61dd0c33e53f55dc9a5fbaf6a2628852c86f290dbf5c8c6c375e178d13ba839126e5c472e3bce1769e118d27b28f8410f17
@@ -892,7 +892,8 @@ module PostHog
892
892
 
893
893
  aggregation_group_type_index = flag_filters[:aggregation_group_type_index]
894
894
  if aggregation_group_type_index.nil?
895
- return match_feature_flag_properties(flag, distinct_id, person_properties, evaluation_cache, @cohorts)
895
+ return match_feature_flag_properties(flag, distinct_id, person_properties, evaluation_cache, @cohorts,
896
+ groups: groups, group_properties: group_properties)
896
897
  end
897
898
 
898
899
  group_name = @group_type_mapping[aggregation_group_type_index.to_s.to_sym]
@@ -916,7 +917,7 @@ module PostHog
916
917
 
917
918
  focused_group_properties = group_properties[group_name_symbol]
918
919
  match_feature_flag_properties(flag, groups[group_name_symbol], focused_group_properties, evaluation_cache,
919
- @cohorts)
920
+ @cohorts, groups: groups, group_properties: group_properties)
920
921
  end
921
922
 
922
923
  def _compute_flag_payload_locally(key, match_value)
@@ -931,23 +932,57 @@ module PostHog
931
932
  response
932
933
  end
933
934
 
934
- def match_feature_flag_properties(flag, distinct_id, properties, evaluation_cache, cohort_properties = {})
935
+ def match_feature_flag_properties(flag, distinct_id, properties, evaluation_cache, cohort_properties = {},
936
+ groups: {}, group_properties: {})
935
937
  flag_filters = flag[:filters] || {}
936
938
 
937
939
  flag_conditions = flag_filters[:groups] || []
940
+ flag_aggregation = flag_filters[:aggregation_group_type_index]
938
941
  is_inconclusive = false
939
942
  result = nil
940
943
 
941
944
  # NOTE: This NEEDS to be `each` because `each_key` breaks
942
945
  flag_conditions.each do |condition|
943
- if condition_match(flag, distinct_id, condition, properties, evaluation_cache, cohort_properties)
946
+ # Per-condition aggregation overrides only when the condition explicitly
947
+ # sets its own aggregation_group_type_index (mixed targeting). When absent,
948
+ # use the properties/bucketing already resolved by the caller.
949
+ condition_aggregation = condition.fetch(:aggregation_group_type_index, flag_aggregation)
950
+
951
+ effective_properties = properties
952
+ effective_bucketing = distinct_id
953
+
954
+ # Mixed-override path: condition-level aggregation differs from flag-level.
955
+ # This assumes flag-level aggregation is nil for mixed flags.
956
+ if condition_aggregation != flag_aggregation
957
+ if condition_aggregation.nil?
958
+ # Person condition under a mixed flag — caller already passed person props/bucketing.
959
+ else
960
+ group_name = @group_type_mapping[condition_aggregation.to_s.to_sym]
961
+ if group_name.nil? || !groups.key?(group_name.to_sym)
962
+ logger.debug do
963
+ "[FEATURE FLAGS] Skipping group condition for flag '#{flag[:key]}': " \
964
+ "group type index #{condition_aggregation} not available"
965
+ end
966
+ next
967
+ end
968
+ unless group_properties.key?(group_name.to_sym)
969
+ is_inconclusive = true
970
+ next
971
+ end
972
+ effective_properties = group_properties[group_name.to_sym]
973
+ effective_bucketing = groups[group_name.to_sym]
974
+ end
975
+ end
976
+
977
+ if condition_match(flag, effective_bucketing, condition, effective_properties, evaluation_cache,
978
+ cohort_properties)
944
979
  variant_override = condition[:variant]
945
980
  flag_multivariate = flag_filters[:multivariate] || {}
946
981
  flag_variants = flag_multivariate[:variants] || []
947
982
  variant = if flag_variants.map { |variant| variant[:key] }.include?(condition[:variant])
948
983
  variant_override
949
984
  else
950
- get_matching_variant(flag, distinct_id)
985
+ get_matching_variant(flag, effective_bucketing)
951
986
  end
952
987
  result = variant || true
953
988
  break
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PostHog
4
- VERSION = '3.7.0'
4
+ VERSION = '3.8.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.7.0
4
+ version: 3.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''