LoggedScreenViewModel

abstract class LoggedScreenViewModel<S, E : Any>(initialState: S, telemetryRepository: TelemetryRepository, screenName: String, viewModelName: String = screenName) : ScreenViewModel<S, E> (source)

A ScreenViewModel that reports to Firebase: a breadcrumb when it is created and for every event, and for each operation a start breadcrumb and vm_op_start event, and on failure an error breadcrumb, a vm_op_error event and a Crashlytics report.

The messages, keys and events are fixed: dashboards and Crashlytics filters read them.

Parameters

screenName

The name reported as the screen key and parameter.

viewModelName

The name reported as the breadcrumb viewModel key and the GA4 view_model parameter. It is passed in rather than read from the class because R8 renames classes in release builds, which would make those values unreadable. Defaults to screenName.

Constructors

Link copied to clipboard
constructor(initialState: S, telemetryRepository: TelemetryRepository, screenName: String, viewModelName: String = screenName)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
val messages: StateFlow<ImmutableList<UiMessage>>

Messages waiting to be shown, oldest first.

Link copied to clipboard
val state: StateFlow<S>

Functions

Link copied to clipboard
open fun addCloseable(closeable: AutoCloseable)
fun addCloseable(key: String, closeable: AutoCloseable)
Link copied to clipboard
Link copied to clipboard

Removes the message with id from the queue, once it has been shown.

Link copied to clipboard
fun onEvent(event: E)