Docs

Swift: Analytics and performance

Log events and screen views for active users, funnels and retention, and report app start, screen and network timings with the Swift SDK.

Updated Oct 26, 2026

Log events and screen views for active users, funnels and retention, and report app start, screen and network timings. Every call runs as the client's signed-in user, so your project's policies and row-level security apply. Types and members are listed in source order; each one links to its HTTP endpoint where it maps to one.

#Types and members

SovariaAnalytics

Product analytics: sovaria.analytics.track("purchase", ["amount": 20]), screen("Home"), identify(["plan": "pro"]), and setEnabled(false) when the user opts out (the server then drops their events on every device). Events are batched (every 10 s or 20 events), kept in the offline store while offline, and the signed-in user comes from the request's token on the server, never from the event.

public final class SovariaAnalytics: @unchecked Sendable

SovariaAnalytics.appVersion

A property.

public var appVersion: String?

SovariaAnalytics.platform

A property.

public var platform

SovariaAnalytics.batchSize

A property.

public var batchSize

SovariaAnalytics.flushInterval

A property.

public var flushInterval: TimeInterval

SovariaAnalytics.anonId

The device id sent as anon_id.

public var anonId: String

SovariaAnalytics.configure

Persist the queue, device id and opt-out (pass the same store as offline documents, or a FileOfflineStore).

public func configure(store: OfflineStore?, appVersion: String? = nil, platform: String? = nil) async

SovariaAnalytics.track

public func track(_ name: String, _ props: [String: Any] = [:]) -> Bool

SovariaAnalytics.screen

public func screen(_ name: String, _ props: [String: Any] = [:]) -> Bool

SovariaAnalytics.identify

public func identify(_ userProps: [String: Any]) -> Bool

SovariaAnalytics.trackExposure

One $exposure per experiment and session (remote config calls this when you read an experiment's value).

public func trackExposure(experiment: String, variant: String)

SovariaAnalytics.flush

Send what is queued now.

public func flush() async

Network errors and throttling keep the events; a refused batch is dropped.

SovariaAnalytics.setEnabled

Analytics consent for this user (DPDP / GDPR).

public func setEnabled(_ on: Bool, erase: Bool = false) async throws

Off clears the queue and tells the server; erase also deletes what was stored.

SovariaAnalytics.isEnabled

A property.

public var isEnabled: Bool

SovariaAnalytics.pending

A property.

public var pending: Int

SovariaRemoteConfig

Remote config and feature flags: setDefaults, fetchAndActivate(), bool/string/number/json(_:) and onUpdate (live after a publish when the plan has realtime config). Only this user's evaluated values come back (never the rules); unchanged config costs a 304; activated values persist for offline starts.

public final class SovariaRemoteConfig: @unchecked Sendable

SovariaRemoteConfig.minimumFetchInterval

A property.

public var minimumFetchInterval: TimeInterval

SovariaRemoteConfig.attributes

A property.

public var attributes: [String: Any]

SovariaRemoteConfig.appVersion

A property.

public var appVersion: String?

SovariaRemoteConfig.platform

A property.

public var platform

SovariaRemoteConfig.language

A property.

public var language: String?

SovariaRemoteConfig.setDefaults

public func setDefaults(_ values: [String: Any])

SovariaRemoteConfig.configure

Restore the last activated values (call early with a durable store).

public func configure(store: OfflineStore?) async

SovariaRemoteConfig.fetchAndActivate

Fetch (respecting minimumFetchInterval unless force) and activate.

public func fetchAndActivate(force: Bool = false) async -> Bool

True when values changed.

SovariaRemoteConfig.onUpdate

Called with the changed keys whenever new values are activated.

public func onUpdate(_ cb: @escaping @Sendable ([String]) -> Void) -> UUID

Returns a token for removeUpdateListener.

SovariaRemoteConfig.removeUpdateListener

public func removeUpdateListener(_ id: UUID)

SovariaRemoteConfig.bool

public func bool(_ key: String, default fallback: Bool = false) -> Bool

SovariaRemoteConfig.string

public func string(_ key: String, default fallback: String = "") -> String

SovariaRemoteConfig.number

public func number(_ key: String, default fallback: Double = 0) -> Double

SovariaRemoteConfig.json

public func json(_ key: String) -> Any?

SovariaRemoteConfig.version

A property.

public var version: Int

SovariaPerf

Client performance monitoring (Observability › Performance in the console): - App start — cold start from process launch to the first time the app becomes active (iOS, automatic), or to your own markAppReady() call. - Screens — let t = sov.perf.screen("Checkout") … t.end() (or the SwiftUI .sovariaScreen("Checkout") modifier): time on screen. - Network — every request the SDK makes (method, route, status, duration), with the traceparent it sent, so a slow call opens the server trace for the same request. - Custom traces — try await sov.perf.trace("sync") { … }. Measurements are batched every 10 s (at most 100 per request) and count against obs.perf_events_month.

public final class SovariaPerf: @unchecked Sendable

SovariaPerf.install

public func install(release: String? = nil, environment: String? = nil, sampleRate: Double = 1, network: Bool = true,
                    appStart: Bool = true)

SovariaPerf.uninstall

public func uninstall()

SovariaPerf.markAppReady

The app is ready (first screen drawn): records the cold start once per launch.

public func markAppReady()

SovariaPerf.screen

Start timing a screen; call end() when it goes away.

public func screen(_ name: String) -> PerfTrace

SovariaPerf.trace

Time an async block as a custom trace (also when it throws).

public func trace<T>(_ name: String, attributes: [String: Any] = [:], _ body: () async throws -> T) async rethrows -> T

SovariaPerf.record

Queue one measurement.

public func record(kind: String, name: String, value: Double, route: String? = nil, traceId: String? = nil,
                   attributes: [String: Any] = [:]) -> Bool

Returns false when not installed or not sampled.

SovariaPerf.flush

Send queued measurements now.

public func flush() async

PerfTrace

A running screen or custom trace; end() records it once.

public final class PerfTrace: @unchecked Sendable

PerfTrace.end

public func end()