Collar is a library which simplifies analytics debugging by showing events, screen views and user properties of your app as they happen.
- Swift 5.1
- Xcode 11.0
- iOS 11.0
Collar is available through CocoaPods. To install it, simply add the following line to your Podfile
:
pod 'Collar'
If you are using the SwiftPM as your dependencies manager, add this to the dependencies in your Package.swift
file:
dependencies: [
.package(url: "https://github.com/infinum/ios-collar.git")
]
import Collar
// Events
AnalyticsCollectionManager.shared.log(event: "some_event", parameters: [
"param1": "value1",
"param2": "value2"
])
// User properties
AnalyticsCollectionManager.shared.setUserProperty("some_value", forName: "user_property_key")
// Screen views
AnalyticsCollectionManager.shared.track(screenName: "Home", screenClass: "HomeViewController")
IMPORTANT: Collar does NOT send out analytics data to remote services. This is left for the developer to solve in their own codebase, with Collar being simply a reflection of the current state of analytics data.
AnalyticsCollectionManager.shared.showLogs(from: viewController)
3. If you want to display popup every time event/user property/screen view is tracked, you can just use the following snippet:
// Also controllable from settings screen inside logs view
LogItemPopupQueue.shared.enabled = true
// Popup dismisses on tap or after defined number of seconds
LogItemPopupQueue.shared.showOnView = { UIApplication.shared.keyWindow }
If you would like to receive notifications when new logs are added to the list, your app can observe AnalyticsCollectionManager.Notification.didUpdateLogs
notification.
Please make sure that AnalyticsCollectionManager
and LogItemPopupQueue
are not used in production builds. Best option would be not to include Collar in you production targets/configurations at all, for example:
pod 'Collar', :configurations => ['Development-release', 'Development-debug']
To run the example project, clone the repo, and run pod install
from the Example directory first.
Filip Gulan, [email protected]
Maintained and sponsored by Infinum.
Collar is available under the MIT license. See the LICENSE file for more info.