Sentry Markus Hintersteiner Apr 21, 2023

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

Critical Insight

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.

The team's workaround for mixing Java into a Kotlin Multiplatform module involves a surprising build system quirk that most developers don't know about.

About This Article

Problem

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.

Solution

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.

Impact

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.