var client = new SidLeeClient('http://dashboard.sidlee.com/', function(data) {
console.log(data);
});
The function passed as a callback will be called each time a new event is received.
client.today().exec(function(data) {
console.log(data);
});
data
returns an aggregated view of the events of the current day (6am to 6am):
[
{
"_id": "visits",
"value": 2
},
{
"_id": "likes",
"value": 86818
},
{
"_id": "undo",
"value": 160,
"date": "DATE_OF_LAST_EVENT",
"app": "my app",
"user": "user"
}
]
For each sensors, and APIs, the client returns an object containing the name of the event and a value, which can be a sum or an average, according to the sensor configuration. The undo
event is a particular one since it also returns the last undo
event (date
, app
and user
).
The list of the sensors and APIs is available here.
client.last24().exec(function(data) {
console.log(data);
});
data
returns an object containing an aggregated view of the events that happened during the last 24h. The events are sorted by hour ranges.
[
{
"_id": "red",
"values": [
{
"hourAgo": 0,
"value": 1
},
{
"hourAgo": 12,
"value": 5
},
{
"hourAgo": 17,
"value": 14
},
{
"hourAgo": 18,
"value": 2
},
{
"hourAgo": 21,
"value": 12
},
{
"hourAgo": 22,
"value": 2
}
]
},
...
]
It returns a sum or an average, hour by hour. In the example, 1 "red" event happened in the running hour, 5 "red" event happened 12h ago, and so on.
client.last30().exec(function(data) {
console.log(data);
});
Similar to last 24, but the sum or average is a daily one: hourAgo
becomes dayAgo
.
It' a fluent interface API, so don't forget to call exec
in order to execute the request!
A jsfiddle: http://jsfiddle.net/07acad0b/6/