@@ -28,17 +28,14 @@ class FeatureFlagManager:
2828
2929 def __init__ (self , app : Application ) -> None :
3030 self .__app = app
31-
32- self .__client = DatadogFeatureFlag (self .__client_token , self .__app )
33-
3431 # Manually implemented cache to avoid calling several time Feature flag backend on the same flag evaluation.
3532 # Cache key is a tuple of the flag, entity and scopes, to make it hashable.
3633 # For example after calling `enabled("test-flag", default=False, scopes={"user": "user1"}),
3734 # the cache will contain the result for the tuple ("test-flag", "entity", (("user", "user1"),)).
3835 self .__cache : dict [tuple [str , str , tuple [tuple [str , str ], ...]], Any ] = {}
3936
4037 @cached_property
41- def __client_token (self ) -> str | None :
38+ def __client (self ) -> str | None :
4239 if running_in_ci (): # We do not support feature flags token retrieval in the CI yet.
4340 return None
4441
@@ -53,7 +50,7 @@ def __client_token(self) -> str | None:
5350 client_token = fetch_client_token ()
5451 save_client_token (client_token )
5552
56- return client_token
53+ return DatadogFeatureFlag ( client_token , self . __app )
5754
5855 @property
5956 def __user (self ) -> FeatureFlagUser :
@@ -68,8 +65,8 @@ def __get_entity(self) -> str:
6865 return self .__user .machine_id
6966
7067 def enabled (self , flag : str , * , default : bool = False , scopes : Optional [dict [str , str ]] = None ) -> bool :
71- if not self .__client_token :
72- self .__app .display_debug ("No client token found " )
68+ if self .__client is None :
69+ self .__app .display_debug ("Feature flag client not initialized properly " )
7370 return default
7471
7572 entity = self .__get_entity ()
0 commit comments