Snowplow Python Tracker 0.2.0 released

15 April 2014  •  Fred Blundun

We are happy to announce the release of the Snowplow Python Tracker version 0.2.0. This release adds support for Python 2.7, makes some improvements to the Tracker API, and expands the test suite.

This post will cover:

  1. Changes to the API
  2. Python 2.7
  3. Integration tests
  4. Other improvements
  5. Upgrading
  6. Support

1. Changes to the API

The call to import the tracker module has not changed:

from snowplow_tracker.tracker import Tracker

Tracker initialization has been simplified:

t = Tracker("d3rkrsqld9gmqf.cloudfront.net")

Note that the method to set a collector URL based purely on a Cloudfront subdomain has been removed: you should now pass the whole host string “d3rkrsqld9gmqf.cloudfront.net”, not just “d3rkrsqld9gmqf”.

You can also provide a tracker name argument:

t = Tracker("d3rkrsqld9gmqf.cloudfront.net", "cf")

Every event fired by t will have a tracker namespace field with value “cf”. This means that you can match events to the tracker which created them.

There is one other major improvement to the API: tracker methods no longer require you to supply every argument. Arguments which are not supplied default to None and will not be added to the event. For example, the track_ecommerce_transaction method takes up to nine arguments, but only order_id and total_value are mandatory. Suppose we want to call track_ecommerce_transaction with just the two mandatory parameters and the optional country parameter. This is how to do it:

t.track_ecommerce_transaction("12e4ba", 19.99, country="France")

As part of this change, the order of arguments for certain methods has been changed so that all keyword arguments come after all non-keyword arguments. For more information on which arguments are required and which are not, on the names of keyword arguments, and on the new order of arguments, see the wiki.

The Snowplow Python Tracker is now fully compatible with Python 2.7. Going forwards, we intend to maintain support for both Python 3.3 and Python 2.7, as well as adding support for other Python versions as they are requested.

As well as running the test suite using both Python 2.7 and Python 3.3, we have expanded the scope of the integration tests. Now the GET payload generated by each tracking method is validated, ensuring that the correct data is being sent.

We have also:

  • Added an event vendor parameter for events defined by Snowplow #55
  • Switched from using pycontract 0.1.4 to PyContracts 1.6.0 #63
  • Fixed the dependency versions in requirements.txt #47
  • Started sending the platform and tracker version through on the querystring #50
  • Linked the Technical Docs and Setup Guide images in the README to the appropriate pages [#60] [60]
  • Changed the tracker version field from “python-0.1.0” to “py-0.2.0” #51

The release version of this tracker (0.2.0) is available on PyPI, the Python Package Index repository, as snowplow-tracker. Download and install it with pip:

$ pip install snowplow-tracker --upgrade

Or with setuptools:

$ easy_install -U snowplow-tracker

For more information on getting started with the Snowplow Python Tracker, see the setup page.

The Snowplow Python Tracker is still very young, so please do get in touch if you need help setting it up or have features you would like us to add next. And raise an issue if you spot any bugs!