Skip to content

Analytics Tracking Example

Monitoring analytics events with the Analytics module.

[Placeholder: Insert screenshot of Analytics UI showing tracked events. Use a device frame if relevant.]

Step 1: Log Analytics Events

// Screen view
AnalyticsLogger.log(
    AnalyticsLog(
        tag = "HomeScreen",
        screenClass = "com.app.HomeScreen",
        timestamp = System.currentTimeMillis(),
        type = AnalyticsLogType.SCREEN
    )
)
// User event
AnalyticsLogger.log(
    AnalyticsLog(
        tag = "button_click",
        screenClass = "HomeScreen",
        timestamp = System.currentTimeMillis(),
        type = AnalyticsLogType.EVENT
    )
)

Step 2: Register Analytics Module

val modules = rememberModules {
    module(Analytics)
    // ...other modules...
}

Step 3: Use AnalyticsScreen in Your Composable

@Composable
fun MyApp() {
    CompositionLocalProvider(LocalAnalytics provides AnalyticsLogger.logs) {
        AnalyticsScreen()
    }
}

Step 4: Test Analytics Tracking

  • Open DevView and navigate to the Analytics module
  • Trigger events in your app and observe them in real time
  • Use filtering and search to inspect specific events

Troubleshooting

  • If events do not appear, check that you are using AnalyticsLogger.log() correctly
  • For UI issues, verify Compose state and log updates
  • For platform-specific issues, check Compose Multiplatform compatibility

Next Steps


If you encounter issues not covered here, consult the Troubleshooting & FAQ or open an issue on the DevView repository.