DevTracker

class DevTracker(var config: TrackerConfig = TrackerConfig())

Development tracker for monitoring application behavior.

Provides comprehensive tracking of page entries, view model creations, recompositions, function calls, and custom events with thread-safe operations.

References:

Constructors

Link copied to clipboard
constructor(config: TrackerConfig = TrackerConfig())

Properties

Link copied to clipboard
Link copied to clipboard
private var config: TrackerConfig

Configuration for the tracker.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard

Appends a single event to the tracking file (useful for large datasets).

Link copied to clipboard
private fun asyncSave()

Saves tracking data asynchronously in a separate thread.

Link copied to clipboard
fun clear()

Clears all tracked data and resets counters.

Link copied to clipboard

Automatically detects the calling function name from the call stack.

Link copied to clipboard
private fun exportAsCSV(): String
Link copied to clipboard
private fun exportAsJSON(): String
Link copied to clipboard
private fun exportAsText(): String
Link copied to clipboard
fun exportStatistics(format: ExportFormat = ExportFormat.TEXT): String

Exports statistics in various formats.

Link copied to clipboard

Gets all recorded events as an immutable map.

Link copied to clipboard

Gets all recorded statistics as an immutable map.

Link copied to clipboard

Gets statistics grouped by category.

Link copied to clipboard

Gets all recorded events for a specific context.

Link copied to clipboard
fun getStats(context: String): TrackingStats?

Gets statistics for a specific context.

Link copied to clipboard

Gets the total number of events tracked across all contexts.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Gets the current enabled state.

Link copied to clipboard
private fun logTrackingEvent(event: TrackingEvent)

Logs a tracking event in a structured format.

Link copied to clipboard

Prints a comprehensive summary of all tracked data.

Link copied to clipboard
private fun recordEvent(event: TrackingEvent)

Records a tracking event with improved performance and memory management.

Link copied to clipboard
fun saveToFile(format: ExportFormat = ExportFormat.TEXT): Boolean

Saves tracking data to file synchronously. Keeps signature intact. Ensures single, correct extension.

Link copied to clipboard
Link copied to clipboard
fun setEnabled(value: Boolean)

Enables or disables tracking globally.

Link copied to clipboard
fun setTrackerFilePath(autoSave: Boolean = false): String

Sets up file tracking with optional auto-save. Keeps signature intact. Generates a default .log file initially.

Link copied to clipboard
fun <T : Any> trackClassCreated(classInstance: T? = null, className: String? = null, category: Any? = null)

Tracks a class creation.

Link copied to clipboard
fun trackCustom(context: String, details: String = "", category: Any? = null)

Tracks a custom event.

Link copied to clipboard
fun <T : Any> trackEffectStart(effectInstance: T? = null, effectName: String? = null, category: Any? = null)
Link copied to clipboard
fun <T : Any> trackEffectStop(effectInstance: T? = null, effectName: String? = null, category: Any? = null)
Link copied to clipboard
fun trackFunctionCall(customName: String? = null, details: String = "", category: Any? = null)

Tracks a function call with optional details.

Link copied to clipboard
fun trackPageEnter(customName: String? = null, category: Any? = null)

Tracks a page entry with automatic caller detection.

Link copied to clipboard
fun trackRecomposition(customName: String? = null, category: Any? = null)

Tracks a recomposition with automatic caller detection.

Link copied to clipboard
fun <T : Any> trackViewModelCreated(viewModel: T? = null, className: String? = null, category: Any? = null)

Tracks a view model creation.

Link copied to clipboard
fun updateConfig(newConfig: TrackerConfig)

Updates the tracker configuration.

Link copied to clipboard
private fun withExt(path: String, ext: String): String

Returns a path with the given extension, replacing any existing one.