SessionCapture
Captures session data for crash reports and manual export.
Events are stored in file-backed JSONL storage (when filesystem is available) to avoid holding large state snapshots in memory. Falls back to in-memory storage on platforms without filesystem access (e.g., wasmJs browser).
Usage:
val capture = SessionCapture(maxActions = 500, maxLogicEvents = 1000)
capture.start("client-id", "MyApp", "Android")
// Capture events as they happen (typically called by middleware/observers)
capture.captureAction(actionEvent)
capture.captureLogicStarted(logicEvent)
// Manual export (no crash)
val json = capture.exportSession()
// Export with crash info
val crashJson = capture.exportCrashSession(exception)The exported JSON format is compatible with DevTools ghost device import.
Parameters
Maximum number of actions to retain (older actions are dropped)
Maximum number of logic events to retain (older events are dropped)
Functions
Captures an action dispatched event.
Captures crash information from a logic method failure. This should be called when a logic failure represents a fatal crash.
Captures crash information from a throwable. This is typically called by the crash handler for uncaught exceptions.
Captures the initial full state snapshot at session start.
Captures a logic method completed event.
Captures a logic method failed event.
Captures a logic method started event.
Exports the current session with crash information as a JSON string. Captures the crash from the throwable before exporting.
Exports the current session as a JSON string. Automatically includes any captured crash information.
Exports the current session as a JSON string, including crash info from parameters. This is kept for DevTools compatibility where crash info is created externally.
Gets the captured crash info if any.
Gets the client ID for this session.
Gets the captured initial state JSON.
Gets the current session history.