Code Monkey home page Code Monkey logo

sidleeagenceconnectee's Introduction

Build Status Test Coverage

Using the JS api

Connect a client:

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.

Request the events of the day

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.

Request the events of the last 24h

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.

Request the events of the last 30 days

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/

sidleeagenceconnectee's People

Contributors

xseignard avatar dbismut avatar

Watchers

James Cloos avatar Miro avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.