Class FeatureFlagOptions

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

public class FeatureFlagOptions extends Object
Configuration options for Mixpanel feature flags.

Use this class to consolidate all feature flag settings into a single configuration object when initializing a MixpanelAPI instance via MixpanelOptions.Builder.featureFlagOptions(FeatureFlagOptions).


 FeatureFlagOptions featureFlagOptions = new FeatureFlagOptions.Builder()
     .enabled(true)
     .context(new JSONObject().put("plan", "enterprise"))
     .prefetchFlags(true)
     .variantLookupPolicy(VariantLookupPolicy.persistenceUntilNetworkSuccess())
     .build();

 MixpanelOptions options = new MixpanelOptions.Builder()
     .featureFlagOptions(featureFlagOptions)
     .build();
 
See Also:
  • Method Details

    • isEnabled

      public boolean isEnabled()
      Returns whether feature flags are enabled.
      Returns:
      true if feature flags are enabled, false otherwise. Defaults to false.
    • getContext

      @NonNull public org.json.JSONObject getContext()
      Returns a defensive copy of the context used for evaluating feature flags.

      The returned JSONObject is a copy; mutating it will not affect this FeatureFlagOptions instance.

      Returns:
      A non-null JSONObject containing the feature flags context. Defaults to an empty JSONObject.
    • shouldPrefetchFlags

      public boolean shouldPrefetchFlags()
      Returns whether feature flags should be automatically loaded on the first app foreground event.
      Returns:
      true if flags should be prefetched on first foreground, false otherwise. Defaults to true.
    • getVariantLookupPolicy

      @NonNull public VariantLookupPolicy getVariantLookupPolicy()
      Returns the strategy used to resolve flag variants relative to the on-disk persistence layer and the network. Determines whether the SDK reads and writes persisted variants: VariantLookupPolicy.networkOnly() disables both; VariantLookupPolicy.persistenceUntilNetworkSuccess() and VariantLookupPolicy.networkFirst() enable both.
      Returns:
      the configured VariantLookupPolicy; defaults to VariantLookupPolicy.networkOnly().