Snowplow Android Tracker 1.0.0 released

20 February 2019  •  Mike Hadam

We are pleased to announce a new release of the Snowplow Android Tracker.

Version 1.0.0 introduces features to alleviate blocking issues on tracker instantiation and add control over sessions. The release also improves the robustness of foreground and background detection. You’ll also notice the introduction of our new documentation site!

Read on below the fold for:

  1. New documentation site
  2. Async support
  3. Share OkHttpClient instance
  4. Session transitions
  5. Updates
  6. Documentation
  7. Getting help

1. New documentation site

We’ve added our mobile trackers to our new documentation site. The documentation is divided into easy parts that lay out:

  • how to install the tracker
  • quickly start tracking events
  • an outline of how the tracker works
  • details about both basic and advanced methods available on the tracker

2. Async support

There are new methods available for loading the tracker asynchronously (since session information is stored in a file, and must be loaded whenever the tracker starts):

  • waitForSessionFileLoad(), a blocking call on the tracker to wait for the session file to load.

  • getHasLoadedFromFile(), a non-blocking call to check whether the tracker has loaded the session file.

  • getLoadFromFileFuture(), a Future that can be used to check the progress.

// First initialize your tracker
Tracker.init(new Tracker
  .TrackerBuilder(e2, "myNamespace", "myAppId", getContext())
  .base64(false) // Optional - defines if we use base64 encoding
  .platform(DevicePlatforms.Mobile) // Optional - defines what platform the event will report to be on
  .subject(new Subject.SubjectBuilder().build()) // Optional - a subject which contains values appended to every event
  .build()
);

// Then this method will return a boolean representing if the tracker has loaded
Tracker.getHasLoadedFromFile()

3. Share `OkHttpClient` instance

In this release, emitters can be created with a shared OkHttpClient instance.

This practice is intended to save resources, since it will allow sharing the ConnectionPool and ThreadPool of the client.

Here’s an example of the new Emitter builder method client():

Emitter e2 = new Emitter
        .EmitterBuilder("com.collector.acme", Context context) // Required
        .client(sharedOkHttpClient) // Use this for the shared OkHttpClient
        .build();

4. Session transitions

The tracker now has a builder method sessionCallbacks() for supplying session transition Runnable callbacks.

These are to be executed whenever there’s a transition in the state of the app (from background to foreground or vice versa), as well as whenever there is a session timeout (in the background or foreground).

5. Other changes

Other updates and fixes include:

  • Fix Travis license issue (#288)
  • Update to Android Target API level 28 (#287)
  • Output maximum logging detail in demo app (#279)
  • Perform blocking operations in the background (#159)
  • Enforce strict mode for demo app (#278)
  • Bump versions in build.gradle for demo app (#284)
  • Bump Android Gradle to 3.2.1 (#280)
  • Bump versions of build tools in Travis (#283)
  • Add setter for session context boolean (#282)
  • Update to Android Target API level 26 (#273)
  • Add ability to momentarily suspend session checking (#271)

Many thanks to Ahmed Khalil for your contributions!

6. Documentation

As always, information about how to use the tracker can be found in the Android Tracker documentation.

You can find the full release notes on GitHub as Snowplow Android Tracker v1.0.0 release.

7. Getting help

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

If you have any questions or run into any problems, please visit our Discourse forum. As always, do raise any bugs in the Android Tracker’s issues on GitHub.

For more details on this release, please check out the release notes on GitHub.