Skip to main content

Getting All Assignments Instantaneously

info

Our SDKs are designed to be invoked in your code at the point where you're serving the experiment treatment or feature. For this reason, we recommend leveraging the standard approach of calling getExperiment, checkGate, or getLayer supplying the user object and the key as needed to determine what to serve.

Often times, customers have the desire to capture all assignments (experiment, gates) in a single call in an edge function or on the server for a each user at the start of their session. This practice is commonly done as a means to pass assignment information to other applications, or to use assignment information as cache-keys for the CDN + edge compute use-case.

For this use-case, we recommend using the getClientInitializeResponse server sdk method to generate the full assignments payload.

Example of capturing all assignments in Node

Note that this method is designed to bootstrap the client SDKs, and as such, will hash the experiment and feature keys returned in the payload, obfuscating their names to mitigate the possibility of end-users spoofing into features & gates. You can now provide an optional hash parameter, allowing you to disable hashing and capture all group names and values in plain text — Node, Python, Java, Go.

const assignments = statsig.getClientInitializeResponse(userObj, options={hash: null});