Skip to content

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

Merged
0xadam-brown merged 13 commits into
feat/sentry-nav3-effect-stackfrom
feat/sentry-nav3-effect-3-observer
Sep 25, 2026
Merged

0xadam-brown merged 13 commits into
feat/sentry-nav3-effect-stackfrom
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 9cf6d1a

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

Stale Bugbot comment from a previous run.

@0xadam-brown
0xadam-brown force-pushed the feat/sentry-nav3-effect-2-routes branch from dc5546c to b0eb957 Compare September 18, 2026 12:38
@0xadam-brown
0xadam-brown force-pushed the feat/sentry-nav3-effect-3-observer branch from 9e615c3 to 7e1db9e Compare September 18, 2026 12:38
Comment thread sentry/src/main/java/io/sentry/TypeCheckHint.java
@0xadam-brown 0xadam-brown added the deep-dive PR needs a thorough review of design, behavior, and edge cases label Sep 18, 2026
@0xadam-brown
0xadam-brown force-pushed the feat/sentry-nav3-effect-3-observer branch from 56bd4d4 to fee0b6c Compare September 24, 2026 08:10
@0xadam-brown
0xadam-brown force-pushed the feat/sentry-nav3-effect-2-routes branch from b0eb957 to 4038ff4 Compare September 24, 2026 08:10

@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 4038ff4 to 01c0ad0 Compare September 24, 2026 08:18
@0xadam-brown
0xadam-brown force-pushed the feat/sentry-nav3-effect-3-observer branch from fee0b6c to acf57d4 Compare September 24, 2026 08:18
Base automatically changed from feat/sentry-nav3-effect-2-routes to feat/sentry-nav3-effect-stack September 24, 2026 16:24
@0xadam-brown
0xadam-brown force-pushed the feat/sentry-nav3-effect-3-observer branch from acf57d4 to b0cf97d Compare September 24, 2026 16:33

@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 and others added 10 commits September 25, 2026 12:07
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.
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.
Remove BackStackObserver's broad top-level try/catch around navigation updates and cleanup.

Keep broad catching at the actual host-callback boundaries in RouteTranslator, where route extractors and later value sanitization can execute arbitrary application code. Those are the places where graceful degradation is justified.

Do not keep a second observer-wide catch above that layer. It mostly hides SDK bugs in BackStackObserver itself, and configureScope already catches exceptions thrown from the scope-mutation callback. Dropping the extra wrapper leaves host callback failures isolated where they occur while making internal observer failures easier to surface during testing and dogfooding.

Co-Authored-By: OpenAI GPT-5.4 <noreply@openai.com>
Move scope and transaction navigation-context updates out of BackStackObserver into a dedicated private helper.

Keep the behavior unchanged while separating the route-to-context binding concern from the observer's change-detection and transaction lifecycle logic. This reduces the observer's surface area and makes the remaining TooManyFunctions pressure easier to address with smaller follow-up extractions.

Co-Authored-By: OpenAI GPT-5.4 <noreply@openai.com>
Rename the local BackStackObserver collaborators to a consistent Nav* pattern.

These types exist only to simplify the observer's implementation rather than to model stable domain abstractions. Using a shared helper-oriented naming scheme makes that status clearer and keeps the file's private implementation pieces on the same footing.

Co-Authored-By: OpenAI GPT-5.4 <noreply@openai.com>
@0xadam-brown
0xadam-brown force-pushed the feat/sentry-nav3-effect-3-observer branch from 28691f0 to 76a9013 Compare September 25, 2026 10:07

@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 76a9013. Configure here.

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

just dropping a quick comment, will review the rest later.

Comment thread sentry-android-navigation3/api/sentry-android-navigation3.api
0xadam-brown and others added 2 commits September 25, 2026 14:20
Treat no-op transactions from scopes.startTransaction as 'not started' in BackStackObserver.

This prevents ignored or incompatible nav transactions from being bound to the default scope, which could otherwise leave a finished no-op transaction attached and block later real transactions until the next top-of-stack change.

Add a regression test proving the observer leaves scope.transaction unset when startTransaction returns NoOpTransaction.

Co-Authored-By: OpenAI GPT-5.4 <noreply@openai.com>

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

LGTM. left some comments!

Comment thread sentry-android-navigation3/build.gradle.kts Outdated
Comment thread sentry-android-navigation3/api/sentry-android-navigation3.api
@0xadam-brown
0xadam-brown merged commit d825db7 into feat/sentry-nav3-effect-stack Sep 25, 2026
71 of 77 checks passed
@0xadam-brown
0xadam-brown deleted the feat/sentry-nav3-effect-3-observer branch September 25, 2026 15:42
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.

2 participants