diff --git a/CHANGELOG.md b/CHANGELOG.md index 50319e4d8cd..bded2b64d93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ ### Fixes +- Capture scroll breadcrumbs for `LazyColumn`, `LazyRow`, lazy grids, and `Pager` on Jetpack Compose foundation 1.10+ ([#6548](https://github.com/getsentry/sentry-java/pull/6548)) - Prevent the main thread from potentially hanging during app start if Android is slow to register the SDK's network or telephony listeners. `Sentry.init`, Session Replay, and capturing events no longer wait for that registration ([#6537](https://github.com/getsentry/sentry-java/pull/6537)) - Add opt-in support for matching GraphQL ignored error types against classification specifications via `sentry.graphql.enable-specification-error-type-filtering` ([#6092](https://github.com/getsentry/sentry-java/pull/6092)) - Session Replay: Fix `SentryOkHttpInterceptor` hanging forever on responses whose body has no known length, such as Server-Sent Events or a gzipped response, when network details are enabled for the URL ([#6231](https://github.com/getsentry/sentry-java/pull/6231)) diff --git a/sentry-compose/proguard-rules.pro b/sentry-compose/proguard-rules.pro index ea5984aa88e..30473497a5f 100644 --- a/sentry-compose/proguard-rules.pro +++ b/sentry-compose/proguard-rules.pro @@ -13,6 +13,7 @@ -keepnames class androidx.compose.foundation.CombinedClickableElement -keepnames class androidx.compose.foundation.ScrollingLayoutElement -keepnames class androidx.compose.foundation.ScrollingContainerElement +-keepnames class androidx.compose.foundation.ScrollableAreaElement -keepnames class androidx.compose.ui.platform.TestTagElement { *; } -keepnames class io.sentry.compose.SentryModifier$SentryTagModifierNodeElement { *; } diff --git a/sentry-compose/src/androidMain/kotlin/io/sentry/compose/gestures/ComposeGestureTargetLocator.kt b/sentry-compose/src/androidMain/kotlin/io/sentry/compose/gestures/ComposeGestureTargetLocator.kt index 47dda6eda9c..ba011e455ab 100644 --- a/sentry-compose/src/androidMain/kotlin/io/sentry/compose/gestures/ComposeGestureTargetLocator.kt +++ b/sentry-compose/src/androidMain/kotlin/io/sentry/compose/gestures/ComposeGestureTargetLocator.kt @@ -83,9 +83,7 @@ public class ComposeGestureTargetLocator(private val logger: ILogger) : GestureT ) { targetTag = tag } else if ( - targetType == UiElement.Type.SCROLLABLE && - ("androidx.compose.foundation.ScrollingLayoutElement" == type || - "androidx.compose.foundation.ScrollingContainerElement" == type) + targetType == UiElement.Type.SCROLLABLE && type in SCROLLABLE_ELEMENT_TYPES ) { return UiElement(null, null, null, tag, ORIGIN) } @@ -130,5 +128,14 @@ public class ComposeGestureTargetLocator(private val logger: ILogger) : GestureT public companion object { private const val ORIGIN = "jetpack_compose" + + private val SCROLLABLE_ELEMENT_TYPES = + setOf( + "androidx.compose.foundation.ScrollingLayoutElement", + "androidx.compose.foundation.ScrollingContainerElement", + // Compose foundation 1.10+: lazy layouts and pagers use ScrollableAreaElement + // in place of ScrollingContainerElement + "androidx.compose.foundation.ScrollableAreaElement", + ) } } diff --git a/sentry-compose/src/androidUnitTest/kotlin/androidx/compose/foundation/GestureModifierStubs.kt b/sentry-compose/src/androidUnitTest/kotlin/androidx/compose/foundation/GestureModifierStubs.kt index 43b3e53bc67..052158c1243 100644 --- a/sentry-compose/src/androidUnitTest/kotlin/androidx/compose/foundation/GestureModifierStubs.kt +++ b/sentry-compose/src/androidUnitTest/kotlin/androidx/compose/foundation/GestureModifierStubs.kt @@ -13,3 +13,5 @@ internal open class CombinedClickableElement : Modifier.Element internal open class ScrollingLayoutElement : Modifier.Element internal open class ScrollingContainerElement : Modifier.Element + +internal open class ScrollableAreaElement : Modifier.Element diff --git a/sentry-compose/src/androidUnitTest/kotlin/io/sentry/compose/gestures/ComposeGestureTargetLocatorTest.kt b/sentry-compose/src/androidUnitTest/kotlin/io/sentry/compose/gestures/ComposeGestureTargetLocatorTest.kt index 8efdf3ebe30..407c5d2f748 100644 --- a/sentry-compose/src/androidUnitTest/kotlin/io/sentry/compose/gestures/ComposeGestureTargetLocatorTest.kt +++ b/sentry-compose/src/androidUnitTest/kotlin/io/sentry/compose/gestures/ComposeGestureTargetLocatorTest.kt @@ -217,6 +217,31 @@ class ComposeGestureTargetLocatorTest { assertEquals("scroll", result!!.tag) } + @Test + fun `detects scrollable via ScrollableAreaElement modifier`() { + val scrollableChild = + mockLayoutNode( + isPlaced = true, + tag = "scroll", + width = 50, + height = 50, + nodeModifierClassName = "androidx.compose.foundation.ScrollableAreaElement", + ) + val root = + mockLayoutNode( + isPlaced = true, + tag = null, + width = 100, + height = 100, + children = listOf(scrollableChild), + ) + val owner = mockOwner(root) + + val result = locator.locate(owner, 5f, 5f, UiElement.Type.SCROLLABLE) + assertNotNull(result) + assertEquals("scroll", result!!.tag) + } + @Test fun `ignores clickable when looking for scrollable`() { val clickableChild =