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: track touchUpInside for any element #203

Merged
merged 8 commits into from
Jul 26, 2024
7 changes: 5 additions & 2 deletions Sources/Amplitude/Plugins/iOS/UIKitUserInteractions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,16 @@ extension UIView: ActionTrackable {
@objc func amp_shouldTrack(_ action: Selector, for target: Any?) -> Bool { false }
}

extension UIButton {
override var amp_title: String? { currentTitle }
extension UIControl {
override func amp_shouldTrack(_ action: Selector, for target: Any?) -> Bool {
actions(forTarget: target, forControlEvent: .touchUpInside)?.contains(action.description) ?? false
}
}

extension UIButton {
override var amp_title: String? { currentTitle ?? currentImage?.accessibilityIdentifier }
}

extension UISegmentedControl {
override var amp_title: String? { titleForSegment(at: selectedSegmentIndex) }
override func amp_shouldTrack(_ action: Selector, for target: Any?) -> Bool {
Expand Down
Loading