Giter VIP home page Giter VIP logo

enalogswift's Introduction

EnalogSwift

Swift Version MacOS Support iOS Support tvOS Support watchOS Support visionOS Support

Enalog for Swift is the Unofficial Swift Package made by Joe Barbour in collaboration with Enalog & Enteka Software.



Getting Started

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



Introduction

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



User Metadata

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)



Tracking Events

Creating & Tracking events can be achieved by calling the EnalogManager.main.ingest() function. This function takes the following parameters...

  • Event ID (Enum)
  • Description (String)
  • Tags (Array)
  • Metadata (AnyObject)
  • Channel (EnalogChannelObject)


  • 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)



    Crash Logging

    EnalogSwift can also notify you of crashes in your App. When enabled, additional metadata is sent which includes the reason.

    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

    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.



    Logging & Debugging

    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.



    Version Support

    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.

    enalogswift's People

    Contributors

    thebarbican19 avatar

    Recommend Projects

    • React photo React

      A declarative, efficient, and flexible JavaScript library for building user interfaces.

    • Vue.js photo Vue.js

      ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

    • Typescript photo Typescript

      TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

    • TensorFlow photo TensorFlow

      An Open Source Machine Learning Framework for Everyone

    • Django photo Django

      The Web framework for perfectionists with deadlines.

    • D3 photo D3

      Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

    Recommend Topics

    • javascript

      JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

    • web

      Some thing interesting about web. New door for the world.

    • server

      A server is a program made to process requests and deliver data to clients.

    • Machine learning

      Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

    • Game

      Some thing interesting about game, make everyone happy.

    Recommend Org

    • Facebook photo Facebook

      We are working to build community through open source technology. NB: members must have two-factor auth.

    • Microsoft photo Microsoft

      Open source projects and samples from Microsoft.

    • Google photo Google

      Google โค๏ธ Open Source for everyone.

    • D3 photo D3

      Data-Driven Documents codes.