Swift

The Swift SDK is built and maintained by Joe Barbour as part of the EnaLog Community. The repository can be found here

Installation

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

Setup

Add the following to the info.plist file in your Swift application, adding your EnaLog project name and API key:

<key>EN_PROJECT_NAME</key>
<string>SprintDock</string>
<key>EN_API_KEY</key>
<string>$(SD_ENALOG_KEY)</string>

Usage

The example code below shows you how to start sending events to EnaLog using the Swift SDK.

Firstly create an Enum containing all your event names:

enum EnalogEvents:String {
    case myNewEvent = "new.event"
    case fatalErrors = "fatal.error"
    case shoutoutJoe = "joe-is-the-best"
}

You can then send events with a description like so:

EnalogManager.main.ingest(EnalogEvents.myNewEvent, description:"This is a description")

Sending Events with Tags

EnalogManager.main.ingest(EnalogEvents.myNewEvent, description:"This is a description", tags:["My Tag 1", "My Tag 2"])

Sending Events with 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)