Skip to content

feat(android-nav3): [Android Nav3 2] Model navigation routes - #6130

Open
0xadam-brown wants to merge 1 commit into
feat/sentry-nav3-effect-1-modulefrom
feat/sentry-nav3-effect-2-routes
Open

0xadam-brown wants to merge 1 commit into
feat/sentry-nav3-effect-1-modulefrom
feat/sentry-nav3-effect-2-routes

Conversation

@0xadam-brown

@0xadam-brown 0xadam-brown commented Sep 18, 2026

Copy link
Copy Markdown
Member

PR Stack (Android Nav3)


📜 Description

To support Nav3 we have to map a host app's back stack to an internal representation suitable for the Sentry data we emit. This PR introduces the core logic for doing so in the form of a RouteTranslator.

Note that the RouteResolvers passed to the translators constructor are defined by the host app, and so we're careful to protect against misuse / unintended performance issues.

💡 Motivation and Context

addresses: JAVA-274

💚 How did you test it?

  • Unit tests
  • Manually via the (forthcoming) Nav3 sample app, including performance tests and macrobenchmarks

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

Build the observer layer that consumes these routes and updates Sentry state.

#skip-changelog

⚠️ Merge this PR using a merge commit (not squash). Later PRs in the stack are based on this branch.

@github-actions

github-actions Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against b0eb957

@sentry

sentry Bot commented Sep 18, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.57.0 (1) release

⚙️ sentry-android Build Distribution Settings

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 061c4c3. Configure here.

@0xadam-brown
0xadam-brown force-pushed the feat/sentry-nav3-effect-1-module branch from e5d13ee to 1b98b50 Compare September 18, 2026 11:28
@0xadam-brown
0xadam-brown force-pushed the feat/sentry-nav3-effect-2-routes branch from 7ea1f4c to dc5546c Compare September 18, 2026 11:28
Introduce the route translation layer for Navigation 3 so later stages can reason about route names and sanitized arguments in one place. At this stage the module still exposes no meaningful public API surface.
@0xadam-brown
0xadam-brown force-pushed the feat/sentry-nav3-effect-2-routes branch from dc5546c to b0eb957 Compare September 18, 2026 12:38
* Doing so prevents route names from being obfuscated while leaving per-route arguments to
* [RouteArgumentsExtractor].
*/
@ApiStatus.Experimental

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marked as experimental b/c this will be made public in a follow-on to the current PR stack. (Same below.)

@0xadam-brown 0xadam-brown added the deep-dive PR needs a thorough review of design, behavior, and edge cases label Sep 18, 2026

@runningcode runningcode left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

before I give it a deeper look or maybe we can answer these in our session later, since I'm not a compose expert, what's the threading behavior on this? are these always called from the main thread since this is UI stuff?

One more question is that I wonder if it is safe to call the logger from inside the catch clause. I know we've had situations in the past where this was unsafe due to the SO/recursion risk.
The issue is that the logger also has user callbacks in the form of BeforeSendLogCallback and is therefore unsafe in the same way that the user callbacks are.


testImplementation(libs.androidx.compose.runtime)
testImplementation(libs.google.truth)
testImplementation(libs.kotlin.test.junit)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this? or can we just use google truth?

import io.sentry.compose.navigation3.RouteTranslator.WarningState
import java.util.AbstractCollection
import kotlin.test.Test
import kotlin.test.assertEquals

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use google truth on this one ?

import androidx.compose.runtime.snapshots.Snapshot
import com.google.common.truth.Truth.assertThat
import kotlin.test.Test
import kotlin.test.assertEquals

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use truth here?

@markushi markushi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, left two minor commments.

* enforced across the whole update. Once the budget is spent, the overflowing entry and every
* older entry are dropped, while newer (already-processed) entries are preserved.
*/
internal class ArgumentSanitizer(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice approach! I'm wondering if we should indicate that the resulting maps is incomplete due to an extraction error or budget exhaustion. Could be as simple as adding a synthetic entry ~ "sentry_arguments_truncated": true

* Extractor invocations are hidden from Compose snapshot observation so they don't impact
* invalidation of the recompose scope that reads them.
*/
internal class RouteResolvers<T : Any>(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance we could unify the naming/terms a bit here? I read 'resolver', 'extractor' and 'translator' and they all sound too similar to my non-native brain 🙈 Maybe 'resolver' and 'extractor' could be merged, e.g. RouteResolvers -> RouteExtractors and keep RouteNameExtractor+ RouteArgumentsExtractor as-is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deep-dive PR needs a thorough review of design, behavior, and edge cases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants