Snowplow Node.js Tracker 0.2.0 released


Version 0.2.0 of the Snowplow Node.js Tracker is now available! This release changes the Tracker’s architecture and adds the ability to send Snowplow events via either GET
or POST
.
Read on for more information…
1. Emitters
This release brings the Node.js Tracker’s API closer to those of other trackers with the addition of Emitters, objects which control how and when the events created by the Tracker are sent to the Snowplow collector. A Tracker object can be configured with one or more Emitters, and sends each event to all Emitters associated with it. This enables you to send events to multiple endpoints, like this:
var snowplow = require('snowplow-tracker'<span class="p">); var tracker = snowplow.tracker<span class="p">; var emitter = snowplow.emitter<span class="p">; var cloudfrontEmitter = emitter( 'drw9087ef0wer.cloudfront.net', // Cloudfront collector 'http', // Protocol null, // No port required for the Cloudfront collectr 'GET' // Method <span class="p">); var kinesisEmitter = emitter( 'myscalastreamcollector.net', // Cloudfront collector 'http', // Optionally specify the method - defaults to http 8080, // Optionally specify a port 'POST', // Method - defaults to GET 10, // Only send events once 10 are buffered function (error, body, response) { // Callback if (error) { console.log("Request to Scala Stream Collector failed!"<span class="p">); } } <span class="p">); var dualTracker = tracker([cloudfrontEmitter, kinesisEmitter], 'exampleTracker', 'myApp'<span class="p">); dualTracker.trackPageView('http://www.example.com'<span class="p">); kinesisEmitter.flush<span class="p">();
This example creates 2 emitters. The first sends events one at a time to a Cloudfront Collector using GET; the second batches up events until it has 10, then sends them to a Scala Stream Collector using POST. We only fire a single event in the example, so to make the second emitter send its batch it is necessary to explicitly call the flush
method.
Note also that the callback argument to the tracker
function is now an argument to the emitter
function instead.
2. Vagrant quickstart
We have added a Vagrant quickstart to the project. If you have VirtualBox and Vagrant installed, you can now easily set up a Snowplow Node.js Tracker development environment:
git clone [email protected]:snowplow/snowplow-nodejs-tracker.git cd snowplow-nodejs-tracker vagrant up vagrant ssh cd /vagrant npm install npm test
3. Getting help
For more detailed information, check out the technical documentation.
If you find any bugs with the Node.js Tracker, please create a GitHub issue.
Finally, if you need help getting set up or want a new feature, please [get in touch] [talk-to-us].