Giter Site home page Giter Site logo

afrostream-api-stats's Introduction

afrostream-api-stats

nodejs api for the stats

Install

npm install
npm test

API

POST /api/v1/events

evenement bandwidthIncrease

{
  "user_id" : number (integer positive),
  "type" : 'bandwidthIncrease',
  "fqdn" : string (max 255),
  "video_bitrate" : number (integer),
  "audio_bitrate" : number (integer)
}

evenement bandwidthDecrease

{
  "user_id" : number (integer positive),
  "type" : 'bandwidthDecrease',
  "fqdn" : string (max 255),
  "video_bitrate" : number (integer),
  "audio_bitrate" : number (integer)
}

evenement buffering

{
  "user_id" : number (integer positive),
  "type" : 'buffering',
  "fqdn" : string (max 255)
}

evenement error

{
  "user_id" : number (integer positive),
  "type" : 'error',
  "fqdn" : string (max 255),
  "number": number (small integer),
  "message": string (max 255)
}

evenement start

{
  "user_id" : number (integer positive),
  "type" : 'start',
  "fqdn" : string (max 255),
  "os": string (max 255),
  "os_version": string (max 64),
  "web_browser": string (max 255),
  "web_browser_version": string (max 64),
  "resolution_size": string (max 32),
  "flash_version": string (max 32),
  "html5_video": boolean,
  "relative_url": string (max 255),
}

evenement stop

{
  "user_id" : number (integer positive),
  "type" : 'stop',
  "fqdn" : string (max 255),
  "timeout": boolean,
  "frames_dropped": number (integer)
}

event ping

{
  "user_id" : number (integer positive),
  "type" : 'ping',
  "fqdn" : string (max 255)
}

POST /api/v1/send

bulk send (non rest)

{
  "events": [
    @see event list
  ]
}

example

{
  "events": [
    {
      "user_id" : number (integer positive),
      "type" : 'start',
      "fqdn" : string (max 255),
      "os": string (max 255),
      "os_version": string (max 64),
      "web_browser": string (max 255),
      "web_browser_version": string (max 64),
      "resolution_size": string (max 32),
      "flash_version": string (max 32),
      "html5_video": boolean,
      "relative_url": string (max 255),
    },
    {
      "user_id" : number (integer positive),
      "type" : 'bandwidthIncrease',
      "fqdn" : string (max 255),
      "video_bitrate" : number (integer),
      "audio_bitrate" : number (integer)
    },
    {
      "user_id" : number (integer positive),
      "type" : 'buffering',
      "fqdn" : string (max 255)
    }
  ]
}

Testing

Warning: current integration tests are using the local development database.

all

npm test

single test

node_modules/.bin/mocha test/integration/api/alive.js

CURL

curl -v --data '{"type":"ping","user_id":4242,"fqdn":"foo.com"}' -H "Content-Type: application/json" http://localhost:3003/api/v1/events/
curl -v --data '{"type":"bandwidthIncrease","user_id":4242,"fqdn":"foo.com","relative_url":"/foo/bar","video_bitrate":4242,"audio_bitrate":4243}' -H "Content-Type: application/json" http://localhost:3003/api/v1/events/
curl -v --data '{"type":"start","user_id":4242,"fqdn":"foo.com","relative_url":"/foo/bar","video_bitrate":4242,"audio_bitrate":4243,"os":"ubunion":"14.04","web_browser":"curl","web_browser_version":"1","resolution_size":"640x480","flash_version":"7","html5_video":true}' -H "Content-Type: application/json" http://localhost:3003/api/v1/events/

afrostream-api-stats's People

Contributors

syndr0m avatar

Watchers

 avatar  avatar  avatar

afrostream-api-stats's Issues

cannot reconnect when mq is down

lorsque la mq est restart (down puis up), l'appel amqp.connect('amqp://rabbitmq-1.adm.afrostream.net', function () { }); sort en erreur

2015-12-21T09:43:52.865043+00:00 app[web.1]: middleware mq: cannot connect to mq  { [Error: connect ECONNREFUSED]
2015-12-21T09:43:52.865045+00:00 app[web.1]:   code: 'ECONNREFUSED',
2015-12-21T09:43:52.865046+00:00 app[web.1]:   errno: 'ECONNREFUSED',
2015-12-21T09:43:52.865047+00:00 app[web.1]:   syscall: 'connect' }
2015-12-21T09:43:52.865081+00:00 app[web.1]: middleware mq: try to reconnect in 10sec.
2015-12-21T09:43:52.909045+00:00 app[web.1]: middleware mq: cannot connect to mq  { [Error: connect ECONNREFUSED]
2015-12-21T09:43:52.909048+00:00 app[web.1]:   code: 'ECONNREFUSED',
2015-12-21T09:43:52.909049+00:00 app[web.1]:   errno: 'ECONNREFUSED',
2015-12-21T09:43:52.909055+00:00 app[web.1]:   syscall: 'connect' }

gist : https://gist.github.com/syndr0m/a586e50e7581a7d9b947

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.