Skip to content

Commit

Permalink
Fix user interaction tracking not working for Jetpack Compose 1.5+ (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
markushi authored Oct 24, 2023
1 parent bc4be3b commit 1ab82a3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Fix crash when HTTP connection error message contains formatting symbols ([#3002](https://github.com/getsentry/sentry-java/pull/3002))
- Cap max number of stack frames to 100 to not exceed payload size limit ([#3009](https://github.com/getsentry/sentry-java/pull/3009))
- This will ensure we report errors with a big number of frames such as `StackOverflowError`
- Fix user interaction tracking not working for Jetpack Compose 1.5+ ([#3010](https://github.com/getsentry/sentry-java/pull/3010))

## 6.32.0

Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/java/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ object Config {
val springBoot3Version = "3.0.3"
val kotlinCompatibleLanguageVersion = "1.4"

val composeVersion = "1.3.0"
val composeVersion = "1.5.3"
val androidComposeCompilerVersion = "1.4.0"

object BuildPlugins {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,15 @@ public ComposeGestureTargetLocator(final @NotNull ILogger logger) {
}
}
}
} else {
// Newer Jetpack Compose 1.5 uses Node modifiers for clicks/scrolls
final @Nullable String type = modifierInfo.getModifier().getClass().getCanonicalName();
if ("androidx.compose.foundation.ClickableElement".equals(type)
|| "androidx.compose.foundation.CombinedClickableElement".equals(type)) {
isClickable = true;
} else if ("androidx.compose.foundation.ScrollingLayoutElement".equals(type)) {
isScrollable = true;
}
}
}

Expand Down
5 changes: 5 additions & 0 deletions sentry-compose/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@
private androidx.compose.ui.node.LayoutNodeLayoutDelegate layoutDelegate;
}

-keepnames class androidx.compose.foundation.ClickableElement
-keepnames class androidx.compose.foundation.CombinedClickableElement
-keepnames class androidx.compose.foundation.ScrollingLayoutElement

# R8 will warn about missing classes if people don't have androidx.compose-navigation on their
# classpath, but this is fine, these classes are used in an internal class which is only used when
# someone is using withSentryObservableEffect extension function (which, in turn, cannot be used
# without having androidx.compose-navigation on the classpath)
-dontwarn androidx.navigation.NavController$OnDestinationChangedListener
-dontwarn androidx.navigation.NavController
-dontwarn androidx.compose.foundation.*

# To ensure that stack traces is unambiguous
# https://developer.android.com/studio/build/shrink-code#decode-stack-trace
Expand Down

0 comments on commit 1ab82a3

Please sign in to comment.