Skip to content

feat(android-nav3): [Android Nav3 3] Track navigation state transitions - #6131

Open
0xadam-brown wants to merge 4 commits into
feat/sentry-nav3-effect-2-routesfrom
feat/sentry-nav3-effect-3-observer
Open

0xadam-brown wants to merge 4 commits into
feat/sentry-nav3-effect-2-routesfrom
feat/sentry-nav3-effect-3-observer

Conversation

@0xadam-brown

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

Copy link
Copy Markdown
Member

PR Stack (Android Nav3)


📜 Description

Now we wire up the logic for consuming the host app's back stack and emitting finished Sentry data. The class responsible for doing so is BackStackObserver.

It rotates the ambient nav transaction and emits the following Sentry data every time the top of the back stack is updated:

  • breadcrumbs
  • screen names
  • a projection of the host app back stack containing the most recent SentryNavOptions.maxCapturedBackStackEntries

BackStackObsever makes use of the RouteTranslator from #6130 for the actual back stack entry -> raw Sentry data translation.

💡 Motivation and Context

With route modeling in place, the next boundary is the state machine that reacts to navigation changes. Keeping that behavior separate makes it easier to review lifecycle and tracing semantics without mixing in Compose effect concerns yet.

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

Introduce the Compose-facing effect that owns this observer in application code.

#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 56bd4d4

@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.

Stale Bugbot comment from a previous run.

@0xadam-brown
0xadam-brown force-pushed the feat/sentry-nav3-effect-3-observer branch from 729cbc7 to a0704f7 Compare September 18, 2026 11:00

@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.

Stale Bugbot comment from a previous run.

@0xadam-brown
0xadam-brown force-pushed the feat/sentry-nav3-effect-2-routes branch from 7ea1f4c to dc5546c Compare September 18, 2026 11:28
@0xadam-brown
0xadam-brown force-pushed the feat/sentry-nav3-effect-3-observer branch from a0704f7 to 6a2c118 Compare September 18, 2026 11:28

@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.

There are 4 total unresolved issues (including 3 from previous reviews).

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 6a2c118. Configure here.

@0xadam-brown
0xadam-brown force-pushed the feat/sentry-nav3-effect-2-routes branch from dc5546c to b0eb957 Compare September 18, 2026 12:38
Add the observer layer that turns Navigation 3 back stack changes into breadcrumbs, scope state, and navigation transactions. This is also the point where the module starts carrying generated BuildConfig version metadata and its first non-empty API snapshot.
@0xadam-brown
0xadam-brown force-pushed the feat/sentry-nav3-effect-3-observer branch from 9e615c3 to 7e1db9e Compare September 18, 2026 12:38
*/
@ApiStatus.Experimental
@Immutable
internal class SentryNavOptions

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

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).

Keep the hint internal for the current stack, but mark it experimental ahead of the follow-on public surface work. Also rename the key and field to match the Android hint naming pattern.
public static final String ANDROID_NAV_DESTINATION = "android:navigationDestination";

/** Used for Navigation 3 breadcrumbs. */
@ApiStatus.Experimental @ApiStatus.Internal

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.

⚠️ Note that Nav3 currently only supports hints for breadcrumbs. The only other candidate is transactions, but I've refrained because Nav2 transactions lack them. Chime in if you think we should reconsider.

@0xadam-brown 0xadam-brown added the deep-dive PR needs a thorough review of design, behavior, and edge cases label Sep 18, 2026
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.

1 participant