MixpanelInstance
The class that represents the Mixpanel Instance
-
apiToken string that identifies the project to track data to
-
The a MixpanelDelegate object that gives control over Mixpanel network activity.
-
distinctId string that uniquely identifies the current user.
-
anonymousId string that uniquely identifies the device.
-
userId string that identify is called with.
-
hadPersistedDistinctId is a boolean value which specifies that the stored distinct_id already exists in persistence
-
alias string that uniquely identifies the current user.
-
Accessor to the Mixpanel People API object.
-
Controls whether to show spinning network activity indicator when flushing data to the Mixpanel servers. Defaults to true.
-
This allows enabling or disabling collecting common mobile events,
-
Flush timer’s interval. Setting a flush interval of 0 will turn off the flush timer and you need to call the flush() API manually to upload queued data to the Mixpanel server.
-
Control whether the library should flush data to Mixpanel when the app enters the background. Defaults to true.
-
Controls whether to automatically send the client IP Address as part of event tracking. With an IP address, the Mixpanel Dashboard will show you the users’ city. Defaults to true.
-
The base URL used for Mixpanel API requests. Useful if you need to proxy Mixpanel requests. Defaults to https://api.mixpanel.com.
-
-
This allows enabling or disabling of all Mixpanel logs at run time.
Note
All logging is disabled by default. Usually, this is only required if you are running in to issues with the SDK and you need support. -
A unique identifier for this MixpanelInstance
-
The minimum session duration (ms) that is tracked in automatic events. The default value is 10000 (10 seconds).
-
The maximum session duration (ms) that is tracked in automatic events. The default value is UINT64_MAX (no maximum session duration).
-
Sets the distinct ID of the current user.
Mixpanel uses a randomly generated persistent UUID as the default local distinct ID.
If you want to use a unique persistent UUID, you can define the
MIXPANEL_UNIQUE_DISTINCT_IDflag in yourActive Compilation Conditionsbuild settings. It then uses the IFV String (UIDevice.current().identifierForVendor) as the default local distinct ID. This ID will identify a user across all apps by the same vendor, but cannot be used to link the same user across apps from different vendors. If we are unable to get an IFV, we will fall back to generating a random persistent UUID.For tracking events, you do not need to call
identify:. However, Mixpanel User profiles always requires an explicit call toidentify:. If calls are made toset:,incrementor otherPeoplemethods prior to callingidentify:, then they are queued up and flushed onceidentify:is called.If you’d like to use the default distinct ID for Mixpanel People as well (recommended), call
identify:using the current distinct ID:mixpanelInstance.identify(mixpanelInstance.distinctId). -
The alias method creates an alias which Mixpanel will use to remap one id to another. Multiple aliases can point to the same identifier.
Please note: With Mixpanel Identity Merge enabled, calling alias is no longer required but can be used to merge two IDs in scenarios where identify() would fail
mixpanelInstance.createAlias("New ID", distinctId: mixpanelInstance.distinctId)You can add multiple id aliases to the existing id
mixpanelInstance.createAlias("Newer ID", distinctId: mixpanelInstance.distinctId) -
Clears all stored properties including the distinct Id. Useful if your app’s user logs out.
-
Uploads queued data to the Mixpanel server.
By default, queued data is flushed to the Mixpanel servers every minute (the default for
flushInterval), and on background (sinceflushOnBackgroundis on by default). You only need to call this method manually if you want to force a flush at a particular moment.
-
Tracks an event with properties. Properties are optional and can be added only if needed.
Properties will allow you to segment your events in your Mixpanel reports. Property keys must be String objects and the supported value types need to conform to MixpanelType. MixpanelType can be either String, Int, UInt, Double, Float, Bool, [MixpanelType], [String: MixpanelType], Date, URL, or NSNull. If the event is being timed, the timer will stop and be added as a property.
-
Tracks an event with properties and to specific groups. Properties and groups are optional and can be added only if needed.
Properties will allow you to segment your events in your Mixpanel reports. Property and group keys must be String objects and the supported value types need to conform to MixpanelType. MixpanelType can be either String, Int, UInt, Double, Float, Bool, [MixpanelType], [String: MixpanelType], Date, URL, or NSNull. If the event is being timed, the timer will stop and be added as a property.
-
-
Starts a timer that will be stopped and added as a property when a corresponding event is tracked.
This method is intended to be used in advance of events that have a duration. For example, if a developer were to track an “Image Upload” event she might want to also know how long the upload took. Calling this method before the upload code would implicitly cause the
trackcall to record its duration.Precondition
// begin timing the image upload: mixpanelInstance.time(event:“Image Upload”) // upload the image: self.uploadImageWithSuccessHandler() { _ in // track the event mixpanelInstance.track(“Image Upload”) }
-
Retrieves the time elapsed for the named event since time(event:) was called.
-
Clears all current event timers.
-
Clears the event timer for the named event.
-
Returns the currently set super properties.
-
Clears all currently set super properties.
-
Registers super properties, overwriting ones that have already been set.
Super properties, once registered, are automatically sent as properties for all event tracking calls. They save you having to maintain and add a common set of properties to your events. Property keys must be String objects and the supported value types need to conform to MixpanelType. MixpanelType can be either String, Int, UInt, Double, Float, Bool, [MixpanelType], [String: MixpanelType], Date, URL, or NSNull.
-
Registers super properties without overwriting ones that have already been set, unless the existing value is equal to defaultValue. defaultValue is optional.
Property keys must be String objects and the supported value types need to conform to MixpanelType. MixpanelType can be either String, Int, UInt, Double, Float, Bool, [MixpanelType], [String: MixpanelType], Date, URL, or NSNull.
-
Removes a previously registered super property.
As an alternative to clearing all properties, unregistering specific super properties prevents them from being recorded on future events. This operation does not affect the value of other super properties. Any property name that is not registered is ignored. Note that after removing a super property, events will show the attribute as having the value
undefinedin Mixpanel until a new value is registered. -
Convenience method to set a single group the user belongs to.
-
Set the groups this user belongs to.
-
Add a group to this user’s membership for a particular group key
-
Remove a group from this user’s membership for a particular group key
-
Opt out tracking.
This method is used to opt out tracking. This causes all events and people request no longer to be sent back to the Mixpanel server.
-
Opt in tracking.
Use this method to opt in an already opted out user from tracking. People updates and track calls will be sent to Mixpanel after using this method.
This method will internally track an opt in event to your project.
-
Returns if the current user has opted out tracking.
View on GitHub
MixpanelInstance Class Reference