npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

keen-event-client

v1.0.2

Published

Simple wrapper for the Keen.io events resource.

Downloads

3

Readme

keen-event-client

A lightweight wrapper for dealing with the Keen.io event API.

Although Keen.io has an extensive JS SDK, I experienced problems using it on the Tessel 1 board.

Install with:

npm install keen-event-client

Usage

var keen = require('keen-event-client');

var client = keen.createClient({
  projectId: 'YOUR_PROJECT_ID',
  writeKey:  'YOUR_WRITE_KEY',
  masterKey: 'YOUR_MASTER_KEY'
});
var event = {
  temp: 74.89,
  rh: 52.17
};

keen.addEvent('climate', data, function(err, data, res) {
  if (err) {
    // there was an error!
  } else {
    // success: return value, if any, is in the data argument.
  }
});

API

All callbacks are called with arguments err, data, res.

  • err is the error object, if any, otherwise null.
  • data is the object deserialized from JSON that was returned by the keen.io API. This may be null if the request did not return data.
  • res is the response object itself.

keen.createClient(options)

Returns an object initialized with the supplied options object. All operations performed by the instance of the client are against the keen.io project specified by options.projectId and will use the keys specified by options.writeKey or options.readKey.

Required:

  • projectId keen.io project ID
  • writeKey keen.io write key
  • masterKey keen.io master key

Optional:

  • urlBase defaults to https://api.keen.io
  • version defaults to 3.0

keen.addEvent(collection, event, callback)

Inserts a single event into the specified collection.

Example event:

{
  temp: 72.34,
  rh: 58.83
}

keen.addEvents(events, callback)

Inserts multiple events into one or more collections. events should be an object with properties, which are the names of collections. The values of these properties should be arrays of objects, which are the events.

events example:

{
  climate: [{
    temp: 72.34,
    rh: 58.83
  }, {
    temp: 71.59,
    rh: 57.96
  }],
  ambient: [{
    soundLevel: 0.43,
    lightLevel: 0.39
  }]
}

keen.getEvent(collection, callback)

Returns the schema information for the collection.

data example:

{
  properties: {
    temp: 'num',
    rh: 'num'
  }
}

keen.getEvents(callback)

Returns the schema information for all collections in the project specified by options.projectId.

data example:

[
  {
    name: 'climate',
    url: '/3.0/projects/YOUR_PROJECT_ID/events/climate',
    properties: {
      'client.id': 'string',
      'client.created_at': 'datetime',
      temp: 'num',
      rh: 'num'
    }
  }, {
    name: 'ambient',
    url: '/3.0/projects/YOUR_PROJECT_ID/events/ambient',
    properties: {
      'client.id': 'string',
      'client.created_at': 'datetime',
      soundLevel: 'num',
      lightLevel: 'num'
    } 
  }
]

License

MIT