DarylAndroidTracker
guitcastro
35
Visit GitHub RepoAnalytics

DarylAndroidTracker codecov

Use multiple analytics and other trackers in your Application easily

Supported trackers:

  • Google Analytics
  • Crashlytics
  • Firebase
  • Facebook
  • Dito
  • Intercom
  • Mixpanel

Installing

Just added the necessary SDKs to your gradle file:

def darylVersion = '0.0.58'

compile "com.appprova.daryl:daryl:$darylVersion"
compile "com.appprova.daryl:googleanalytics:$darylVersion"
compile "com.appprova.daryl:crashlytics:$darylVersion"
compile "com.appprova.daryl:firebase:$darylVersion"
compile "com.appprova.daryl:facebook:$darylVersion"
compile "com.appprova.daryl:dito:$darylVersion"
compile "com.appprova.daryl:intercom:$darylVersion"
compile "com.appprova.daryl:mixpanel:$darylVersion"

Usages instructions

Registering your trackers

Google Analytics

GoogleAnalytics googleAnalytics = GoogleAnalytics
                .getInstance(app.getApplicationContext());
Tracker googleTracker = googleAnalytics.newTracker(R.xml.app_tracker);
googleTracker.enableAdvertisingIdCollection(true);

TrackerAdapter googleAnalyticsTracker = new GoogleAnalyticsTracker(googleTracker);

Firebase

TrackerAdapter firebaseTracker = new FirebaseTracker(FirebaseAnalytics.getInstance(context.getApplicationContext()));

CrashLytics Log

TrackerAdapter crashlyticsLogTracker = new CrashlyticsLogTracker();

Facebook Log

TrackerAdapter facebookTracker = new FacebookTracker(AppEventsLogger.newLogger(context.getApplicationContext()));

Intercom

TrackerAdapter intercomTracker = new IntercomTracker(Intercom.client());

Mixpanel

MixpanelAPI mixpanel =
    MixpanelAPI.getInstance(context, MIXPANEL_TOKEN);
TrackerAdapter mixpanelTracer = new MixpanelTracer(mixpanelApi);

Registering multiple trackers

MultipleTrackerAdapter trackerAdapter = new MultipleTrackerAdapter();
trackerAdapter.addTracker(googleAnalyticsTracker);
        trackerAdapter.addTracker(ditoTracker);
        trackerAdapter.addTracker(firebaseTracker);
        trackerAdapter.addTracker(facebookTracker);
        trackerAdapter.addTracker(intercomTracker);
        trackerAdapter.addTracker(mixpanelTracker);
        if (!BuildConfig.DEBUG) {
            trackerAdapter.addTracker(crashlyticsLogTracker);
        }

Starting Tracking

After all trackers are registered you can just use the multiple tracker to track all events at once

Tracking event

trackerAdapter.logEvent(new EventBuilder("event name")
                .setCategory("event category")
                .setAction("event action")
                .setProperty("custom property", "property value")         
                .get());

Tracking page view

trackerAdapter.logPageView("page name");

Tracking exceptions

Avaibles for : Firebase, CrashlyticsLog and Google Analytics

trackerAdapter.logException(new Exception("something went wrong"));

Logging user properties

Avaibles for : Firebase, CrashlyticsLog

trackerAdapter.setUserProperty(Constants.USER_PROPERTY_EMAIL, "example@gmail.com");

Creating custom tracker

In oder to create a custom tracker you just need to implement the TrackerAdapter interface.

Become a better Android Developer
Millions of developers are learning at MindOrks

Online Training Program

Featured Blogs

Our Team

MindOrks is Certainly one of the best online blog to stay on top of all the Android development news, coding and design patterns. Finally a blog I can count on to keep myself updated with latest and greatest things happening in Android world.

Vipul Shah
Android Developer
Microsoft

Become Pro in Android by watching videos

OUR LEARNERS WORK AT