Skip to content

Commit

Permalink
fix: add UITextEffectsWindow type in screen ignore list
Browse files Browse the repository at this point in the history
  • Loading branch information
ioannisj committed Dec 23, 2024
1 parent d357609 commit 299903b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
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

0 comments on commit 299903b

Please sign in to comment.