GamebeastDocs
Dashboard
Unity SDKAPI Reference

Experiments

This API is used to read the experiments the local user is currently enrolled in.

For more information about Experiments, visit the Experiments Guide.

Enrollment happens automatically: fetching a configuration evaluates active experiments for the local user, and the values returned by the Configs service already include the assigned group's changes. This service exists for display, analytics segmentation, and debugging.

var gamebeastExperiments = GamebeastSdk.Experiments;

Types

ExperimentAssignment

public sealed class ExperimentAssignment
{
    public long ExperimentId;
    public string ExperimentName;       // The name of the experiment. Null until the experiment catalog has loaded.
    public long GroupId;
    public string GroupLabel;           // The label of the assigned group. Null until the experiment catalog has loaded.
    public string ConfigurationAlias;   // The alias of the configuration the experiment applies to.
    public string Source;               // "weightedHash", "roundRobin" or "manual".
}

Assignments

IReadOnlyList<ExperimentAssignment>return type

This property contains the local user's active experiment assignments across all fetched configurations. It is empty until the first configuration has been fetched.

Usage

foreach (var assignment in gamebeastExperiments.Assignments)
{
    Debug.Log($"User is in group {assignment.GroupLabel} of experiment {assignment.ExperimentName}");
}

OnAssignmentsChanged(callback)

IDisposablereturn type

This callback is triggered with the full assignment list whenever it changes, including when experiment names finish resolving.

callbackAction<IReadOnlyList<ExperimentAssignment>>

The callback function to be invoked when the assignments change. The updated assignment list is passed as a parameter to the callback.

Usage

gamebeastExperiments.OnAssignmentsChanged(assignments =>
{
    Debug.Log($"User is now in {assignments.Count} experiment(s).");
});

On this page