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 Type | Variant Values | OpenFeature Method |
|---|
| Feature Gate | true / false | getBooleanValue() |
| Experiment | boolean, string, number, or JSON object | getBooleanValue(), getStringValue(), getIntegerValue(), getDoubleValue(), or getObjectValue() |
| Dynamic Config | JSON object | getObjectValue() |
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 Code | When |
|---|
PROVIDER_NOT_READY | Flags evaluated before the provider has finished initializing |
FLAG_NOT_FOUND | The requested flag does not exist in Mixpanel |
TYPE_MISMATCH | The flag value type does not match the requested type |
Troubleshooting
Flags Always Return Default Values
- Feature flags not enabled: Ensure MixpanelOptions includes
.featureFlags().
- Provider not ready: Use
setProviderAndWait to ensure initialization.
- Network issues: Check Logcat for failed requests.
- 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: