Skip to content

Commit

Permalink
fix: track touchUpInside for any element (#203)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
PouriaAmini authored Jul 26, 2024
1 parent 6564e33 commit 7e6f42a
Showing 1 changed file with 5 additions and 2 deletions.
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

0 comments on commit 7e6f42a

Please sign in to comment.