Date of slack thread: 4/25/24
Anonymous: Hi, I’m adding the Python sdk to my Django backend. I want to use statsig.check_gate
without the need for passing a user, but a user is required. In this case, the flag is for all users and because the code that is running is in a background worker it doesn’t have a current user. How can I accomplish this?
Statbot: When using statsig.check_gate
in a scenario where you do not have a specific user, such as in a background worker, you can pass any non-empty identifier, hard-coded string, or a random ID as the userID. This is because if you are using feature gates to turn on/off a feature for all of your users, or for all users passing certain conditions, the actual user ID is not necessary. However, you cannot target the empty string in the Statsig console. So, you can create a placeholder user with a non-empty identifier to perform the gate check in your background worker (source).
Statbot: Click below to mark as resolved.
Statbot: This thread has been marked as resolved. Press below to re-open.
Tore (Statsig): User is a bit of a misnomer - its really just the evaluation context. The SDK doesnt need any attributes, but some sort of identifier is necesarry for partial rollouts.
If you just want 0/100 gates, that works fine, but if you want to roll out to 10%, we need to know what 10% to evaluate on. So you’d need to provide a user or custom id.
You can learn more here: https://docs.statsig.com/messages/serverRequiredUserID