Snowplow Java Tracker 0.3.0 released

13 July 2014  •  Jonathan Almeida

Today we are introducing the release of the Snowplow Java Tracker version 0.3.0.

Similar to the previous 0.2.0 release, this too is a mixture of minor & stability fixes. We’ve made only a few minor interface changes, so it shouldn’t affect current users of the Java Tracker too much.

You can find more on the new additions futher down in this post:

  1. Strings replaced with Maps for Context
  2. Timestamp for Trackers
  3. Logging with SLF4J
  4. Dependency updates
  5. Unit testing
  6. Support

1. Strings replaced with Maps for Context

This is probably the largest part of this release. Previously, users would need to pass in the context as a JSON-formatted string of data which would then be encoded accordingly. We’ve now removed that option and replaced it with a Map. You can see a comparison of the method signature before and after:

// Previous
public void trackPageView(String page_url, String page_title, String referrer, String context)

// Now
public void trackPageView(String page_url, String page_title, String referrer, Map context, long timestamp)

This should give a bit more flexibility and ease while creating your custom contexts.

2. Timestamp for Trackers

You may have noticed in the previous example’s method signature that there was an extra argument with a timestamp. In order to keep the Java Tracker consistent with the other trackers, we’ve added the ability to set your own timestamp for the event you’re tracking. If you would rather use the default timestamp, you can just set a 0.

Here are two cases where we set our own timestamp as well as use the default:

trackScreenView("Main View", "pageId", contextMap, 1234567L);
trackScreenView("Main View", "pageId", contextMap, 0);

3. Logging with SLF4J

We’ve added some initial debug logging to our trackers using SLF4J. This should make it easier to debug issues should any arise. While there is only debug-level logging currently, we are looking to add some info-level logging in the future if needed.

4. Dependency updates

The Jackson library that we introduced in our previous 0.2.0 release has been updated from 1.9.3 to 2.4.1.1. This was done to stay on the latest stable release and shouldn’t need any change from your side.

We’ve changed the slf4j-api dependency to slf4j-simple (which includes slf4j-api) from version 1.7.5 to 1.7.7.

5. Unit testing

More unit tests have been added to the project for continued stability checks, the majority of which are for the PayloadMap class. Feel free to use some of these as example code.

6. Support

As always, we’d love to hear of any feature suggestions from you, or even help setting up the tracker. Feel free to get in touch with us, or raise an issue if you find any bugs.