Swiftpack.co - HituziANDO/LoggingViewKit as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by HituziANDO.
HituziANDO/LoggingViewKit 6.0.5
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.
⭐️ 3
🕓 1 week ago
iOS macOS
.package(url: "https://github.com/HituziANDO/LoggingViewKit.git", from: "6.0.5")

LoggingViewKit

release Pod Platform Pod Version Carthage Compatible Swift Package Manager compatible

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.

Include in Your Project

Swift Package Manager

LoggingViewKit is available through Swift Package Manager. To install it using Xcode, specify the git URL for LoggingViewKit.

https://github.com/HituziANDO/LoggingViewKit

CocoaPods

LoggingViewKit is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "LoggingViewKit"

Carthage

LoggingViewKit is available through Carthage. To install it, simply add the following line to your Cartfile:

github "HituziANDO/LoggingViewKit"

Import framework

import LoggingViewKit

Usage

  1. Programmatically write click event

    In following code, buttonPressed method 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)
    }
    
  2. Start recording

    LGVLoggingViewService.shared().startRecording()
    
  3. Stop recording

    LGVLoggingViewService.shared().stopRecording()
    
  4. Read all logs

    let logs = LGVLoggingViewService.shared().allLogs()
    
  5. Delete all logs

    LGVLoggingViewService.shared().deleteAllLogs()
    

More info, see my sample project.

Use Storyboard

If you use the storyboard, you can set UI class such as LGVButton in the storyboard.

screenshot1

LoggingViewKit has following UI classes by default.

  • Button
  • Label
  • SegmentedControl
  • Slider
  • Stepper
  • Switch
  • View
  1. Set arbitrary name to Logging Name field

    screenshot2

    [NOTE] Recommend setting a unique name.

  2. Select On in Logging field to record the view

    [NOTE] If you select Off or Default, the view is not target to record.

Sample Log

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;
}

Dump View Hierarchy

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)

Usage

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:

  1. Open Build Settings > Swift Compiler - Custom Flags > Other Swift Flags section
  2. Add -DDEBUG flag to Debug row

GitHub

link
Stars: 3
Last commit: 1 week ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

6.0.5
1 week ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics