From 7e6f42a754add0c25002365e5036e78cd38a8cbc Mon Sep 17 00:00:00 2001 From: Pouria Amini <64161548+PouriaAmini@users.noreply.github.com> Date: Fri, 26 Jul 2024 18:43:33 -0400 Subject: [PATCH] fix: track touchUpInside for any element (#203) * fix: just track touchupinside and valuechanged for some elements * fix: fix tvos issue * feat: capture control events * fix: remove row selected event * fix: track any touchUpInside * fix: capture image name as a fallback for buttons title --- Sources/Amplitude/Plugins/iOS/UIKitUserInteractions.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Sources/Amplitude/Plugins/iOS/UIKitUserInteractions.swift b/Sources/Amplitude/Plugins/iOS/UIKitUserInteractions.swift index 99d0177..6e50e0c 100644 --- a/Sources/Amplitude/Plugins/iOS/UIKitUserInteractions.swift +++ b/Sources/Amplitude/Plugins/iOS/UIKitUserInteractions.swift @@ -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 {