Giter Club home page Giter Club logo

solid-kotlin-analytics's Introduction

Bintray

SOLID Android Client Kotlin Analytics Interface

fancy-diagram

Writing SOLID Analytics With Kotlin for Android - Medium Article

This library demonstrates how you could decouple analytics libraries from your business logic code, effectively allowing you to:

  • Add & remove analytics services quickly
  • Add & remove events quickly
  • Change event names and parameters according to the required kit

Quick Start Guide

Add To Gradle

Add library to your gradle module

repositories {
    maven { url "http://dl.bintray.com/sofakingforever/analytics" }
}

dependencies {

    def version = '1.0.19'


    // This is the generic java/kotlin interface
    compile "com.sofakingforever.analytics:analytics:version"

    // This is an android-dependant extension interface
    compile "com.sofakingforever.analytics:android:version@aar"
    
    // then add the kits you need, or implement your own kit/dispatcher
    compile "com.sofakingforever.analytics:kit-answers:version@aar"
    compile "com.sofakingforever.analytics:kit-firebase:version@aar"
    compile "com.sofakingforever.analytics:kit-flurry:version@aar"
    compile "com.sofakingforever.analytics:kit-mixpanel:version@aar"
    
    
    // Don't forget to add kotlin dependency, if you're in a pure-java project
    implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.2.71


}

Kotlin Implementation Example

Initiate analytics and send events

// init analytics
analytics = Analytics(settings,
                CustomDispatcher(init = true),
                LoggerDispatcherImpl(init = true, context = this),
                FirebaseDispatcherImpl(init = true, context = this),
                MixPanelDispatcherImpl(init = true, projectToken = "TOKEN", context = this),
                AnswersDispatcherImpl(init = true, context = this)


//              if you're using crashlytics, or any other fabric kit in addition to Answers
//              AnswersDispatcherImpl(init = true, Answers(), Crashlytics())
        )

// send event
analytics.track(SimpleEvent())

Don't forget to declare the event

class SimpleEvent : CustomEvent {
    // declare name - will be sent to all dispatchers
    override fun getEventName(kit: AnalyticsKit): String = "Simple Event"

}

Android Highlights

If you're targeting Android, you need the android package, and you should generally extend AndroidAnalyticsDispatcher and AndroidAnalyticsSettings instead of the kotlin ones.

See more integration examples in the source code

Todo List

  • Setup repository
  • Add Code
  • Upload First Build
  • Add Gradle Example
  • Add Fabric Answers Default Implementation
  • Add Firebase Default Implementation
  • Add Flurry Default Implementation
  • Add Example Code to App Module
  • Add Example Code to README
  • Add Documentation
  • Add Unit Tests
  • Who knows... :o

Originally developed for Wakey - Beautiful Alarm Clock

Wakey is a simple & beautiful animated alarm clock, featuring a spectacular design and an immersive experience - guaranteed to wake you up with a smile everyday!

With our smiling sunrise, and grumpy lunar animations, this is the most unique alarm clock in our solar system.

Wakey Alarm Clock

License

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

solid-kotlin-analytics's People

Contributors

sofakingforever avatar udev avatar

Watchers

James Cloos 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.