Skip to content
This repository has been archived by the owner on Jun 23, 2023. It is now read-only.
/ Swiftlytics Public archive

Swiftlytics is a simple protocol-oriented analytics abstraction that affords easy integration and disintegration with various analytics providers.

License

Notifications You must be signed in to change notification settings

almost-free/Swiftlytics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Swiftlytics

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(), //requires GoogleServices.info
    FacebookAnalyticsProvider(),
    AppsFlyerAnalyticsProvider(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.

About

Swiftlytics is a simple protocol-oriented analytics abstraction that affords easy integration and disintegration with various analytics providers.

Resources

License

Stars

Watchers

Forks

Packages

No packages published