Enalog for Swift is the Unofficial Swift Package made by Joe Barbour in collaboration with Enalog & Enteka Software.
You can add this package to your project using Swift Package Manager. Enter the following url when adding it to your project package dependencies:
https://github.com/thebarbican19/EnalogSwift
EnalogSwift requires an Enalog Account and an API Key which can all be created for free here.
Once you have obtained an API Key and created a project in the Enalog Dashboard, you must specify these in the info.plist
in your Swift application.
To paste this directly into the info.plist
right-click on the info.plist
file in Xcode and choose Open As > Source Code
<key>EN_PROJECT_NAME</key>
<string>SprintDock</string>
<key>EN_API_KEY</key>
<string>$(SD_ENALOG_KEY)</string>
Declare the Library
import EnalogClient
For tracking each event in Enalog by user attributes it's important to call the user function. Here you can pass an UserID (required), Email Address & Name Additionally, you can also pass Any object that conforms to the Codable
protocol.
struct UserObject:Codable {
let id = "@MisterMeenr"
let name = "Mojito Joe"
let email = "[email protected]"
var plan:String
}
let user:UserObject = .init(plan: "PREMIUM")
EnalogManager.main.user(user.id, name: user.name, email: user.email, metadata: user)
EnalogManager.main.ingest()
function. This function takes the following parameters...
First, you must create an Enum with all your Event ID's. This can be named anything.
enum EnalogEvents:String {
case myNewEvent = "new.event"
case fatalErrors = "fatal.error"
case purchaseEvent = "purchase.event"
}
Once you have added this, you can call...
EnalogManager.main.ingest(EnalogEvents.myNewEvent, description:"This is a description")
Additionally, you can add Tags by calling...
EnalogManager.main.ingest(EnalogEvents.myNewEvent, description:"This is a description", tags:["My Tag 1", "My Tag 2"])
And like when specifying User Metadata, you can specify additional Metadata with AnyObject the conforms to the codable protocol.
struct PurchaseEvent:Codable { let product:String let cost:Double}
let product:PurchaseEvent = .init(product:"SprintDock License", cost:95.00)
EnalogManager.main.ingest(EnalogEvents.purchaseEvent, description:"A product was purchased", metadata:product)
To enable crash logging, you call the
crash
. This takes an enum
just like the ingest
function. EnalogManager.main.crash(EnalogEvents.fatalError) EnalogManager.main.crash(EnalogEvents.fatalError, channel: .init(.slack, id:"MY CHANNEL"))
Throttling stops duplicate ingests and unnecessary requests to the server. By default, this is set to **10 requests per minute**.
This limit can be changed by passing an Int
the throttle
function
EnalogManager.main.throttle(perMinute: 0)
This limit is capped at 20 ingest requests per second.
You can turn off all event tracking if you are running in a debug environment or running tests manually.
EnalogManager.main.disable(true)
Logging & Debugging are available in EnalogSwift. This can be toggled on and off at any point by calling
EnalogManager.main.debug(true)
By default, this will output all logs in the Xcode console.
For additional granularity, you can pass .fatal EnalogManager.main.debug(true, logType:.fatal)
. This will call a FatalError exception whenever an error occurs.This should not be used in Production.
Debug is automatically enabled when running in Xcode.
EnalogSwift runs on all Apple device architectures, including VisionOS!
- MacOS 10.15+ (Silicon & Intel)
- iOS 13.0+
- watchOS 6.0+
- tvOS 13.0+
- visionOS 1.0+
Enalog also has official Libraries in Python Node.js & Go. For more information, visit the official documentation.