Skip to main content

Overview

This guide covers using Mixpanel’s Feature Flags through the OpenFeature standard with the Mixpanel Swift 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 (Swift) guide.

Prerequisites

  • Enterprise subscription plan with Feature Flags enabled
  • iOS 14.0+ / tvOS 14.0+ / macOS 11.0+ / watchOS 7.0+
  • Swift 5.5+
  • Project Token from your Mixpanel Project Settings

Installation

Add the following to your Package.swift:
Then add MixpanelOpenFeature as a dependency of your target:

Quick Start

Using an Existing Mixpanel 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 Mixpanel instance that was passed to the provider.

Usage

Flag Types and Evaluation Methods

Evaluation Context

Context must be set globally via OpenFeatureAPI.shared.setEvaluationContext():

Runtime Properties

Pass custom_properties in the evaluation context for Runtime Properties 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

Error Handling

To avoid PROVIDER_NOT_READY, use setProviderAndWait:

Troubleshooting

Flags Always Return Default Values

  1. Provider not ready: Use setProviderAndWait to ensure initialization completes.
  2. Network issues: Check for failed requests to Mixpanel’s flags API.
  3. Flag not configured: Verify the flag exists and is enabled in your Mixpanel project.

Flags Not Updating After Context Change

When you update the OpenFeature context, the provider fetches new flag values:
If flags still aren’t updating, verify your targeting rules in Mixpanel use the context properties you’re setting.