Mixpanel
open class Mixpanel
The primary class for integrating Mixpanel with your app.
-
Undocumented
Declaration
Swift
@discardableResult open class func initialize(options: MixpanelOptions) -> MixpanelInstance -
initialize(token:trackAutomaticEvents: flushInterval: instanceName: optOutTrackingByDefault: useUniqueDistinctId: superProperties: serverURL: useGzipCompression: ) Initializes an instance of the API with the given project token.
Returns a new Mixpanel instance API object. This allows you to create more than one instance of the API object, which is convenient if you’d like to send data to more than one Mixpanel project from a single app.
Important
If you have more than one Mixpanel instance, it is beneficial to initialize the instances with an instanceName. Then they can be reached by calling getInstance with name.
Declaration
Swift
@discardableResult open class func initialize( token apiToken: String, trackAutomaticEvents: Bool, flushInterval: Double = 60, instanceName: String? = nil, optOutTrackingByDefault: Bool = false, useUniqueDistinctId: Bool = false, superProperties: Properties? = nil, serverURL: String? = nil, useGzipCompression: Bool = false ) -> MixpanelInstanceParameters
tokenyour project token
trackAutomaticEventsWhether or not to collect common mobile events
flushIntervalOptional. Interval to run background flushing
instanceNameOptional. The name you want to uniquely identify the Mixpanel Instance. It is useful when you want more than one Mixpanel instance under the same project token.
optOutTrackingByDefaultOptional. Whether or not to be opted out from tracking by default
useUniqueDistinctIdOptional. whether or not to use the unique device identifier as the distinct_id
superPropertiesOptional. Super properties dictionary to register during initialization
serverURLOptional. Mixpanel cluster URL
useGzipCompressionOptional. Whether to use gzip compression for network requests.
Return Value
returns a mixpanel instance if needed to keep throughout the project. You can always get the instance by calling getInstance(name)
-
initialize(token:trackAutomaticEvents: flushInterval: instanceName: optOutTrackingByDefault: useUniqueDistinctId: superProperties: proxyServerConfig: useGzipCompression: ) Initializes an instance of the API with the given project token.
Returns a new Mixpanel instance API object. This allows you to create more than one instance of the API object, which is convenient if you’d like to send data to more than one Mixpanel project from a single app.
Important
If you have more than one Mixpanel instance, it is beneficial to initialize the instances with an instanceName. Then they can be reached by calling getInstance with name.
Declaration
Swift
@discardableResult open class func initialize( token apiToken: String, trackAutomaticEvents: Bool, flushInterval: Double = 60, instanceName: String? = nil, optOutTrackingByDefault: Bool = false, useUniqueDistinctId: Bool = false, superProperties: Properties? = nil, proxyServerConfig: ProxyServerConfig, useGzipCompression: Bool = false ) -> MixpanelInstanceParameters
tokenyour project token
trackAutomaticEventsWhether or not to collect common mobile events
flushIntervalOptional. Interval to run background flushing
instanceNameOptional. The name you want to uniquely identify the Mixpanel Instance. It is useful when you want more than one Mixpanel instance under the same project token.
optOutTrackingByDefaultOptional. Whether or not to be opted out from tracking by default
useUniqueDistinctIdOptional. whether or not to use the unique device identifier as the distinct_id
superPropertiesOptional. Super properties dictionary to register during initialization
proxyServerConfigOptional. Setup for proxy server.
useGzipCompressionOptional. Whether to use gzip compression for network requests.
Return Value
returns a mixpanel instance if needed to keep throughout the project. You can always get the instance by calling getInstance(name)
-
initialize(token:flushInterval: instanceName: optOutTrackingByDefault: useUniqueDistinctId: superProperties: serverURL: useGzipCompression: ) Initializes an instance of the API with the given project token (MAC OS ONLY).
Returns a new Mixpanel instance API object. This allows you to create more than one instance of the API object, which is convenient if you’d like to send data to more than one Mixpanel project from a single app.
Important
If you have more than one Mixpanel instance, it is beneficial to initialize the instances with an instanceName. Then they can be reached by calling getInstance with name.
-
initialize(token:flushInterval: instanceName: optOutTrackingByDefault: useUniqueDistinctId: superProperties: proxyServerConfig: useGzipCompression: ) Initializes an instance of the API with the given project token (MAC OS ONLY).
Returns a new Mixpanel instance API object. This allows you to create more than one instance of the API object, which is convenient if you’d like to send data to more than one Mixpanel project from a single app.
Important
If you have more than one Mixpanel instance, it is beneficial to initialize the instances with an instanceName. Then they can be reached by calling getInstance with name.
-
Gets the mixpanel instance with the given name
Declaration
Swift
open class func getInstance(name: String) -> MixpanelInstance?Parameters
namethe instance name
Return Value
returns the mixpanel instance
-
Returns the main instance that was initialized.
If not specified explicitly, the main instance is always the last instance added
Declaration
Swift
open class func mainInstance() -> MixpanelInstanceReturn Value
returns the main Mixpanel instance
-
Returns the main Mixpanel instance if it has been initialized.
Declaration
Swift
public class func safeMainInstance() -> MixpanelInstance?Return Value
An optional MixpanelInstance, or nil if not yet initialized.
-
Sets the main instance based on the instance name
Declaration
Swift
open class func setMainInstance(name: String)Parameters
namethe instance name
-
Removes an unneeded Mixpanel instance based on its name
Declaration
Swift
open class func removeInstance(name: String)Parameters
namethe instance name
View on GitHub
Mixpanel Class Reference