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

eventpouch

v0.0.1

Published

eventpouch ==========

Downloads

1

Readme

eventpouch

Simple instrumentation tool for HTML5 web apps.

With the onmipresent idea of offline first, eventpouch is a javascript library that will help developers to know how their app is behaving, by keeping track of how the app is used and possible javascript errors.

Developers need to know how users are interacting with their application, to check if new features are having a good impact, also knowing if the app is generating unexpected javascript errors is key to provide users with regular updates.

offline first

eventpouch has been built in top of PouchDB and CouchDB working in the following way:

  • All events registered will be stored in 2 local PouchDB databases:
    • session: where the events happening in a current session are stored.
    • history: containing all previous session events.
  • The information could be sync to a remote CouchDB database
    • when configuring eventpouch we can setup the history database to be sync with an external CouchDB instance.

What is logged?

By default eventpouch will store the following information:

  • register even: will happen just once, first time is used and will create a json object containing app version (can be specified in the configuration, Firefox OS is supported so eventpouch can get the version automatically), and random generated uuid.
  • start session event: each time eventpouch is initialised a new event containing a session identifier.
  • end session event: eventpouch will record when a document is unloaded. For single document webapps this is usually when the app is closed.
  • javascript errors: any uncaught javascript error will be stored containing the line and javascript file that generated the error.

Also each developer can decide what to log, eventpouch provides a function to add custom events with the desired payload (in json format). An example of this:

logger.logEvent('redButtonPressed', {currentValue: 1});

Getting eventpouch

During eventpouch build process all the dependencies needed are downloaded and dispatched, that's the case of PouchDB, which version used is downloaded and bundled into a single file.

To get the latest version just:

git clone https://github.com/arcturus/eventpouch
cd eventpouch
npm install
grunt

This will create the following file:

./dist/eventpouch-<version>.min.js

ready to be used in your projects.

Using eventpouch

Without external sync

var eventpouch = require('eventpouch');

var logger = new eventpouch({}, function onReady() {
    // Optional
    // Initalised and start session event already recorded
});
...
logger.logEvent('redButtonPressed');

With external sync

var eventpouch = require('eventpouch');

var logger = new eventpouch({
    'remoteSyncHost': 'https://mycouchdbdomain.com/mydb',
    // Sync after X seconds to avoid several ops at once
    'syncAfter': 5,
    // Optional, if not present will be inferred
    'appVersion': '1.0.3'
}, function onReady() {
    // Optional
}, function onSyncDone() {
    // Optional, callback called once the sync between
    // current history db and external CouchDB happened.
});

When syncing remotely, CouchDB must be configured to accept CORS request, a good practice here is to setup an unique allowed origin, your web app origin.

Example

You can find a simple webapp example on the code (folder example), just run

grunt open-example

This example will allow you to generate events to be logged and dump the content of the local databases to check what's saved.

Build status

Status

TODO

Now we need to create a CouchDB app, that will be visualising the information that we sync from the client. Next project to be announced :)

License

Apache 2.0 (see LICENSE)