Latest 0.2.4
Homepage https://github.com/almost-free/Swiftlytics
License MIT
Platforms ios 9.0
Authors

CI Status
Version
License
Platform

Getting started

To run the example project, clone the repo, and run pod install from the Example directory first.

Declare a (global) instance of MultiAnalyticsProvider

import Swiftlytics

let swiftlytics: AnalyticsProvider = MultiAnalyticsProvider(providers: [
    FirebaseAnalyticsProvider(priority: 3), //requires GoogleServices.info
    FacebookAnalyticsProvider(priority: 2),
    AppsFlyerAnalyticsProvider(priority: 1, devKey: "YOUR_DEV_KEY", appId: "YOUR_APP_ID")
])

Pass AppDelegate lifecycle events to your instance

See Example/Swiftlytics/AppDelegate.swift

Define your event

struct MemoryWarningEvent: AnalyticsEventConvertible {
    let name = "memory_warning"
    let count: UInt
}

Track your event


...

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()

    count += 1
    swiftlytics.trackEvent(MemoryWarningEvent(count: count))
}

Track user properties to qualify events

swiftlytics.setUserId(UUID().uuidString) // your persistent database value in production
swiftlytics.setUserProperty(name: "name", withValue: "Sandy")

Requirements

Tested on Xcode 9.4.1, Swift 4, Cocoapods 1.5.3

Installation

Swiftlytics is available through CocoaPods, and is split into subspecs to avoid bloat from providers that you do not wish to integrate. To install
it, simply add the following line to your Podfile:

pod 'Swiftlytics'
pod 'Swiftlytics/Firebase'
pod 'Swiftlytics/AppsFlyer'
pod 'Swiftlytics/Facebook'

Contributing- adding a new provider

Add an entry to Swiftlytics.podspec

s.subspec 'AppsFlyer' do |appsflyer|
    appsflyer.source_files = 'Swiftlytics/AppsFlyer/**/*'
    appsflyer.dependency 'AppsFlyerFramework'
end

Define a new AnalyticsProvider, implementing all protocol methods

See Swiftlytics/AppsFlyer/AppsFlyerAnalyticsProvider for an example

Add any tests to the Example project

Be sure to import the subspec in Example/Podfile, e.g.:

pod 'Swiftlytics/Facebook', :path => '../'

and then pod install

License

Swiftlytics is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "Swiftlytics",
    "version": "0.2.4",
    "summary": "Swiftlytics is a lightweight analytics abstraction for many arbitrary analytics providers",
    "description": "Swiftlytics is a simple protocol-oriented analytics abstraction that affords easy integration and disintegration with various analytics providers.",
    "homepage": "https://github.com/almost-free/Swiftlytics",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Jon Willis": "[email protected]"
    },
    "source": {
        "git": "https://github.com/almost-free/Swiftlytics.git",
        "tag": "0.2.4"
    },
    "social_media_url": "https://twitter.com/almostfreetech",
    "platforms": {
        "ios": "9.0"
    },
    "static_framework": true,
    "swift_version": "4.2",
    "subspecs": [
        {
            "name": "Core",
            "source_files": "Swiftlytics/Core/**/*"
        },
        {
            "name": "Firebase",
            "source_files": "Swiftlytics/Firebase/**/*",
            "dependencies": {
                "Firebase/Core": [],
                "Firebase/Analytics": [],
                "Swiftlytics/Core": []
            }
        },
        {
            "name": "Facebook",
            "source_files": "Swiftlytics/Facebook/**/*",
            "dependencies": {
                "FacebookCore": [],
                "Swiftlytics/Core": []
            }
        },
        {
            "name": "AppsFlyer",
            "source_files": "Swiftlytics/AppsFlyer/**/*",
            "dependencies": {
                "AppsFlyerFramework": [],
                "Swiftlytics/Core": []
            }
        }
    ]
}

Pin It on Pinterest

Share This