FeatureFlagOptions
public struct FeatureFlagOptions
Configuration options for feature flags behavior.
Use this to control how and when feature flags are loaded by the SDK.
Example — Default behavior (prefetches flags during initialization):
let options = MixpanelOptions(
token: "YOUR_TOKEN",
featureFlagOptions: FeatureFlagOptions(enabled: true)
)
Example — Deferred loading (for use with identify):
let options = MixpanelOptions(
token: "YOUR_TOKEN",
featureFlagOptions: FeatureFlagOptions(enabled: true, prefetchFlags: false)
)
let mp = Mixpanel.initialize(options: options)
// identify() triggers loadFlags() internally when the distinctId changes
mp.identify(distinctId: "user123")
If identify may be called with the same persisted distinctId (no change),
call mp.flags.loadFlags() explicitly to ensure flags are fetched.
-
Whether feature flags are enabled. Defaults to
false.Declaration
Swift
public let enabled: Bool -
Custom context dictionary sent with flag fetch requests.
Declaration
Swift
public let context: [String : Any] -
Whether the SDK should prefetch feature flags during initialization. Defaults to
true.Set to
falseif you need to callidentifybefore the first flag fetch, then manually trigger loading viaflags.loadFlags().Declaration
Swift
public let prefetchFlags: Bool -
Strategy used to resolve flag variants relative to the on-disk persistence layer and the network. Defaults to
.networkOnly— variant lookups always wait for the network call, matching behavior prior to the introduction of variant persistence.Persistence behavior is derived directly from this policy:
.networkOnly— no persistence. The on-disk blob is also wiped at init if present (so toggling from a persisting policy back to.networkOnlycleans up after itself)..persistenceUntilNetworkSuccess(persistenceTtl:)/.networkFirst(persistenceTtl:)— successful fetches write to disk; persisted variants are read on init.
Declaration
Swift
public let variantLookupPolicy: VariantLookupPolicy -
Undocumented
Declaration
Swift
public init( enabled: Bool = false, context: [String: Any] = [:], prefetchFlags: Bool = true, variantLookupPolicy: VariantLookupPolicy = .networkOnly )
View on GitHub
Install in Dash