FAQ
SDKs and APIs
How does bucketing within the Statsig SDKs work?
Bucketing in Statsig is deterministic. Given the same user object and the same state of the experiment or feature gate, Statsig always returns the same result, even when evaluated on different platforms (client or server). Here's how it works:
- Salt Creation: Each experiment or feature gate generates a unique salt.
- Hashing: The user identifier (e.g., userId, organizationId) is passed through a SHA256 hashing function, combined with the salt, which produces a large integer.
- Bucket Assignment: The large integer is then subjected to a modulus operation with 10000 (or 1000 for layers), assigning the user to a bucket.
- Bucket Determination: The result defines the specific bucket out of 10000 (or 1000 for layers) where the user is placed.
This process ensures a randomized but deterministic bucketing of users across different experiments or feature gates. The unique salt ensures that the same user can be assigned to different buckets in different experiments.
For more details, check our open-source SDKs here.
Is it possible to add a layer to a running experiment?
No. Once an experiment is started, you cannot change the layer. This restriction ensures the integrity of the experiment. We may support this feature in the future.
Why should I define parameters for my experiments instead of just getting the group?
Defining parameters for experiments provides flexibility and speed in iteration. Many companies, such as Facebook, Uber, and Airbnb, follow this approach in their experimentation platforms because it allows:
- Faster iteration (no code changes required for new experiments).
- More flexible experiment designs.
For example:
Without Parameters (Group-based):
if (otherExpEngine.getExperiment('button_color_test').getGroup() === 'Control') {
color = 'BLACK';
} else if (otherExpEngine.getExperiment('button_color_test').getGroup() === 'Blue') {
color = 'BLUE';
}
With Parameters (Statsig approach):
color = statsig.getExperiment('button_color_test').getString('button_color', 'BLACK');
In the first case, adding a new color (e.g., "Green") requires a code change. In the second case, you can modify the experiment configuration without making a code change.
Why am I not seeing my exposures and custom events logged in Statsig?
In short-lived processes (e.g., scripts or edge workers), the process may exit before the event queue flushes to Statsig. To ensure that exposures and events are logged, call statsig.flush()
before the process exits.
For details on flushing, check the Node.js Server SDK documentation.