diff --git a/CHANGELOG.md b/CHANGELOG.md index f29fd0f6..a2199947 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to the LaunchDarkly Python SDK will be documented in this fi ## [7.6.0] - 2023-01-31 ### Added: -- Introduced support for an `application` config property which sets application metadata that may be used in LaunchDarkly analytics or other product features. . This does not affect feature flag evaluations. +- Introduced support for an `application` config property which sets application metadata that may be used in LaunchDarkly analytics or other product features. This does not affect feature flag evaluations. ## [7.5.1] - 2022-09-29 ### Added: diff --git a/ldclient/client.py b/ldclient/client.py index 86a45e06..98d937ab 100644 --- a/ldclient/client.py +++ b/ldclient/client.py @@ -408,7 +408,7 @@ def all_flags_state(self, user: dict, **kwargs) -> FeatureFlagsState: 'variation': detail.variation_index, 'reason': detail.reason, 'version': flag['version'], - 'trackEvents': flag['trackEvents'] or requires_experiment_data, + 'trackEvents': flag.get('trackEvents', False) or requires_experiment_data, 'trackReason': requires_experiment_data, 'debugEventsUntilDate': flag.get('debugEventsUntilDate', None), } diff --git a/testing/integrations/test_test_data_source.py b/testing/integrations/test_test_data_source.py index 47f0d025..fbf09266 100644 --- a/testing/integrations/test_test_data_source.py +++ b/testing/integrations/test_test_data_source.py @@ -329,3 +329,28 @@ def test_flag_can_evaluate_rules(): assert eval2.variation_index == 1 assert eval2.reason['kind'] == 'FALLTHROUGH' +def test_flag_can_evaluate_all_flags(): + td = TestData.data_source() + store = InMemoryFeatureStore() + + client = LDClient(config=Config('SDK_KEY', + update_processor_class = td, + send_events = False, + feature_store = store)) + + td.update(td.flag(key='test-flag') + .fallthrough_variation(False) + .if_match('firstName', 'Mike') + .and_not_match('country', 'gb') + .then_return(True)) + + user1 = { 'key': 'user1', 'firstName': 'Mike', 'country': 'us' } + flags_state = client.all_flags_state(user1, with_reasons=True) + + assert flags_state.valid + + value = flags_state.get_flag_value('test-flag') + reason = flags_state.get_flag_reason('test-flag') or {} + + assert value == True + assert reason.get('kind', None) == 'RULE_MATCH'