keen-js learns to node.js
This library now runs in the browser and the server, and can be installed via npm:
$ npm install keen-js
http://d26b395fwzu5fz.cloudfront.net/3.2.0/keen.min.js
http://d26b395fwzu5fz.cloudfront.net/3.2.0/keen.js
New to keen-js
client.addEvents
- record multiple events with a single API call (#108)client.addEvent("collection", data, null, false)
- fourth argument offalse
invokes a synchronous XHR call, which is useful for sending events before a page unloads (#188)client.get
- execute a generic GET request (New approach to #139)client.put
- execute a generic PUT requestclient.post
- execute a generic POST requestclient.del
- execute a generic DELETE request (server-only)Keen.utils.encryptScopedKeys
- create a new scoped key (server-only)Keen.utils.decryptScopedKeys
- decrypt an existing scoped key (server-only)Keen.noConflict
– avoid version collisions (#159)Keen.Request
object supports timeouts (explained below), and must be explicitly run with.refresh()
(#209, wip)- "Metric" visualization shows raw value via the HTML element's
title
attribute (#206, wip)
var req = new Keen.Request(client, [query1, query2], callback)
.timeout(300*1000)
.refresh();
Keen.Visualization has been removed
This object doesn't add any value, and only creates more surface-area for new users to reason about.
Check out Keen.Dataviz
for building customized visualizations. The docs have been updated to reflect this object's departure, and .run still works as expected.
Breaking change to all callback signatures
All callbacks now use the single function (err, res)
callback pattern common to node.js. This was done to make implementations portable between the browser and the server.
This:
client.run(query, function(res){
// handle response
}, function(err){
// handle error
});
Now looks like this:
client.run(query, function(err, res){
// if (err) handle err
// handle response
});
Build/test-related
- Switched from grunt to gulp
- Browserify builds browser-specific versions of the library
- Karma runs tests on local browsers (Chrome, FF, Safari)
- SauceLabs testing tests IE + mobile