?> Snowplow Scala Tracker 0.1.0 released | Snowplow
Snowplow Outperforms GA4 in GigaOm Comparative Evaluation.
Read More
  1. Home
  2. Blog
  3. Releases
Releases

Snowplow Scala Tracker 0.1.0 released

Jump to

We are pleased to announce the release of the new Snowplow Scala Tracker! This initial release allows you to build and send unstructured events and custom contexts using the json4s library.

We plan to move Snowplow towards being “self-hosting” by sending Snowplow events from within our own apps for monitoring purposes; the idea is that you should be able to monitor the health of one deployment of Snowplow by using a second instance. We will start “eating our own dog food” in upcoming Snowplow Kinesis releases, where the Elasticsearch Sink and Kinesis S3 Sink (now in its own repo) will both emit startup, shutdown, heartbeat, and write_failed events using this new Scala event tracker.

The library is built around Akka 2.3.5; events are sent to a Snowplow collector using spray-client, and both synchronous and asynchronous event emitters are supported.

Contents:

  1. How to install the tracker
  2. How to use the tracker
  3. Getting help

How to install the tracker

The Snowplow Scala Tracker is cross-published for Scala 2.10.x and Scala 2.11.x, and hosted in the Snowplow Maven repository. Assuming you are using SBT, you can add the tracker to your project’s build.sbt like so:

// Resolvers val snowplowRepo = "Snowplow Releases" at "http://maven.snplow.com/releases/" // Libraries libraryDependencies += "com.snowplowanalytics.snowplow" %% "snowplow-scala-tracker" % "0.1.0"

For more detailed setup instructions, check out the Scala Tracker Setup Guide on the Snowplow wiki.

You’re now ready to start using the Tracker!

How to use the tracker

You will require these imports:

import com.snowplowanalytics.snowplow.scalatracker.Tracker import com.snowplowanalytics.snowplow.scalatracker.SelfDescribingJson import com.snowplowanalytics.snowplow.scalatracker.emitters.AsyncEmitter

Create a Tracker instance like this:

val emitter = AsyncEmitter.createAndStart("mycollector.com") val tracker = new Tracker(List(emitter), "mytracker", "myapplication")

We will now send an unstructured event with a custom context attached. We can create the JSONs for the event using the json4s DSL:

import org.json4s.JsonDSL._ val productViewEvent = SelfDescribingJson( "iglu:com.acme/product_view/jsonschema/1-0-0", ("userType" -> "tester") ~ ("sku" -> "0000013") ) val pageTypeContext = SelfDescribingJson( "iglu:com.acme/page_type/jsonschema/1-0-0", ("type" -> "promotional") ~ ("backgroundColor" -> "red") ) tracker.trackUnstructEvent(productViewEvent, List(pageTypeContext))

Please check out the Scala Tracker Technical Documentation on the Snowplow wiki for the tracker’s full API.

3. Getting help

The Scala Tracker is of course very young, with a much narrower featureset than some of our other trackers – so we look forward to community feedback on what new features to prioritize. Feel free to get in touch or raise an issue on GitHub!

More about
the author

Avatar
Snowplow Team
View author

Ready to start creating rich, first-party data?

Image of the Snowplow app UI