API reference
StatsClient is an actor; every method below is awaited. Value types are Sendable across every boundary.
StatsClient(configuration:)Constructs the client. Performs no disk I/O, so it is safe on the main actor during launch.track(_ name: String, props:)Captures an event. Returns once it is on disk, so a kill does not lose it. Names are snake_case; props are flat and carry no user text.identify(userID:)Opt-in and hashed with your salt before it leaves the device. Most apps should never call it.setConsent(_:)Sets the three consent groups. Revoking discards the queue and deletes the stored install UUID.setEnabled(_:)The master opt-out you ship for a person. Persists; keeps the install UUID unused rather than deleting it.flush()Sends what is queued now, instead of waiting for the count or interval trigger.reset()Flushes, then regenerates the install id, resets seq to 0 and starts a new session.applicationDidBecomeActive()Starts or continues a session and emits app_open. Call it from scenePhase.applicationDidEnterBackground()Emits app_background and flushes. Call it from scenePhase.StatsQuery.summary(projectId:from:to:)Reads your own numbers back with a read key. Never embed a read key in a shipped app.Consent groups
Three independent groups, persisted: usage, diagnostics, identity. The default is [.usage, .diagnostics]. Identity is never in the default, because a stable install id changes what your app must disclose. Pass .none and nothing is collected at all — no queue file, no id, no context.