Snowplow Android Tracker 0.7.0 released with consent tracking

10 May 2018  •  Mike Hadam

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

Version 0.7.0 introduces first-class methods for tracking when users grant or withdraw consent for their personal data to be processed for specific purposes, as well as new and improved form tracking and the ability to create new tracker sessions client-side.

Read on below the fold for:

  1. Consent tracking
  2. More flexible lifecycle tracking
  3. Improved TLS configuration
  4. New session convenience method
  5. Updates and bug fixes
  6. Documentation
  7. Getting help

Against the backdrop of the incoming GDPR and ePrivacy regulations, this release adds new events to track when users give their consent to, and withdraw their consent from, having their personal data processed for specific purposes.

We envision that many digital businesses will want to track the consent of their users against relatively fine-grained “bundles” of specific use cases for data, which we model in Snowplow as consent documents.

The two new consent tracking methods are:

  1. trackConsentGranted for the giving of consent by a data subject
  2. trackConsentWithdrawn for the removal of consent by a data subject

Each consent event will be associated to one or more consent documents, attached to the event as contexts.

Here is an example of a user opting into data collection per a specific consent document 1234:

List<ConsentDocument> documents = new LinkedList<>();
        documents.add(ConsentDocument.builder()
                .documentDescription("an associated document")
                .documentId("1234")
                .documentName("test name")
                .documentVersion("3")
                .build());

t1.track(ConsentGranted.builder()
    .expiry("2020-11-21T08:00:00.000Z")
    .documentDescription("a document granting consent")
    .documentName("consent_document")
    .documentVersion("5")
    .documentId("1234")
    .consentDocuments(documents)
    .build());

2. More flexible lifecycle tracking

App lifecycle tracking is a powerful auto-tracking capability, introduced in version 0.6.0. In this release we add fine-tuned control of lifecycle tracking, with the functions tracker.pauseLifecycleHandler() and tracker.resumeLifecycleHandler().

For example, this can be used to maintain a session uninterrupted when something momentarily backgrounds an activity:

tracker.pauseLifecycleHandler()
// Call code that backgrounds the activity watched by the lifecycle handler
tracker.resumeLifecycleHandler()

The lifecycle handler can also now be constructed with a custom context, so that all application_foreground and application_background events will include the custom context:

// Create a Map of the data you want to include...
Map<String, String> dataMap = new HashMap<>();
dataMap.put("deviceName", "Phone");
dataMap.put("OSVersion", "16");

// Now create your SelfDescribingJson object...
SelfDescribingJson context1 = new SelfDescribingJson("iglu:com.acme/device_info/jsonschema/2-1-1", dataMap);

// Now add this JSON into a list of SelfDescribingJsons...
List<SelfDescribingJson> contexts = new ArrayList<>();
contexts.add(context1);

Tracker.init(new Tracker.TrackerBuilder(emitter, namespace, appId, this.getApplicationContext())
       .level(LogLevel.DEBUG)
       .base64(false)
       .platform(DevicePlatforms.Mobile)
       .subject(subject)
       .threadCount(20)
       .sessionContext(true)
       .mobileContext(true)
       .geoLocationContext(true)
       .applicationCrash(true)
       .lifecycleEvents(true)
       .build())
       .setLifecycleHandler(this, contexts);

Documentation can be found here.

3. Improved TLS configuration

With this release, the TLS version(s) used by the emitter can be specified in the builder:

Emitter e2 = new Emitter
        .EmitterBuilder("com.collector.acme", Context context) // Required
        .method(HttpMethod.GET) // Optional - Defines how we send the request
        .option(BufferOption.Single) // Optional - Defines how many events we bundle in a POST
        .security(RequestSecurity.HTTPS) // Optional - Defines what protocol used to send events
        .tls(EnumSet.of(TLSVersion.TLSv1_1, TLSVersion.TLSv1_2)) // Optional - Defines what TLS versions should be used
        .callback(new EmitterCallback() {...})
        .build();

Alternatively a single enum can be passed to the builder like so: .tls(TLSVersion.TLSv1_2).

As always, documentation is found here.

4. New session convenience method

With this release, a new session can be started with the tracker method, tracker.startNewSession().

5. Updates and bug fixes

Other updates and fixes include:

  • Fixing the bug where firstId was not reset if the app is in the foreground (issue #257)
  • Raising the minimum supported Android API to level 14 (issue #262)
  • Unregistering LifecycleHandler callbacks on activity destruction (issue #259)
  • Fixing our outdated and broken Travis configuration (issue #258)
  • Adding identifyUser as an alias for setUserId (issue #254)
  • Making tracker.setLifecycleHandler take a Context instead of an Activity (issue #224)

6. Documentation

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

As part of this release we have updated our 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.7.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.