From b516cf3d93753a93ae1affb1ce850e7945ec74ea Mon Sep 17 00:00:00 2001 From: Markus Hintersteiner Date: Fri, 28 Oct 2022 10:15:49 +0200 Subject: [PATCH] Overload withSentryObservableEffect to provide compose instrumentation hook(#2320) --- CHANGELOG.md | 5 +++++ .../compose/SentryNavigationIntegration.kt | 17 ++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a66f85f332..8f9fb0d541 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## Unreleased + +### Features +- Provide hook for Jetpack Compose navigation instrumentation ([#2320](https://github.com/getsentry/sentry-java/pull/2320)) + ## 6.6.0 ### Fixes diff --git a/sentry-compose/src/androidMain/kotlin/io/sentry/compose/SentryNavigationIntegration.kt b/sentry-compose/src/androidMain/kotlin/io/sentry/compose/SentryNavigationIntegration.kt index 2403148f2b..7112e7ff77 100644 --- a/sentry-compose/src/androidMain/kotlin/io/sentry/compose/SentryNavigationIntegration.kt +++ b/sentry-compose/src/androidMain/kotlin/io/sentry/compose/SentryNavigationIntegration.kt @@ -37,7 +37,7 @@ internal class SentryLifecycleObserver( /** * A [DisposableEffect] that captures a [Breadcrumb] and starts an [ITransaction] and sends - * them to Sentry for when attached to the respective [NavHostController]. + * them to Sentry for every navigation event when being attached to the respective [NavHostController]. * * @param enableNavigationBreadcrumbs Whether the integration should capture breadcrumbs for * navigation events. @@ -73,3 +73,18 @@ public fun NavHostController.withSentryObservableEffect( } return this } + +/** + * A [DisposableEffect] that captures a [Breadcrumb] and starts an [ITransaction] and sends + * them to Sentry for every navigation event when being attached to the respective [NavHostController]. + * + * Used by the sentry android gradle plugin for Jetpack Compose instrumentation. + * + */ +@Composable +internal fun NavHostController.withSentryObservableEffect(): NavHostController { + return withSentryObservableEffect( + enableNavigationBreadcrumbs = true, + enableNavigationTracing = true + ) +}