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

seismo-client

v0.0.5

Published

Seismo node.js client

Downloads

10

Readme

Seismo Node.js / Express.js client

Installation

seismo-client available in npm,

$ npm install seismo-client

Development

Clone git repository,

$ git clone https://github.com/seismolabs/seismo-node-client.git

Clone seismo server and make sure all prereqisits installed,

$ git clone https://github.com/seismolabs/seismo.git

Start seismo server in test mode,

$ NODE_ENV="test" node source/server.js

Run tests,

$ npm test

Create client and post events

This is a small example of seismo-client usage:

var seismo = require('seismo-client');

// create analytics client, by providing app id
var events = seismo('my-web-app');

// call function, with the name of event
events('application started');
// provide event id (optional, but suitable for fetching data)
events({id: 'app-start', event: 'application started'});
// provide additional payload (optional, but usefull for sophisticated analysis)
events('application stated', {environment: process.env.NODE_ENV});
// or ..
events({id: 'app-start', event: 'application started'}, {environment: process.env.NODE_ENV});

// provide callback (optional)
events('application started', function (err) {
	console.log('event posted on server');
});

Scenarios for web (express.js) application:

var express = require('express');
var seismo = require('seismo');
var app = express();

// create analytics client, by providing app id
var events = seismo('my-web-app');

var eventsMiddleware = function (event, data) {
	return function (req, res, next) {
		events(event, data, next);
	}
}

app.get('/login',
	eventsMiddleware('user login request'),
	renderLogin
);

app.post('/login',
	checkCredentials,
	eventsMiddleware('user logged on'),
	redirectToApp
);

app.get('/search', function(req, res) {
	var query = req.query['q'];
	search.run(query, function (err, results) {
		events('search executed', {query: query, time: results.timeTakes});
		res.json(results.data);
	});
})

Querying for results

You can query server for data you application collected.

var seismo = require('seismo');
var events = seismo('my-web-app');

// query all collected events
events.query(function (err, results) {
	console.log(results);
});
// query by event name
events.query('search executed', function (err, results) {
	console.log(results);
});
// query by event type
events.query({id: 'app-start'}, function (err, results) {
	console.log(results);
});

For convenience, you can request data by certain date.

var analytics = require('analytics');
var events = analytics('my-web-app');

// query all collected events for today
events.query({date: 'today'}, function (err, results) {
	console.log(results);
});
// query all collected events for particular day
events.query({date: '2014-09-26'}, function (err, results) {
	console.log(results);
});
// query all collected events for particular, for event name
events.query({event: 'search executed', date: '2014-09-26'}, function (err, results) {
	console.log(results);
});
// query all collected events for particular, for event type
events.query({id: 'app-start', date: '2014-09-26'}, function (err, results) {
	console.log(results);
});

Reports

In order, to build dashboard application, there are number of ready to use reports.

// report all events by hour
events.report({event: 'application started', report: 'hour', date: '2013-09-29', hour: 6}, function (err, summary) {
	console.log(summary);
});
// report all events by day
events.report({event: 'application started', report: 'day', date: '2013-09-29'}, function (err, summary) {
	console.log(summary);
});
// report all events by week
events.report({event: 'application started', report: 'week', date: '2013-09-29'}, function (err, summary) {
	console.log(summary);
});
// report all events by month
events.report({event: 'application started', report: 'month', date: '2013-09-29'}, function (err, summary) {
	console.log(summary);
});
// report all events by period
events.report({event: 'application started', report: 'period', from: '2013-09-10', to: '2013-09-13'}, function (err, summary) {
	console.log(summary);
});

Summary object contains totals,

{
	id: 'app-started',
	event: 'application started',
	total: 224
}

License

MIT