Local Eval Adapter
Use the local evaluation data adapter in Statsig client SDKs to bootstrap evaluations from a custom data source, file, or server-rendered payload.
Local Eval Adapter
A common limitation of experimentation systems is the dependence on an upfront network request to fetch experiment configurations. Bootstrapping and Synchronous Initialization offer alternatives, but both have limitations: bootstrapping still requires an upfront request (though it can be made synchronous with other requests), and synchronous initialization can result in configs that are out of date by one session.The Local Eval Adapter solves this by letting you ship experiment configurations inline with your application, so you can run experiments before initialization completes. The adapter expects a ruleset defining your experiments, similar to Statsig's Server SDKs. Refer to the Example Ruleset below.Limitations
Shipping with a ruleset presents security concerns. When the experiment set is scoped to only a few experiments that run before any network requests, those concerns are often minimal. Exercise caution when shipping a ruleset in production code and verify that the contents are correct and safe.
Usage & Functionality
With proper attention to security and maintenance of the ruleset in your application, the Local Eval Adapter addresses the downsides of other experiment-at-launch strategies.
The local evaluation adapter is for Enterprise and Pro Tier companies only. If you are trying to follow these instructions but don't meet that criteria, some of the setup steps may not work.
The Adapter manifests as a StatsigOptions object seeded with a ruleset payload:
Statsig.initialize(
sdkKey: "client-sdkkey",
user: user,
options: StatsigOptions(
overrideAdapter: OnDeviceEvalAdapter(stringPayload: onDeviceEvalAdapterRulesetPayload)
)
) { err in
// Initialization completed. `err` is `nil` if it was successful
}
Example Ruleset "Config Spec"
The ruleset is a JSON object that contains the following fields:
{
"feature_gates": [],
"dynamic_configs": [],
"layer_configs": [],
"time": 1735718400000
}
Was this helpful?