You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d6f3bdd
Browse filesBrowse the repository at this point in the historyBrowse files
docs(android): Lifecycle support for Android Nav3 integration
Update the Android Navigation page to reflect the changes in the PR stack rooted at [sentry-java #6301](getsentry/sentry-java#6301), which introduces support for Nav3 setups involving multiple NavDisplay <> SentryNavEffect pairs.
Supported vs non-supported setups are now listed explicitly.
@@ -469,12 +471,6 @@ Values returned from `BackStackEntryMapper` are **not** scrubbed by the Sentry S
469
471
470
472
</Alert>
471
473
472
-
<Alert>
473
-
474
-
Multiple, simultaneously active `SentryNavEffect` instances writing to the same [Sentry scope](https://docs.sentry.io/platforms/android/enriching-events/scopes/) are **_not_** supported. Violating this restriction can result in duplicated or interleaved data and undefined transaction behavior.
475
-
476
-
</Alert>
477
-
478
474
### Customize Nav3 Options
479
475
480
476
Use `SentryNavOptions` to disable breadcrumbs or transactions, or to limit how much of the back stack Sentry stores with captured events.
The setups below require `sentry-android-navigation3` 8.63.0 or later. Earlier versions support only one active `SentryNavEffect` per Sentry scope.
636
+
637
+
`SentryNavEffect` is compatible with most, but not all, Nav3 setups. Each effect uses the lifecycle of its nearest `LocalLifecycleOwner` to decide when it can write to Sentry's [shared scope](/platforms/android/enriching-events/scopes/), and compatibility between effects depends on how those lifecycle owners interact. Incompatible effects won't crash, but they can generate stale navigation data, produce interleaved breadcrumbs, or interfere with each other's transactions.
638
+
639
+
<Alert>
640
+
641
+
All supported setups below assume that each `SentryNavEffect` is called in the same composable as the `NavDisplay` it observes, and that the effect is called before it.
642
+
643
+
They also assume that `SentryNavEffect` is **_not_** called from content rendered by `NavDisplay`, such as a `NavEntry`, `NavEntryDecorator`, or `Scene`. `SentryNavEffect` needs the lifecycle of the Activity or Fragment hosting your `NavDisplay`, rather than the navigation-scoped lifecycle `NavDisplay` provides to its content.
644
+
645
+
</Alert>
646
+
647
+
**Supported:**
648
+
649
+
- A single-Activity app with one `NavDisplay` and `SentryNavEffect` pair.
650
+
- A multi-Activity app where each Activity has its own `NavDisplay` and `SentryNavEffect` pair.
651
+
- A multi-Fragment app where each Fragment has its own `NavDisplay` and `SentryNavEffect` pair, and the host Activity or Activities have none of their own.
652
+
- A `ViewPager2` whose pages are Fragments, each with its own `NavDisplay` and `SentryNavEffect` pair.
653
+
- An Activity or Fragment with its own `NavDisplay` and `SentryNavEffect` pair that stays visible beneath a `DialogFragment` or translucent Activity with its own pair.
654
+
655
+
**Not supported:**
656
+
657
+
- Side-by-side `NavDisplay` and `SentryNavEffect` pairs in the same Activity or Fragment.
658
+
- Nested `NavDisplay` and `SentryNavEffect` pairs in the same Activity or Fragment. If you nest `NavDisplay` instances, call `SentryNavEffect` only for the outermost one.
659
+
-`SentryNavEffect` instances in multiple Activities or Fragments that users can interact with at the same time, such as an Activity and hosted Fragments where the Activity and Fragments each have their own `NavDisplay` and `SentryNavEffect` pairs, or two Activities from the same app in [multi-resume mode](https://developer.android.com/develop/ui/views/layout/support-multi-window-mode).
660
+
-`SentryNavEffect` instances in pages or tabs that share their host's lifecycle, such as Compose `HorizontalPager` pages, `ViewPager2` pages that aren't Fragments, or tabs that are all kept in the composition. Those pages or tabs share one `LifecycleOwner`, so at most one can call `SentryNavEffect`.
661
+
637
662
### Limitations
638
663
639
664
`SentryNavEffect` treats the top entry in your back stack as the current screen. That works well for most Nav3 setups, but it means that `SentryNavEffect` does **_not_**:
640
665
641
666
- understand the concept of Nav3 [Scenes](https://developer.android.com/guide/navigation/navigation-3/scenes) or multi-pane layouts
642
-
- track multiple back stacks
643
-
- permit multiple, simultaneously active `SentryNavEffect` instances
667
+
- track multiple back stacks with one `SentryNavEffect` instance
644
668
- make special accommodations for [predictive back](https://developer.android.com/guide/navigation/custom-back/predictive-back-gesture) gestures (e.g., spans produced by predictively rendered composables may appear under the current destination's transaction)
0 commit comments