FEAT: Add version of withSentryObservableEffect that has better inter…#3411
FEAT: Add version of withSentryObservableEffect that has better inter…#3411designedbyz wants to merge 1 commit intogetsentry:mainfrom
Conversation
…op with fragment navigation
|
Question: how do I get a review for this? |
romtsn
left a comment
There was a problem hiding this comment.
hi @designedbyz sorry for the delays, the team was overloaded with other tasks.
I've taken a look at the PR and it makes a lot of sense to have this functionality in the SDK, so I'm just approving it. You'd also have to add a changelog entry to make CI green, you can take a look at the other entries to comply with the changelog format.
Ideally we'd also update Sentry docs in this section and mention how to handover the navigation listener between compose and the old view system, but we could take care of that ourselves 👍
Thanks for your contribution!
|
@designedbyz sorry for abandoning this, I've reopened #4143 as I was unable to push to this branch and update it for some reason. We'll merge it and ship in version 8.2.0. Thanks for your contribution! |
📜 Description
This PR adds a version of
NavHostController.withSentryObservableEffectthat accepts aSentryNavigationListeneras a parameter to support better navigation tracing in apps that make use of both Fragments and Compose.💡 Motivation and Context
A challenge with the existing Navigation and Compose Navigation integrations is that, in the testing I've done, they seem to clobber each other. My guess as to why is because each listener will try to register itself as the integration, meaning that you only get one. Additionally, even if the instances didn't clobber each other, navigation history will end up separated between instances, as the Compose version will only have the nav destinations for Compose, whereas the fragment version will only have the destinations for fragments. This makes it hard to put traces back together for apps that make use of both fragments and compose navigation and navigate between the two.
Thankfully, the fix is pretty simple and is implemented here. I added a new version of
withSentryObservableEffectthat accepts aSentryNavigationListeneras a parameter, which allows consumers of the SDK to pass the same version of theSentryNavigationListener towithSentryObservableEffectwhen using the compose integration as they do tonavController.addOnDestinationChangedListener` when adding the integration for fragment navigation tracing.There is one possible downside to this approach. Specifically, the trace origin will show up as
navigationfor compose navigation instead ofcompose, but I personally don't see this as an issue.💚 How did you test it?
Tested locally; and we'll likely ship an internal version of this to prod at Maven before this is merged
📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
needs a review from the Sentry team