Skip to content

Commit

Permalink
swallow errors
Browse files Browse the repository at this point in the history
  • Loading branch information
marandaneto committed Oct 30, 2024
1 parent dcaf6f4 commit 30843a3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 24 deletions.
4 changes: 4 additions & 0 deletions posthog-android/consumer-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,8 @@
-dontwarn org.conscrypt.**
-dontwarn org.bouncycastle.**
-dontwarn org.openjsse.**

# used in reflection to check if compose is available at runtime
-keepnames class androidx.compose.ui.platform.AndroidComposeView

##---------------End: proguard configuration for okhttp3 ----------
Original file line number Diff line number Diff line change
Expand Up @@ -607,39 +607,44 @@ public class PostHogReplayIntegration(
view: View,
maskableWidgets: MutableList<Rect>,
) {
val semanticsOwner =
(view as? RootForTest)?.semanticsOwner ?: run {
config.logger.log("View is not a RootForTest: $view")
return
}
val semanticsNodes = semanticsOwner.getAllSemanticsNodes(true)
try {
val semanticsOwner =
(view as? RootForTest)?.semanticsOwner ?: run {
config.logger.log("View is not a RootForTest: $view")
return
}
val semanticsNodes = semanticsOwner.getAllSemanticsNodes(true)

semanticsNodes.forEach { node ->
val hasText = node.config.contains(SemanticsProperties.Text)
val hasEditableText = node.config.contains(SemanticsProperties.EditableText)
val hasPassword = node.config.contains(SemanticsProperties.Password)
val hasImage = node.config.contains(SemanticsProperties.ContentDescription)
semanticsNodes.forEach { node ->
val hasText = node.config.contains(SemanticsProperties.Text)
val hasEditableText = node.config.contains(SemanticsProperties.EditableText)
val hasPassword = node.config.contains(SemanticsProperties.Password)
val hasImage = node.config.contains(SemanticsProperties.ContentDescription)

val hasMaskModifier = node.config.contains(PostHogReplayMask)
val isNoCapture = hasMaskModifier && node.config[PostHogReplayMask]
val hasMaskModifier = node.config.contains(PostHogReplayMask)
val isNoCapture = hasMaskModifier && node.config[PostHogReplayMask]

when {
isNoCapture -> {
maskableWidgets.add(node.boundsInWindow.toRect())
}
when {
isNoCapture -> {
maskableWidgets.add(node.boundsInWindow.toRect())
}

!hasMaskModifier -> {
when {
(hasText || hasEditableText) && (config.sessionReplayConfig.maskAllTextInputs || hasPassword) -> {
maskableWidgets.add(node.boundsInWindow.toRect())
}
!hasMaskModifier -> {
when {
(hasText || hasEditableText) && (config.sessionReplayConfig.maskAllTextInputs || hasPassword) -> {
maskableWidgets.add(node.boundsInWindow.toRect())
}

hasImage && config.sessionReplayConfig.maskAllImages -> {
maskableWidgets.add(node.boundsInWindow.toRect())
hasImage && config.sessionReplayConfig.maskAllImages -> {
maskableWidgets.add(node.boundsInWindow.toRect())
}
}
}
}
}
} catch (e: Throwable) {
// swallow possible errors due to compose versioning, etc
config.logger.log("Session Replay findMaskableComposeWidgets failed: $e")
}
}

Expand Down

0 comments on commit 30843a3

Please sign in to comment.