Skip to content

Commit

Permalink
relax user object requirement on custom ids
Browse files Browse the repository at this point in the history
  • Loading branch information
jkw-statsig committed Apr 22, 2022
1 parent 70c19c4 commit b135667
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions statsig/statsig_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ def _verify_inputs(self, user: object, variable_name: str):
if not self._initialized:
raise RuntimeError(
'Must call initialize before checking gates/configs/experiments or logging events')
if not user or not user.user_id:
if not user or (not user.user_id and not user.custom_ids):
raise ValueError(
'A non-empty StatsigUser.user_id is required. See https://docs.statsig.com/messages/serverRequiredUserID')
'A non-empty StatsigUser with user_id or custom_ids is required. See https://docs.statsig.com/messages/serverRequiredUserID')
if not variable_name:
return False

Expand Down
4 changes: 2 additions & 2 deletions statsig/statsig_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def _str_or_none(field):
@dataclass
class StatsigUser:
"""An object of properties relating to the current user
user_id is required: learn more https://docs.statsig.com/messages/serverRequiredUserID
user_id or at least a custom ID is required: learn more https://docs.statsig.com/messages/serverRequiredUserID
Provide as many as possible to take advantage of advanced conditions in the statsig console
A dictionary of additional fields can be provided under the custom field
Set private_attributes for any user property you need for gate evaluation but prefer stripped from logs/metrics
Expand All @@ -29,7 +29,7 @@ class StatsigUser:

def __post_init__(self):
# ensure there is a user id or at least a custom ID, empty dict evaluates to false in python so we can use "not" operator to check
if (self.user_id is None or self.user_id == "") and (self.custom_ids is None or not self.custom_ids):
if not self.user_id and not self.custom_ids:
raise ValueError(
'user_id or at least a custom ID is required: learn more https://docs.statsig.com/messages/serverRequiredUserID')

Expand Down
2 changes: 1 addition & 1 deletion statsig/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.9.1'
__version__ = '0.9.2'

0 comments on commit b135667

Please sign in to comment.