Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import io.sentry.android.core.internal.gestures.ViewUtils;
import io.sentry.protocol.ViewHierarchy;
import io.sentry.protocol.ViewHierarchyNode;
import io.sentry.util.HintUtils;
import io.sentry.util.JsonSerializationUtils;
import io.sentry.util.Objects;
import java.util.ArrayList;
Expand Down Expand Up @@ -43,6 +44,10 @@ public ViewHierarchyEventProcessor(final @NotNull SentryAndroidOptions options)
return event;
}

if (HintUtils.isFromHybridSdk(hint)) {
return event;
}

final @Nullable Activity activity = CurrentActivityHolder.getInstance().getActivity();
final @Nullable ViewHierarchy viewHierarchy =
snapshotViewHierarchy(activity, options.getLogger());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import io.sentry.Hint
import io.sentry.JsonSerializable
import io.sentry.JsonSerializer
import io.sentry.SentryEvent
import io.sentry.TypeCheckHint
import io.sentry.protocol.SentryException
import org.junit.runner.RunWith
import org.mockito.invocation.InvocationOnMock
Expand Down Expand Up @@ -64,10 +65,10 @@ class ViewHierarchyEventProcessorTest {

fun process(
attachViewHierarchy: Boolean,
event: SentryEvent
event: SentryEvent,
hint: Hint = Hint()
): Pair<SentryEvent, Hint> {
val processor = getSut(attachViewHierarchy)
val hint = Hint()
processor.process(event, hint)

return Pair(event, hint)
Expand Down Expand Up @@ -104,6 +105,22 @@ class ViewHierarchyEventProcessorTest {
assertNull(viewHierarchy)
}

@Test
fun `when an event errored, the view hierarchy should not attached if the event is from hybrid sdk`() {
val hintFromHybridSdk = Hint()
hintFromHybridSdk.set(TypeCheckHint.SENTRY_IS_FROM_HYBRID_SDK, true)
val (event, hint) = fixture.process(
true,
SentryEvent().apply {
exceptions = listOf(SentryException())
},
hintFromHybridSdk
)

assertNotNull(event)
assertNull(hint.viewHierarchy)
}

@Test
fun `when an event errored, the view hierarchy should not attached if the feature is disabled`() {
val (event, hint) = fixture.process(
Expand Down