Instabug automatically tracks steps users have taken in the app before a bug is reported or a crash has occurred. This gives you great insights on how to reproduce the issue your users have encountered. Note that the maximum number of user steps sent with each report is 100.
To be able to capture the user steps, we need to do some method swizzling. We take an approach to swizzling that is absolutely safe and does not impact your app negatively in any way. In all the methods we swizzle, we call the original implementation to make sure we never break your app.
Method swizzling done in the Instabug SDK never impacts the performance of your app. In all the methods we swizzle, we only log events, and most of this is done in a low-priority background queue. you can check how much is spent on the original implementation only by checking
As of the latest version of the SDK, we swizzle the following methods:
- [UIApplication sendAction:to:from:forEvent:]: we log the action, target, sender and current view.
- [UIApplication sendEvent:]: we log the event type (touch, motion, etc). For privacy, we ignore any touch events on the keyboard.
To be able to keep support some features like APM UI Traces and User steps, we also swizzle the following methods:
- [UIWindow resignKeyWindow]
- [UIWindow becomeKeyWindow]
- [UIViewController initWithCoder:]
- [UIViewController initWithNibName:bundle::]
- [UIViewController viewDidLoad]
- [UIViewController viewWillAppear:]
- [UIViewController viewWillDisappear:]
- [UIViewController viewDidAppear:]
- [UIViewController viewDidDisappear:]
- [UIViewController viewWillLayoutSubviews]
- [UIViewController viewDidLayoutSubviews]
Finally, only when running on the iOS simulator, we swizzle
- [UIResponder motionEnded:withEvent:] to be able to respond to shake gestures.
All method swizzling done by the iOS SDK is absolutely safe and has no negative impact on the performance of your app, but if you decide you don’t want any method swizzling in your app, you can disable it by using the following method. Please note that the following method should be called right before Instabug is initialized with
Instabug.disableMethodSwizzling() // Make sure to call it before `start` Instabug.start(withToken: <#T##String#>, invocationEvents: <#T##IBGInvocationEvent#>)
[Instabug disableMethodSwizzling]; // Make sure to call it before `start` [Instabug startWithToken:<#(nonnull NSString *)#> invocationEvents:<#(IBGInvocationEvent)#>];
Effects of disabling swizzling
Disabling swizzling will prevent the SDK from doing the following:
If method swizzling is disabled, you can manually log touch events by following the below steps.
In order to group events together for the Repro Steps, you'll need to call the below method whenever a new view controller appears (whenever viewDidAppear is called):
[Instabug logViewDidAppearEvent:@"view name"];
In order to log the touch events that occur on your app manually, you should call the following method while passing to it the event type and the view name. This is required for both user and repro steps:
Instabug.logTouch(.tap, viewName: "view name")
[Instabug logTouchEvent:IBGUIEventTypeTap viewName:@"view name"];
The available event types are as follows:
.tap .forceTouch .longPress .pinch .swipe .scroll
IBGUIEventTypeTap IBGUIEventTypeForceTouch IBGUIEventTypeLongPress IBGUIEventTypePinch IBGUIEventTypeSwipe IBGUIEventTypeScroll
Updated 3 months ago