# MixpanelOptions

    public class MixpanelOptions

Undocumented

- `token`

  Undocumented

  #### Declaration

  Swift

      public let token: String

- `flushInterval`

  Undocumented

  #### Declaration

  Swift

      public let flushInterval: Double

- `instanceName`

  Undocumented

  #### Declaration

  Swift

      public let instanceName: String?

- `trackAutomaticEvents`

  Undocumented

  #### Declaration

  Swift

      public let trackAutomaticEvents: Bool

- `optOutTrackingByDefault`

  Undocumented

  #### Declaration

  Swift

      public let optOutTrackingByDefault: Bool

- `useUniqueDistinctId`

  Undocumented

  #### Declaration

  Swift

      public let useUniqueDistinctId: Bool

- `superProperties`

  Undocumented

  #### Declaration

  Swift

      public let superProperties: Properties?

- `serverURL`

  Undocumented

  #### Declaration

  Swift

      public let serverURL: String?

- `proxyServerConfig`

  Undocumented

  #### Declaration

  Swift

      public let proxyServerConfig: ProxyServerConfig?

- `useGzipCompression`

  Undocumented

  #### Declaration

  Swift

      public let useGzipCompression: Bool

- `featureFlagsEnabled`

  Undocumented

  #### Declaration

  Swift

      public var featureFlagsEnabled: Bool { get }

- `featureFlagsContext`

  Undocumented

  #### Declaration

  Swift

      public var featureFlagsContext: [String : Any] { get }

- `featureFlagOptions`

  Grouped configuration for feature flags behavior.

  When provided to the initializer, this takes precedence over the `featureFlagsEnabled` and `featureFlagsContext` parameters.

  #### Declaration

  Swift

      public let featureFlagOptions: FeatureFlagOptions

- `deviceIdProvider`

  A closure that provides a custom device ID.

  Use this to control device ID generation instead of relying on the SDK’s default behavior (random UUID or IDFV based on `useUniqueDistinctId`).

  Important: Choose your device ID strategy up front. This closure is called:

  - Once during initialization (if no persisted identity exists)
  - On each call to `reset()`
  - On each call to `optOutTracking()`

  Controlling Reset Behavior:

  - Return the same value each time = Device ID never changes (persistent identity)
  - Return a different value each time = Device ID changes on reset (ephemeral identity)
  - Return `nil` = Use SDK’s default device ID (useful for error handling)

  Thread Safety: This closure is called synchronously while holding internal locks. Keep implementations fast and non-blocking. For Keychain or network-fetched IDs, retrieve and cache the value at app launch, then return the cached value from the provider.

  Warning: Adding a `deviceIdProvider` to an existing app that previously used the default device ID may cause identity discontinuity. The SDK will log a warning if the provider returns a value different from the persisted anonymous ID.

  Example - Persistent Device ID (cached at launch):

      // Cache the device ID at app launch (before Mixpanel init)
      let cachedDeviceId = MyKeychainHelper.getOrCreatePersistentId()

      let options = MixpanelOptions(
          token: "YOUR_TOKEN",
          deviceIdProvider: { cachedDeviceId }  // Return cached value
      )

  Example - Ephemeral Device ID (resets each time):

      let options = MixpanelOptions(
          token: "YOUR_TOKEN",
          deviceIdProvider: {
              return UUID().uuidString
          }
      )

  #### Declaration

  Swift

      public let deviceIdProvider: (() -> String?)?

- `init(token:flushInterval:instanceName:trackAutomaticEvents:optOutTrackingByDefault:useUniqueDistinctId:superProperties:serverURL:proxyServerConfig:useGzipCompression:featureFlagsEnabled:featureFlagsContext:deviceIdProvider:featureFlagOptions:)`

  Undocumented

  #### Declaration

  Swift

      public init(
        token: String,
        flushInterval: Double = 60,
        instanceName: String? = nil,
        trackAutomaticEvents: Bool = false,
        optOutTrackingByDefault: Bool = false,
        useUniqueDistinctId: Bool = false,
        superProperties: Properties? = nil,
        serverURL: String? = nil,
        proxyServerConfig: ProxyServerConfig? = nil,
        useGzipCompression: Bool = true,  // NOTE: This is a new default value!
        featureFlagsEnabled: Bool = false,
        featureFlagsContext: [String: Any] = [:],
        deviceIdProvider: (() -> String?)? = nil,
        featureFlagOptions: FeatureFlagOptions? = nil
      )

© 2026 Mixpanel. All rights reserved. (Last updated: 2026-04-07)

Generated by jazzy ♪♫ v0.15.4, a Realm project.