feat: UI event transactions for clicks#1784
Conversation
Add a wrapper around swizzling sendAction:to:from:forEvent: for testability and to only swizzle once when multiple implementations need to be called for the same swizzled method.
…entry-cocoa into feat/ui-transactions
|
…entry-cocoa into feat/ui-transactions
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1784 +/- ##
==========================================
+ Coverage 91.74% 92.30% +0.56%
==========================================
Files 198 200 +2
Lines 9159 9388 +229
==========================================
+ Hits 8403 8666 +263
+ Misses 756 722 -34
... and 8 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
Creates transactions when a control sends an action to the application, like button clicks and switch toggles. Co-authored-by: Philipp Hofmann <philipp.hofmann@sentry.io>
Co-authored-by: Dhiogo Brustolin <dhiogorb@gmail.com>
brustolin
left a comment
There was a problem hiding this comment.
Great work! A few more things we should talk about it.
| * convert the selector to a Swift appropriate format aligned with the Swift #selector syntax. | ||
| * method:first:second:third: gets converted to method(first:second:third:) | ||
| */ | ||
| - (NSString *)getTransactionName:(NSString *)action target:(id)target |
There was a problem hiding this comment.
Here are some usage samples to simplify my explanation:
| Swift Function | Result | How I think it should be to not cause confusion |
|---|---|---|
| func testClick() | iOS_Swift.ViewController.testClick | iOS_Swift.ViewController.testClick() |
| func testClick(_ sender : Any) | iOS_Swift.ViewController.testClick | iOS_Swift.ViewController.testClick(_:) |
| func testClick(sender : Any) | iOS_Swift.ViewController.testClickWithSender | iOS_Swift.ViewController.testClick(sender:) |
| func testClick(sender : Any, second : Any) | iOS_Swift.ViewController.testClickWithSender(second:) | iOS_Swift.ViewController.testClick(sender:second:) |
| func testClick(_ sender : Any, second : Any) | iOS_Swift.ViewController.testClick(second:) | iOS_Swift.ViewController.testClick(_:secondParam:) |
As I said before, it is a little trickier to achieve perfect solution, Im kind fine with the result we have right now, because the first and second items are more common, but I do believe this will cause some confusion with some users.
There was a problem hiding this comment.
Hmm, I get your point but aren't most of these events coming from the storyboard, and there we only have
func testClick()func testClick(_ sender : Any)func testClick(_ sender : Any, _ second : Any)
I agree that our solution is not optimal, but I think it's enough for you to figure out which code was executed. The problem is that only when looking at the action I don't know how to get the difference between func testClick(_ sender : Any) and func testClick() without using other objc_runtime functions. Do have any idea how we could solve this? Maybe we can also fix this before enabling enableUserInteractionTracing per default.
There was a problem hiding this comment.
Are you okay with creating an issue for this and fixing it later, @brustolin?
There was a problem hiding this comment.
I don't know how to get the difference between func testClick(_ sender : Any) and func testClick()
if actions contain :, it has parameter, otherwise not.
But I thing we can release this way and wait for feedbacks
brustolin
left a comment
There was a problem hiding this comment.
I believe we already have a good feature. Let's merge it and gather feedbacks.
Creates transactions when the user clicks an UIButton, UISegmentedControl, UIBarButtonItem, or UIPageControl. Co-authored-by: Dhiogo Brustolin <dhiogorb@gmail.com>
Creates transactions when the user clicks an UIButton, UISegmentedControl, UIBarButtonItem, or UIPageControl. Co-authored-by: Dhiogo Brustolin <dhiogorb@gmail.com>
📜 Description
Creates transactions when the user clicks an UIButton, UISegmentedControl, UIBarButtonItem or UIPageControl. For more details, see getsentry/team-mobile#4.
💡 Motivation and Context
getsentry/team-mobile#4
💚 How did you test it?
Unit tests, simulator, and real devices.
📝 Checklist
🔮 Next steps