Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add UITextEffectsWindow type in screen ignore list #279

Merged
merged 3 commits into from
Dec 23, 2024
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Next

- fix: ignore additional keyboard windows for $screen event ([#279](https://github.com/PostHog/posthog-ios/pull/279))

## 3.17.1 - 2024-12-18

- fix: avoid masking SwiftUI Gradient views ([#275](https://github.com/PostHog/posthog-ios/pull/275))
Expand Down
1 change: 0 additions & 1 deletion PostHog/UIViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@

@objc func viewDidAppearOverride(animated: Bool) {
// ignore views from keyboard window
// these may include: UIInputWindowController, _UICursorAccessoryViewController, UICompatibilityInputViewController,UIKeyboardHiddenViewController_Autofill and others
if let window = viewIfLoaded?.window, !window.isKeyboardWindow {
captureScreenView(window)
}
Expand Down
35 changes: 34 additions & 1 deletion PostHog/Utils/UIWindow+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,42 @@
import Foundation
import UIKit

/**
Known keyboard window (private) types

## UIRemoteKeyboardWindow
This is the window that manages the actual keyboard

The following system view controllers were observed to be presented in a UIRemoteKeyboardWindow window
- UIInputWindowController
- UICompatibilityInputViewController
- UISystemInputAssistantViewController
- UIPredictionViewController
- UISystemKeyboardDockController
- TUIEmojiSearchInputViewController
- STKPrewarmingViewController
- STKStickerRemoteSearchViewController
- _UIRemoteInputViewController
- _UISceneHostingViewController
- STKEmojiAndStickerCollectionViewController

## UITextEffectsWindow
Hosts system components like the magnifying glass for text selection, predictive text suggestions, copy/paste menus, input accessory views etc.

The following system view controllers were observed to be presented in a UITextEffectsWindow window
- UIInputWindowController
- UICompatibilityInputViewController

These view controllers should not appear in a $screen event. If they do, then it means that they are presented in a UIWindow not listed below
*/
private let knownKeyboardWindowTypes: [String] = [
"UIRemoteKeyboardWindow",
"UITextEffectsWindow",
]

extension UIWindow {
var isKeyboardWindow: Bool {
String(describing: type(of: window)) == "UIRemoteKeyboardWindow"
knownKeyboardWindowTypes.contains(String(describing: type(of: self)))
}
}
#endif
Loading