feat(demo-app): use compose-navigation instrumentation for screen tracking - #1979
Conversation
…cking Replaces the hand-written InstrumentedAstronomyShopNavController wrapper with rememberObservedNavController from the compose-navigation instrumentation. The wrapper only emitted events at the call sites it explicitly wrapped, so bottom navigation bar taps, back/up presses, and deep links produced no telemetry. Observing destination changes covers all of them. Adds an astronomyShopScreenName mapping to demonstrate the screenName override: destinations resolve to display names (Product List, Cart, Checkout Info) rather than raw route patterns, and product details reads the product id out of the destination arguments so the screen name identifies which product was viewed.
There was a problem hiding this comment.
Pull request overview
Updates the demo app’s astronomy shop navigation to use the compose-navigation instrumentation (from #1964) for destination-based screen tracking, replacing the bespoke InstrumentedAstronomyShopNavController wrapper so all navigation paths (bottom nav, back/up, deep links) are observed consistently.
Tier: 2 (small internal/demo app change)
Changes:
- Use
rememberObservedNavControllerto auto-emitapp.navigation.completeon destination changes, with a customastronomyShopScreenNamemapping. - Remove the bespoke instrumented NavController wrapper and update call sites to use
AstronomyShopNavControllerdirectly. - Add demo-app build substitution + dependency for
compose-navigation, and update the demo-app README to document the new behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| demo-app/src/main/java/io/opentelemetry/android/demo/shop/ui/Navigation.kt | Switches to rememberObservedNavController, removes the wrapper, and adds a destination→screen-name mapper. |
| demo-app/src/main/java/io/opentelemetry/android/demo/shop/ui/AstronomyShopActivity.kt | Updates the order-placement helper to accept the non-instrumented nav controller type. |
| demo-app/settings.gradle.kts | Adds composite-build substitution for compose-navigation to use the local module during demo-app builds. |
| demo-app/README.md | Documents the compose-navigation instrumentation and removes the stale manual navigation-event reference. |
| demo-app/build.gradle.kts | Adds the compose-navigation instrumentation dependency. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1979 +/- ##
=======================================
Coverage 65.67% 65.67%
=======================================
Files 172 172
Lines 3918 3918
Branches 442 442
=======================================
Hits 2573 2573
Misses 1213 1213
Partials 132 132 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
breedx-splk
left a comment
There was a problem hiding this comment.
This is awesome, thanks!!
Description
Switches the demo app's astronomy shop to the
compose-navigationinstrumentation added in #1964, replacing the bespoke
InstrumentedAstronomyShopNavControllerwrapper.The old wrapper emitted a custom event from each navigation helper it
wrapped (
navigate.to.product.details,navigate.to.checkout.info,navigate.to.checkout.confirmation). Navigation that didn't go throughthose helpers — bottom navigation bar taps, back/up presses, deep links —
was invisible.
rememberObservedNavControllerobserves destinationchanges instead, so every completed navigation emits
app.navigation.completewithapp.navigation.destination.name.Also serves as the demo-app example of the
screenNameoverride:astronomyShopScreenNamemaps route patterns to human-readable namesinstead of the default route pattern, and pulls the product id out of the
destination arguments for product details
(
Product Details: OLJCESPC7Z).Changes
compose-navigationinstrumentation dependency and itscomposite-build substitution.
InstrumentedAstronomyShopNavController; call sites now useAstronomyShopNavControllerdirectly.astronomyShopScreenNameto map destinations to display names.stale reference to Navigation.kt under Manual Instrumentation.
Testing
Ran the demo app against the local collector and confirmed

app.navigation.completeevents appear with the expectedapp.navigation.destination.namefor each screen, including bottomnav taps and back presses.