Tracker

interface Tracker

The main entry point for recording analytics events.

Obtain an instance via the Autograph builder function and provide it to your UI (e.g. through AutographProvider from the autograph-compose module).

track, screen, and identify are fire-and-forget and safe to call from any thread, including the main thread: stamping and its disk persistence run on an internal serial dispatcher, so they never block the caller. Events are still stamped in call order.

Functions

Link copied to clipboard
open fun close()

Drains, then releases the resources held by this tracker (its internal stamping/delivery coroutine scope). Call when a tracker is being discarded and replaced, such as recreating it on logout — not needed for a tracker that lives for the app's lifetime.

Link copied to clipboard
open fun flush()

Asks the underlying transport to send any queued events now.

Link copied to clipboard
abstract fun identify(userId: String, traits: JsonObject = EmptyJsonObject)

Associates the current user with userId and optional traits.

Link copied to clipboard
open fun notifyBackground()

Signals that the app moved to the background. See notifyForeground.

Link copied to clipboard
open fun notifyForeground()

Signals that the app moved to the foreground. Drives session-timeout bookkeeping. Wired automatically when using AutographProvider from autograph-compose.

Link copied to clipboard
open fun reset()

Clears user identity and session state, e.g. on logout.

Link copied to clipboard
abstract fun screen(name: String, properties: JsonObject = EmptyJsonObject)

Records a screen view.

Link copied to clipboard
abstract fun track(name: String, properties: JsonObject = EmptyJsonObject, target: String? = null)

Records a custom event with the given name and properties.