Skip to content

SDKs

iOS SDK

Add Tracklyne to an iOS app with Swift Package Manager: screens, events, identify, feature flags and errors.

Install

In Xcode choose File → Add Package Dependencies…, enter the package URL shown in Project settings → Install → iOS, and add the TracklyneSwift product to your app target. iOS 14+, macOS 12+ and tvOS 14+, no dependencies.

AppDelegate.swift
import TracklyneSwift

// AppDelegate or App.init()
let config = TracklyneConfig(token: "tl_your_project_token", host: "https://tracklyne.com")
Tracklyne.shared.setup(config)

Tracklyne.shared.capture("workout finished", properties: ["minutes": 42])
Tracklyne.shared.identify(user.id, userProperties: ["plan": "pro"])

if Tracklyne.shared.isFeatureEnabled("new-onboarding") {
  showNewOnboarding()
}

Screens and lifecycle

Application Installed, Application Updated, Application Opened and Application Backgrounded are captured automatically. Track screens yourself as $screen events:

CheckoutView.swift
Tracklyne.shared.screen("Checkout", properties: ["items": 3])

Feature flags

Flags are fetched at setup and after identify, group and reset, then cached on disk for offline use.

Onboarding.swift
let variant = Tracklyne.shared.getFeatureFlag("onboarding-test") as? String
let payload = Tracklyne.shared.getFeatureFlagPayload("onboarding-test") as? [String: Any]
Tracklyne.shared.reloadFeatureFlags { ok in refreshUI() }

Offline, errors and logout

Events are queued on disk, survive restarts, and are sent in batches when the network is available and when the app goes to the background.

Checkout.swift
do { try checkout() } catch { Tracklyne.shared.captureException(error, properties: ["screen": "checkout"]) }

Tracklyne.shared.reset()  // on logout: new anonymous id and session
Tracklyne.shared.optOut() // or optIn()

Session replay and autocapture are browser-only for now. On iOS, call screen(_:) and capture(_:) for the steps you care about.