Skip to main content

Overview

This guide covers using Mixpanel’s Feature Flags through the OpenFeature standard with the Mixpanel Android OpenFeature provider. OpenFeature provides a vendor-agnostic API for feature flag evaluation, allowing you to switch between providers without changing your application code. For the native Mixpanel SDK approach, see the Feature Flags (Android) guide.

Prerequisites

Installation

Add to your build.gradle.kts:

Quick Start

Using an Existing MixpanelAPI Instance

This provider does not call mixpanel.identify() or mixpanel.track(). If you need to update the logged-in user or use Runtime Events for targeting, call these methods on the same MixpanelAPI instance whose Flags object was passed to the provider.

Usage

Flag Types and Evaluation Methods

Mixpanel Flag TypeVariant ValuesOpenFeature Method
Feature Gatetrue / falsegetBooleanValue()
Experimentboolean, string, number, or JSON objectgetBooleanValue(), getStringValue(), getIntegerValue(), getDoubleValue(), or getObjectValue()
Dynamic ConfigJSON objectgetObjectValue()

Evaluation Context

Context must be set globally via OpenFeatureAPI.setContext():
Per-evaluation context (the optional context parameter on evaluation methods) is not supported by this provider. Context must be set globally via OpenFeatureAPI.setContext(), which triggers a re-fetch of flag values from Mixpanel.

Runtime Properties

Pass custom_properties in the evaluation context for runtime targeting:
Unlike some providers, targetingKey is not used as a special bucketing key. It is passed as another context property. Mixpanel’s server-side configuration determines which properties are used for targeting and bucketing.

Full Resolution Details

User Identity

This provider does not call mixpanel.identify(). Manage identity through the same Mixpanel instance:

Error Handling

Error CodeWhen
PROVIDER_NOT_READYFlags evaluated before the provider has finished initializing
FLAG_NOT_FOUNDThe requested flag does not exist in Mixpanel
TYPE_MISMATCHThe flag value type does not match the requested type

Troubleshooting

Flags Always Return Default Values

  1. Feature flags not enabled: Ensure MixpanelOptions includes .featureFlags().
  2. Provider not ready: Use setProviderAndWait to ensure initialization.
  3. Network issues: Check Logcat for failed requests.
  4. Flag not configured: Verify the flag exists and is enabled.

Flags Not Updating After Context Change

Update context and the provider will re-fetch flags: