Overview
This guide covers using Mixpanel’s Feature Flags through the OpenFeature standard with the Mixpanel Java 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 (Java) guide.
Prerequisites
Installation
Maven
Gradle
Quick Start
Initialization
Local Evaluation (Recommended)
Targeting by Mixpanel cohorts and sticky variants are not supported in Local Evaluation mode.
Remote Evaluation
Using an Existing MixpanelAPI Instance
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
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
Accessing the Underlying MixpanelAPI
Shutdown
Error Handling
| Error Code | When |
|---|
PROVIDER_NOT_READY | Flags evaluated before the local provider has finished loading definitions |
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
- Provider not ready: Flag definitions are polled asynchronously. Allow time for the initial fetch.
- Invalid project token: Verify the token matches your Mixpanel project.
- Flag not configured: Verify the flag exists and is enabled.
Type Mismatch Errors
- Verify the flag’s value type matches your evaluation method.
- Use
getObjectValue() for JSON objects.
- Integer evaluation accepts
Long and whole-number Double values within Integer bounds. Double evaluation accepts any numeric type.