diff --git a/statsig/statsig_server.py b/statsig/statsig_server.py index 378ea78..e99c967 100644 --- a/statsig/statsig_server.py +++ b/statsig/statsig_server.py @@ -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 diff --git a/statsig/statsig_user.py b/statsig/statsig_user.py index 175b415..763e6d8 100644 --- a/statsig/statsig_user.py +++ b/statsig/statsig_user.py @@ -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 @@ -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') diff --git a/statsig/version.py b/statsig/version.py index 8969d49..1f04780 100644 --- a/statsig/version.py +++ b/statsig/version.py @@ -1 +1 @@ -__version__ = '0.9.1' +__version__ = '0.9.2'