Snowplow Android Tracker 0.4.0 released
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:
- Alternative to RxJava
- Tracker updates
- Emitter updates
- Under the hood
- Demo app
- Getting help
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.
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:
By default all logging from the Tracker is turned off but you can switch the logging level to one of
The emitter has had five new options added to its builder. You can now control:
- The amount of time between emitter attempts (
- The number of times the emitter will attempt to send if there are no events to send (
- The maximum amount of events to retrieve out of the database per emitter cycle (
- 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 (
This is a simplified algorithm for how the emitter runs:
- An event is added to the database; if the emitter is not running then start it and attempt to send
- If the device is offline then exit the emitter
- If the device is online and there are events to send, retrieve up to the
sendLimitfrom the database and then send
- Check the each event is under the specified byte limit before sending:
- Posts are bundled together up until the byte limit
- After sending, the emitter will then check if any more events have been added to the database:
- If empty the
emptyCountwill itterate every tick amount that was specified
- If the
emptyLimitis reached the emitter will halt
- If empty the
The emitter will only be started again on a new event addition or on calling the emitter
Here is an updated example of creating a new emitter:
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:
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.
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.
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:
- Guide to integrating the tracker
- Guide to setting up a test environment
- Walkthrough of our Android demo app
You can find the full release notes on GitHub as Snowplow Android Tracker v0.4.0 release.
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.