LoggingViewKit is a framework that can record user click events, etc. All records are stored in a local database and the framework does not send any data externally.
LoggingViewKit is available through Swift Package Manager. To install it using Xcode, specify the git URL for LoggingViewKit.
https://github.com/HituziANDO/LoggingViewKit
LoggingViewKit is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "LoggingViewKit"LoggingViewKit is available through Carthage. To install it, simply add the following line to your Cartfile:
github "HituziANDO/LoggingViewKit"
import LoggingViewKit-
Programmatically write click event
In following code,
buttonPressedmethod is set to the action method of UIButton.@objc func buttonPressed(_ sender: Any) { // Records a click event. let attr = LGVLoggingAttribute(view: sender, name: "SampleButton", loggingEnabled: true) attr.info = ["more-info": "test"] LGVLoggingViewService.shared().click(attr) }
-
Start recording
LGVLoggingViewService.shared().startRecording()
-
Stop recording
LGVLoggingViewService.shared().stopRecording()
-
Read all logs
let logs = LGVLoggingViewService.shared().allLogs()
-
Delete all logs
LGVLoggingViewService.shared().deleteAllLogs()
More info, see my sample project.
If you use the storyboard, you can set UI class such as LGVButton in the storyboard.
LoggingViewKit has following UI classes by default.
- Button
- Label
- SegmentedControl
- Slider
- Stepper
- Switch
- View
-
Set arbitrary name to Logging Name field
[NOTE] Recommend setting a unique name.
-
Select
Onin Logging field to record the view[NOTE] If you select
OfforDefault, the view is not target to record.
LoggingViewKit records logs like the following log.
{
ID = 47;
eventType = "click";
absoluteClickX = "124.3333282470703";
absoluteClickY = "189.6666564941406";
clickX = "108.3333282470703";
clickY = "145.6666564941406";
createdAt = "2018-12-25 23:02:13 +0000";
info = {
newValue = 2;
};
key = "7F34859D-2164-4B4B-B896-EA9D3D826C92";
name = SampleSegmentedControl;
}
LoggingViewKit can dump the hierarchy of specified view to Xcode console. The sample log is following.
2019-04-02 12:11:59.876292+0900 LoggingViewSwiftSample[8616:19026371] ===ViewHierarchy===
UIView
LGVView(loggingName: (null))
LGVButton(loggingName: SampleButton)
LGVSwitch(loggingName: SampleSwitch)
UISwitchModernVisualElement
UIView
UIView
UIView
UIView
UIView
UIImageView
UIImageView
UIImageView
LGVSegmentedControl(loggingName: SampleSegmentedControl)
UISegment
UISegmentLabel
UIImageView
UISegment
UISegmentLabel
UIImageView
UISegment
UISegmentLabel
UIImageView
UISegment
UISegmentLabel
UIImageView
LGVStepper(loggingName: SampleStepper)
_UIStepperButton
_UIStepperButton
UIImageView
LGVLabel(loggingName: SampleLabel)
LGVView(loggingName: SampleView)
LGVButton(loggingName: TestButton)
LGVSlider(loggingName: SampleSlider)
override func viewDidLoad() {
super.viewDidLoad()
#if DEBUG
// Dumps hierarchy of the root view.
LGVViewHierarchy.dump(view)
#endif
}[NOTE] Recommend that you enclose with #if DEBUG ~ #endif. Then LoggingViewKit dumps logs only in Debug build.
How to Enable DEBUG Flag:
- Open Build Settings > Swift Compiler - Custom Flags > Other Swift Flags section
- Add
-DDEBUGflag to Debug row

