Swift Objective-C
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Mixpanel.xcodeproj
Mixpanel
.gitignore
.swift-version
Cartfile.private
Cartfile.resolved
LICENSE
Readme.markdown

Readme.markdown

Mixpanel

Version Carthage compatible

Unofficial Mixpanel client written in Swift 2 for iOS and Mac.

This is a very simple client that just implements tracking events and identifying the current user. A network request is initiated whenver you call track. If it fails, nothing happens. Eventually, it would be cool if it stored these and retried at some point.

Installation

Carthage is the recommended way to install Mixpanel. Add the following to your Cartfile:

github "soffes/Mixpanel"

Usage

import Mixpanel

// Setup a client
let mixpanel = Mixpanel(token: "your app token")

// Identify the current user. This doesn't make a network request. It simply
// will add their identifer to the next event tracked.
mixpanel.identify("7")

// Track an event
mixpanel.track("Launch")

// Track an event with parameters
mixpanel.track("Share", parameters: [
  "service": "Twitter",
])

// You can also customize the time the event happened and add a completion
// handler if you want.
mixpanel.track("Import photo", parameters: [
  "source": "Photo library"
], time: someTime, completion: (success) in {
  println("Tracked event successfully: \(success)")
})

Enjoy.