1. Home
  2. Blog
  3. Releases

Snowplow Android Tracker 0.4.0 released

Jump to

We are pleased to announce the release of the fourth version of the Snowplow Android Tracker. The Tracker has undergone a series of changes in light of the issues around the Android dex limit, resulting in the library being split in two, allowing users to either use an RxJava-based version of the tracker, or a “classic” version using a standard Java threadpool.

Big thanks to Duncan at Wunderlist for his work on splitting apart the libraries and providing an RxJava-free version for those missing the dex space for it. And thanks again to Hamid at Trello for getting us on the path to a much more robust Android Tracker.

This release post will cover the following topics:

  1. Alternative to RxJava
  2. Tracker updates
  3. Emitter updates
  4. Under the hood
  5. Demo app
  6. Documentation
  7. Getting help

1. Alternative to RxJava

RxJava was brought into the Android Tracker as the better alternative to traditional Android AsyncTasks and for the speed at which it can process data; see our last blog post for the rationale. However it also brought with it a sizeable number of functions which add to the dex count of any application the tracker would be integrated into. This prompted thinking about a “lighter” version of the tracker, utilizing the inbuilt concurrency available to us without the overhead of RxJava.

Having to give the library as small a footprint as possible led us to split the library into three parts: a core library, an RxJava library and a Classic library. The RxJava and Classic libraries simply extend the core with their own concurrency logic.

2. Tracker updates

Another significant change is the move to greater concurrency in the Tracker. All tracker.trackXXX functions now operate within a threadpool to remove any impact the tracker could have on the UI/Main thread. From the moment you start tracking, all processing is moved to background threads, so there is nothing blocking for your application to deal with.

On top of this you can now also set how much logging you would like to see from the Tracker. The new builder option:

Tracker t1 = new Tracker .TrackerBuilder( ... ) .level(LogLevel.VERBOSE) // Logging Options .build<span class="o">();

By default all logging from the Tracker is turned off but you can switch the logging level to one of VERBOSE, DEBUG or ERROR.

3. Emitter updates

The emitter has had five new options added to its builder. You can now control:

  • The amount of time between emitter attempts (emitterTick)
  • The number of times the emitter will attempt to send if there are no events to send (emptyLimit)
  • The maximum amount of events to retrieve out of the database per emitter cycle (sendLimit):
    • This is controlled so you do not pull in huge numbers of events into the Heap
  • The maximum byte limit for request sending for both GET and POST requests (byteLimitGet and byteLimitPost respectively)

This is a simplified algorithm for how the emitter runs:

  1. An event is added to the database; if the emitter is not running then start it and attempt to send
  2. If the device is offline then exit the emitter
  3. If the device is online and there are events to send, retrieve up to the sendLimit from the database and then send
  4. Check the each event is under the specified byte limit before sending:
    • Posts are bundled together up until the byte limit
  5. After sending, the emitter will then check if any more events have been added to the database:
    • If empty the emptyCount will itterate every tick amount that was specified
    • If the emptyLimit is reached the emitter will halt

The emitter will only be started again on a new event addition or on calling the emitter flush() function.

Here is an updated example of creating a new emitter:

Emitter e1 = new Emitter .EmitterBuilder( ... ) .sendLimit(500) // Will get up to 500 events from the Database .emptyLimit(10) // Emitter will tick 10 times before shutting down .tick(5) // Emitter will tick every 5 seconds .byteLimitGet(40000) // The maximum GET payload must be less than 40000 bytes .byteLimitPost(40000) // The maximum POST payload must be less than 40000 bytes .build<span class="o">();

4. Under the hood

As well as the splitting of libraries, we have also made a range of other improvements.

The dependency on Jackson JSON processor has been removed.

For those developing for older versions of Android or with a very tight dex limit, the need to have any Google Play Services libraries has also been removed. If you do import Google Play Services you will now only need to import the analytics specific package as well instead of the entire Play Services setup:

ompile 'com.google.android.gms:play-services-analytics:7.5.0'

5. Demo app

This release also includes a demo app for test driving both the Classic and the RxJava Trackers. The app allows you to send every possible combination of events to an endpoint of your choosing via HTTP or HTTPS, and via GET or POST. You can grab the APK from here. To install the app you will need to allow installation from sources other than the Google Play Store.

Here are some screenshots from the app:

For a walkthrough of the demo please go here.

For setting up an endpoint quickly and easily we now also include Ngrok along with Mountebank in the Vagrant VM environment. Set it up like so:

 host$ git clone https://github.com/snowplow/snowplow-android-tracker.git host$ cd snowplow-android-tracker host$ vagrant up && vagrant ssh guest$ cd /vagrant guest$ chmod +x ./testing/setup.bash guest$ ./testing/setup.bash

Then in your host machine navigate to http://localhost:4040/, the Ngrok interface. Put in the endpoint provided into the application and send away!

For further information on the test environment go here.

6. Documentation

You can find the updated Android Tracker documentation on our wiki.

As part of this release we have also several new tutorials to help Android developers integrate the tracker into their apps:

You can find the full release notes on GitHub as Snowplow Android Tracker v0.4.0 release.

7. Getting help

The Android Tracker is still an immature project and we will be working hard with the community to improve it over the coming weeks and months; in the meantime, do please share any user feedback, feature requests or possible bugs.

For help on integrating the application please have a look at the setup and integration guides.

Feel free to get in touch or raise an issue in the Android Tracker’s issues on GitHub!

More about
the author

Joshua Beemster
Joshua Beemster

Josh is a Head of Engineering and enjoys mapping out how to manage infrastructure across multiple clouds using a combination of Terraform, K8s and Helm. He works mainly with the teams responsible for infrastructure and the core data processing teams at Snowplow.

View author

Unlock the value of your behavioral data with customer data infrastructure for AI, advanced analytics, and personalized experiences

Image of the Snowplow app UI