Skip to main content
The Swift SDK tracks events and structured logs from your Apple apps. It’s a client SDK — you configure a singleton once at launch, and it handles device IDs, sessions, and delivery automatically. Events called before initialization completes are queued and replayed. Your app never blocks on network I/O.

Installation

Add the package in Xcode: File > Add Package Dependencies and enter:
Or in your Package.swift:
Requires iOS 16.0+, macOS 13.0+, or visionOS 1.0+, with Swift 6.0+ and Xcode 16.0+.

Quick start

That’s it. The SDK generates a device ID, starts a session, collects device context, and batches events over TCP. Events fired before configure completes are queued (up to 1,000) and sent once ready.

Configuration

Use a preset for one-line setup, or pass individual parameters.
For fire-and-forget initialization (returns immediately, connects in the background):
For async initialization with error handling:
The API key must be a 32-character hex string.

Tracking events

No user ID needed — the SDK tracks the current user automatically (anonymous until you call identify).

Standard event names

The SDK provides strongly typed constants for common events:
Constants cover user lifecycle, revenue, subscriptions, trials, shopping, engagement, communication, and session events. Custom string names always work too.

Revenue

Track purchases with typed currency codes:
The SDK includes constants for 60+ currencies (.usd, .eur, .gbp, .jpy, .btc, etc.) and accepts custom currency strings via Currency("XYZ").

User identity

Super properties

Register properties that get merged into every track, group, and revenue call:
Event-specific properties override super properties when keys conflict.

Structured logging

Send logs alongside events through the same pipeline:
The service parameter defaults to "app". Convenience methods are available for all nine RFC 5424 levels: logEmergency, logAlert, logCritical, logError, logWarning, logNotice, logInfo, logDebug, and logTrace.

Sessions

Sessions are managed automatically. The SDK:
  1. Generates a persistent device ID (stored in UserDefaults)
  2. Creates a new session on launch with a device context snapshot
  3. Tracks app background/foreground transitions
  4. Starts a new session if the app was backgrounded longer than sessionTimeout (default: 30 minutes)
Device context collected automatically includes device model, OS version, app version, screen dimensions, locale, timezone, and battery state (iOS).

Privacy

Opt-out state is persisted across sessions. For privacy-first apps, set defaultOptOut: true during configuration so new users start opted out. When opted out, all tracking and logging calls silently drop. flush() and close() still work.

Lifecycle

Call reset() on logout to start a fresh anonymous session for the next user.

Advanced

Configuration reference

Validation rules

Pre-initialization queue

Events called before configure completes are buffered (up to 1,000 items). On overflow, the oldest event is dropped. Once initialization succeeds, all queued events are replayed in order.