Skip to content

Commit 4539f4a

Browse files
committed
Use flag key instead of id
1 parent e5d7c8f commit 4539f4a

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

example.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
"distinct_id_random_22", person_properties={"$geoip_city_name": "Sydney"}, only_evaluate_locally=True
102102
)
103103
)
104+
print(posthog.get_decrypted_feature_flag_payload("encrypted_payload_flag_key"))
104105

105106

106107
posthog.shutdown()

posthog/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -436,12 +436,12 @@ def get_feature_flag_payload(
436436

437437

438438
def get_decrypted_feature_flag_payload(
439-
flag_id, # type: int
439+
key, # type: str
440440
):
441441
"""Get the decrypted payload for a specific feature flag.
442442
443443
Args:
444-
flag_id: The unique identifier of the feature flag
444+
key: The key of the feature flag
445445
446446
Returns:
447447
The decrypted payload associated with the feature flag
@@ -451,7 +451,7 @@ def get_decrypted_feature_flag_payload(
451451
"""
452452
return _proxy(
453453
"get_decrypted_feature_flag_payload",
454-
flag_id=flag_id,
454+
key=key,
455455
)
456456

457457

posthog/client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,11 @@ def get_decide(self, distinct_id, groups=None, person_properties=None, group_pro
206206

207207
return resp_data
208208

209-
def get_remote_config_payload(self, flag_id: int):
209+
def get_remote_config_payload(self, key: str):
210210
resp_data = remote_config(
211211
self.personal_api_key,
212212
self.host,
213-
flag_id,
213+
key,
214214
timeout=self.feature_flags_request_timeout_seconds,
215215
)
216216

@@ -820,7 +820,7 @@ def get_feature_flag_payload(
820820

821821
return payload
822822

823-
def get_decrypted_feature_flag_payload(self, flag_id: int):
823+
def get_decrypted_feature_flag_payload(self, key: str):
824824
if self.disabled:
825825
return None
826826

@@ -831,7 +831,7 @@ def get_decrypted_feature_flag_payload(self, flag_id: int):
831831
return None
832832

833833
try:
834-
return self.get_remote_config_payload(flag_id=flag_id)
834+
return self.get_remote_config_payload(key)
835835
except Exception as e:
836836
self.log.exception(f"[FEATURE FLAGS] Unable to get decrypted feature flag payload: {e}")
837837

posthog/request.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ def decide(api_key: str, host: Optional[str] = None, gzip: bool = False, timeout
8181
return _process_response(res, success_message="Feature flags decided successfully")
8282

8383

84-
def remote_config(api_key: str, host: Optional[str] = None, flag_id: int = 0, timeout: int = 15) -> Any:
84+
def remote_config(api_key: str, host: Optional[str] = None, key: str = "", timeout: int = 15) -> Any:
8585
"""Get remote config flag value from remote_config API endpoint"""
86-
return get(api_key, f"/api/projects/@current/feature_flags/{flag_id}/remote_config/", host, timeout)
86+
return get(api_key, f"/api/projects/@current/feature_flags/{key}/remote_config/", host, timeout)
8787

8888

8989
def batch_post(

0 commit comments

Comments
 (0)