AnalyticsLogger

In-memory analytics recorder with observable, read-only history.

Each log call records a distinct occurrence and snapshots its parameters. History belongs to this logger; consumers cannot insert or remove records through logs. Read logs inside composition to observe updates, rather than remembering a returned snapshot.

See also

Samples

AnalyticsLogger.log(
    AnalyticsLog(
        tag = "HomeScreen",
        screenClass = "com.example.ui.HomeScreen",
        timestamp = Clock.System.now().toEpochMilliseconds(),
        type = AnalyticsLogCategory.Screen.View
    )
)

Properties

Link copied to clipboard

Whether the history currently contains at least one event.

Link copied to clipboard

Immutable history snapshot in recording order. Previously returned snapshots never change. Read the property again to obtain new events; reading in composition observes changes.

Functions

Link copied to clipboard
fun log(log: AnalyticsLog)

Records log with a fresh internal occurrence ID and an immutable copy of its parameters. Snapshot-state storage supports calls from different threads and notifies observing UI.