Skip to content

Commit

Permalink
Fix Compose widgets are not being correctly identified for user inter…
Browse files Browse the repository at this point in the history
…action tracing (#3209)

* Fix Compose widgets are not being correctly identified

* Update Changelog
  • Loading branch information
markushi committed Feb 16, 2024
1 parent a537f8a commit ceb541b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
- Add new threshold parameters to monitor config ([#3181](https://github.com/getsentry/sentry-java/pull/3181))
- Report process init time as a span for app start performance ([#3159](https://github.com/getsentry/sentry-java/pull/3159))

## Fixes

- Fix Jetpack Compose widgets are not being correctly identified for user interaction tracing ([#3209](https://github.com/getsentry/sentry-java/pull/3209))

## 7.3.0

### Features
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,18 @@ public ComposeGestureTargetLocator(final @NotNull ILogger logger) {
}
}

@Nullable String targetTag = null;

if (!(root instanceof Owner)) {
return null;
}

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

// the final tag to return
@Nullable String targetTag = null;

// the last known tag when iterating the node tree
@Nullable String lastKnownTag = null;
while (!queue.isEmpty()) {
final @Nullable LayoutNode node = queue.poll();
if (node == null) {
Expand All @@ -66,7 +69,6 @@ public ComposeGestureTargetLocator(final @NotNull ILogger logger) {
if (node.isPlaced() && layoutNodeBoundsContain(composeHelper, node, x, y)) {
boolean isClickable = false;
boolean isScrollable = false;
@Nullable String testTag = null;

final List<ModifierInfo> modifiers = node.getModifierInfo();
for (ModifierInfo modifierInfo : modifiers) {
Expand All @@ -83,7 +85,7 @@ public ComposeGestureTargetLocator(final @NotNull ILogger logger) {
isClickable = true;
} else if ("SentryTag".equals(key) || "TestTag".equals(key)) {
if (entry.getValue() instanceof String) {
testTag = (String) entry.getValue();
lastKnownTag = (String) entry.getValue();
}
}
}
Expand All @@ -100,10 +102,10 @@ public ComposeGestureTargetLocator(final @NotNull ILogger logger) {
}

if (isClickable && targetType == UiElement.Type.CLICKABLE) {
targetTag = testTag;
targetTag = lastKnownTag;
}
if (isScrollable && targetType == UiElement.Type.SCROLLABLE) {
targetTag = testTag;
targetTag = lastKnownTag;
// skip any children for scrollable targets
break;
}
Expand Down

0 comments on commit ceb541b

Please sign in to comment.