How We Built User Interaction Tracking For Jetpack Compose
Article Summary
Markus Hintersteiner from Sentry reveals how they cracked a tricky problem: tracking user interactions in Jetpack Compose without cluttering developers' code or killing performance.
The Sentry team built automatic user interaction tracking for Jetpack Compose as part of their open-source Android SDK. This deep dive shows how they navigated Compose's internal APIs, avoided accessibility overhead, and delivered a feature that works out-of-the-box with minimal setup.
Key Takeaways
- Used Window.Callback to intercept all touch events globally without code changes
- Avoided accessibility APIs due to 100ms sync overhead and performance concerns
- Accessed internal Compose APIs via Java to bypass Kotlin compiler restrictions
- Leveraged existing Modifier.testTag for UI element identification in release builds
Sentry shipped automatic Compose interaction tracking in SDK 6.10.0 by cleverly combining Window callbacks, LayoutNode traversal, and semantic modifiers without requiring reflection or accessibility services.
About This Article
Sentry couldn't identify which specific UI element users interacted with in Jetpack Compose. Unlike traditional Android Views, Compose renders everything through a single AndroidComposeView, so there are no individual widget IDs to retrieve.
The team iterated through LayoutNode modifiers to extract existing Modifier.testTag values. These tags are already used in UI testing and provide readable identifiers without needing reflection or accessibility service overhead.
The feature shipped in Android SDK 6.10.0 as an opt-in capability that only requires AndroidManifest.xml configuration. Developers get automatic breadcrumb generation for user interactions without writing custom Sentry instrumentation code.