Class GBContext

java.lang.Object
growthbook.sdk.java.GBContext

public class GBContext extends Object
Context object passed into the GrowthBook constructor. The builder() is recommended for constructing a Context. Alternatively, you can use the class's constructor.
  • Constructor Details

    • GBContext

      public GBContext(@Nullable String attributesJson, @Nullable String featuresJson, @Nullable String encryptionKey, @Nullable Boolean enabled, Boolean isQaMode, @Nullable String url, Boolean allowUrlOverrides, @Nullable Map<String,Integer> forcedVariationsMap, @Nullable TrackingCallback trackingCallback, @Nullable FeatureUsageCallback featureUsageCallback)
      The GBContext.GBContextBuilder is recommended for constructing a Context. Alternatively, you can use this static method instead of the builder.
      Parameters:
      attributesJson - User attributes as JSON string
      featuresJson - Features response as JSON string, or the encrypted payload. Encrypted payload requires `encryptionKey`
      encryptionKey - Optional encryption key. If this is not null, featuresJson should be an encrypted payload.
      enabled - Whether globally all experiments are enabled (default: true)
      isQaMode - If true, random assignment is disabled and only explicitly forced variations are used.
      url - A URL string that is used for experiment evaluation, as well as forcing feature values.
      allowUrlOverrides - Boolean flag to allow URL overrides (default: false)
      forcedVariationsMap - Force specific experiments to always assign a specific variation (used for QA)
      trackingCallback - A function that takes Experiment and ExperimentResult as arguments.
  • Method Details

    • setAttributesJson

      public void setAttributesJson(String attributesJson)
      You can update the attributes JSON with new user attributes to evaluate against.
      Parameters:
      attributesJson - updated user attributes
    • setFeaturesJson

      public void setFeaturesJson(String featuresJson)
      You can update the features JSON with new features to evaluate against.
      Parameters:
      featuresJson - updated features
    • builder

      public static GBContext.GBContextBuilder builder()
      The builder class to help create a context. You can use this builder or the constructor
      Returns:
      GBContext.CustomGBContextBuilder