Class UserContextUtils

java.lang.Object
growthbook.sdk.java.util.UserContextUtils

public final class UserContextUtils extends Object
INTERNAL: not part of the supported API. Public only because the multiusermode internals call it from another package — treat its signatures as free to change without a major version bump. Builds the per-request UserContext shared by the local and remote evaluation paths: overlays user attributes on the client's global attributes and, when a StickyBucketService is configured, preloads the user's sticky-bucket assignment documents.

The sticky preload preserves the assignment behaviour that GrowthBookClient relied on before evaluation was split across GlobalContextManager and RemoteEvalCoordinator. Without it, multi-user clients using a StickyBucketService would evaluate experiments without their persisted assignments, changing assignment behaviour and diverging from the sticky-bucketing contract shared across GrowthBook SDKs.

  • Method Details

    • mergeAttributesAndPreloadSticky

      public static UserContext mergeAttributesAndPreloadSticky(Options options, @Nullable UserContext userContext)
      Merges global and per-user attributes and preloads sticky-bucket assignments for the merged attributes when a StickyBucketService is configured and the caller has not already supplied assignment documents.
      Parameters:
      options - client options (global attributes and optional sticky bucket service)
      userContext - the per-request user context; null is treated as an empty context
      Returns:
      a new user context carrying the merged attributes and any preloaded sticky docs