Swiftpack.co - Automattic/Automattic-Tracks-iOS as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by Automattic.
Automattic/Automattic-Tracks-iOS 2.0.0
Client library for tracking user events for later analysis
⭐️ 37
🕓 6 weeks ago
iOS macOS
.package(url: "https://github.com/Automattic/Automattic-Tracks-iOS.git", from: "2.0.0")


Client library for tracking user events for later analysis


Tracks for iOS is a client library used to help track events inside of an application. This project solely is responsible for collecting the events, storing them locally, and on a schedule send them out to the Automattic servers. Realistically this library is only useful for Automattic-based projects but the idea is to share what we've made.


You can install the Tracks component in your app via Swift Package Manager:

.package(url: "https://github.com/Automattic/Automattic-Tracks-iOS", from: "0.10.0")

You can import the entire library, using import AutomatticTracks. Or, you can import just one particular part of the library:

// Reporting events to the internal 'Tracks' service
import AutomatticTracksEvents

// Uploading app logs and crash logs to internal monitoring tools
import AutomatticRemoteLogging

// Running experiments using the internal 'ExPlat' tool
import AutomatticExperiments

// Displaying crash logs in your app
import AutomatticCrashLoggingUI

Tracks can also be installed via CocoaPods, though we encourage users to use Swift Package Manager instead. To install via Cocoapods:

pod 'Automattic-Tracks-iOS'


To report events:

  1. Create an instance of TracksService.
  2. Set an appropriate event name prefix using the propert eventNamePrefix. As an Automattician you will know how to get a prefix allowed.
  3. Keep this instance in a stable place and only instantiate one for your application.

Check out the TracksDemo project for more information on how to track events.

To run experiments:

  1. Call ExPlat.configure(platform:oauthToken:userAgent:anonId:) to configure the experiment platform. (If you are using TracksService, it will make this call for you when you create the Tracks service.)
  2. Register the experiments the app should use via Explat.shared.register(experiments:).
  3. Check ExPlat.shared.experiment("my_experiment_name") to determine which variant of an experiment should be used.

To upload files:

  1. Create an instance of EventLogging using init(dataSource:delegate:).
  2. Call enqueueLogForUpload(log:) to schedule log files for uploading.


Tracks logs about some of its activity. By default, this logging will just go to the console. If you'd like to include this logging in your own logging solution, you can create and assign a logging delegate conforming to TracksLoggingDelegate:

TracksLogging.delegate = MyLoggingHandler()


  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D


Original source: https://github.com/Automattic/Automattic-Tracks-iOS

Created by initially: Aaron Douglas @astralbodies


Automattic-Tracks-iOS is available under the GPLv2 license. See the LICENSE file for more info.


Stars: 37
Last commit: 4 days ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

6 weeks ago

Breaking Changes

  • ExPlat returns optional instead of assuming control as variation. This lets the client know that there is no variation for an experiment. [#247]

Internal Changes

  • Make Variation confirm to Codable. [#247]

New Contributors

Full Changelog: https://github.com/Automattic/Automattic-Tracks-iOS/compare/1.0.0...2.0.0

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics