Skip to content

Commit

Permalink
recording: react native has window attached but needs view ready call…
Browse files Browse the repository at this point in the history
…back
  • Loading branch information
marandaneto committed Sep 17, 2024
1 parent 546f46e commit d5a2b59
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Next

- no user facing changes

## 3.7.2 - 2024-09-17

- no user facing changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,17 @@ public class PostHogReplayIntegration(

private fun addView(
view: View,
added: Boolean,
added: Boolean = true,
) {
try {
if (added) {
view.phoneWindow?.let { window ->
if (view.windowAttachCount == 0) {
view.phoneWindow?.let { window ->
var hasDecorView = false

window.peekDecorView()?.let { decorView ->
hasDecorView = decorViews[decorView] != null
}
if (added) {
if (view.windowAttachCount == 0 || !hasDecorView) {
window.onDecorViewReady { decorView ->
try {
val listener =
Expand Down Expand Up @@ -158,10 +163,10 @@ public class PostHogReplayIntegration(
window.touchEventInterceptors += onTouchEventListener
// TODO: can check if user pressed hardware back button (KEYCODE_BACK)
// window.keyEventInterceptors
} else {
config.logger.log("Session Replay already has onDecorViewReady.")
}
}
} else {
view.phoneWindow?.let { window ->
} else {
window.peekDecorView()?.let { decorView ->
decorViews[decorView]?.let { status ->
cleanSessionState(decorView, status)
Expand Down Expand Up @@ -299,15 +304,7 @@ public class PostHogReplayIntegration(
// workaround for react native that is started after the window is added
// Curtains.rootViews should be empty for normal apps yet
Curtains.rootViews.forEach { view ->
view.phoneWindow?.let { window ->
window.peekDecorView()?.let { decorView ->
val hasDecorView = decorViews[decorView] != null

if (!hasDecorView) {
addView(view, true)
}
}
}
addView(view)
}

try {
Expand Down

0 comments on commit d5a2b59

Please sign in to comment.