Class MixpanelFlagVariant

java.lang.Object
com.mixpanel.android.mpmetrics.MixpanelFlagVariant

public class MixpanelFlagVariant extends Object
Represents the data associated with a feature flag variant from the Mixpanel API. This class stores the key and value of a specific variant for a feature flag. It can be instantiated either by parsing an API response or by creating a fallback instance.
  • Field Details

    • key

      @NonNull public final String key
      The key of the feature flag variant. This corresponds to the 'variant_key' field in the Mixpanel API response. It cannot be null.
    • value

      @Nullable public final Object value
      The value of the feature flag variant. This corresponds to the 'variant_value' field in the Mixpanel API response. The value can be of type Boolean, String, Number (Integer, Double, Float, Long), JSONArray, JSONObject, or it can be null.
    • experimentID

      @Nullable public final String experimentID
      The value of experimentID. This corresponds to the optional 'experiment_id' field in the Mixpanel API response.
    • isExperimentActive

      @Nullable public final Boolean isExperimentActive
      The value of isExperimentActive. This corresponds to the optional 'is_experiment_active' field in the Mixpanel API response.
    • isQATester

      @Nullable public final Boolean isQATester
      The value of isQATester. This corresponds to the optional 'is_qa_tester' field in the Mixpanel API response.
  • Constructor Details

    • MixpanelFlagVariant

      public MixpanelFlagVariant(@NonNull String key, @Nullable Object value)
      Constructs a MixpanelFlagVariant object when parsing an API response.
      Parameters:
      key - The key of the feature flag variant. Corresponds to 'variant_key' from the API. Cannot be null.
      value - The value of the feature flag variant. Corresponds to 'variant_value' from the API. Can be Boolean, String, Number, JSONArray, JSONObject, or null.
    • MixpanelFlagVariant

      public MixpanelFlagVariant(@NonNull String key, @Nullable Object value, @Nullable String experimentID, @Nullable Boolean isExperimentActive, @Nullable Boolean isQATester)
      Constructs a MixpanelFlagVariant object when parsing an API response with optional experiment fields.
      Parameters:
      key - The key of the feature flag variant. Corresponds to 'variant_key' from the API. Cannot be null.
      value - The value of the feature flag variant. Corresponds to 'variant_value' from the API. Can be Boolean, String, Number, JSONArray, JSONObject, or null.
      experimentID - The experiment ID. Corresponds to 'experiment_id' from the API. Can be null.
      isExperimentActive - Whether the experiment is active. Corresponds to 'is_experiment_active' from the API. Can be null.
      isQATester - Whether the user is a QA tester. Corresponds to 'is_qa_tester' from the API. Can be null.
    • MixpanelFlagVariant

      public MixpanelFlagVariant(@NonNull String keyAndValue)
      Constructs a MixpanelFlagVariant object for creating fallback instances. In this case, the provided keyAndValue is used as both the key and the value for the feature flag data. This is typically used when a flag is not found and a default string value needs to be returned.
      Parameters:
      keyAndValue - The string value to be used as both the key and the value for this fallback. Cannot be null.
    • MixpanelFlagVariant

      public MixpanelFlagVariant(@NonNull Object value)
      Constructs a MixpanelFlagVariant object for creating fallback instances. In this version, the key is set to an empty string (""), and the provided value is used as the value for the feature flag data. This is typically used when a flag is not found or an error occurs, and a default value needs to be provided.
      Parameters:
      value - The object value to be used for this fallback. Cannot be null. This can be of type Boolean, String, Number, JSONArray, or JSONObject.