Skip to content

Commit ceb541b

Browse files
authored
Fix Compose widgets are not being correctly identified for user interaction tracing (getsentry#3209)
* Fix Compose widgets are not being correctly identified * Update Changelog
1 parent a537f8a commit ceb541b

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
- Add new threshold parameters to monitor config ([#3181](https://github.com/getsentry/sentry-java/pull/3181))
88
- Report process init time as a span for app start performance ([#3159](https://github.com/getsentry/sentry-java/pull/3159))
99

10+
## Fixes
11+
12+
- Fix Jetpack Compose widgets are not being correctly identified for user interaction tracing ([#3209](https://github.com/getsentry/sentry-java/pull/3209))
13+
1014
## 7.3.0
1115

1216
### Features

sentry-compose-helper/src/jvmMain/java/io/sentry/compose/gestures/ComposeGestureTargetLocator.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,18 @@ public ComposeGestureTargetLocator(final @NotNull ILogger logger) {
4848
}
4949
}
5050

51-
@Nullable String targetTag = null;
52-
5351
if (!(root instanceof Owner)) {
5452
return null;
5553
}
5654

5755
final @NotNull Queue<LayoutNode> queue = new LinkedList<>();
5856
queue.add(((Owner) root).getRoot());
5957

58+
// the final tag to return
59+
@Nullable String targetTag = null;
60+
61+
// the last known tag when iterating the node tree
62+
@Nullable String lastKnownTag = null;
6063
while (!queue.isEmpty()) {
6164
final @Nullable LayoutNode node = queue.poll();
6265
if (node == null) {
@@ -66,7 +69,6 @@ public ComposeGestureTargetLocator(final @NotNull ILogger logger) {
6669
if (node.isPlaced() && layoutNodeBoundsContain(composeHelper, node, x, y)) {
6770
boolean isClickable = false;
6871
boolean isScrollable = false;
69-
@Nullable String testTag = null;
7072

7173
final List<ModifierInfo> modifiers = node.getModifierInfo();
7274
for (ModifierInfo modifierInfo : modifiers) {
@@ -83,7 +85,7 @@ public ComposeGestureTargetLocator(final @NotNull ILogger logger) {
8385
isClickable = true;
8486
} else if ("SentryTag".equals(key) || "TestTag".equals(key)) {
8587
if (entry.getValue() instanceof String) {
86-
testTag = (String) entry.getValue();
88+
lastKnownTag = (String) entry.getValue();
8789
}
8890
}
8991
}
@@ -100,10 +102,10 @@ public ComposeGestureTargetLocator(final @NotNull ILogger logger) {
100102
}
101103

102104
if (isClickable && targetType == UiElement.Type.CLICKABLE) {
103-
targetTag = testTag;
105+
targetTag = lastKnownTag;
104106
}
105107
if (isScrollable && targetType == UiElement.Type.SCROLLABLE) {
106-
targetTag = testTag;
108+
targetTag = lastKnownTag;
107109
// skip any children for scrollable targets
108110
break;
109111
}

0 commit comments

Comments
 (0)