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

app-user-events

v1.1.1

Published

A way to store, retrive, and trigger app user events

Downloads

6

Readme

app-user-events

A way to store, retrive, and trigger app user events.

Be careful with user events. This form the base for triggering a workflow.

Module Usage

Install

npm install app-user-events

Require and config

var events = require('app-user-events')('http://localhost:5984/app-user-events')

Posting events

var data = {name: 'Ryan', awesome: true}
events.post('space', 'userid', 'E38293', data)
events.post('space', 'userid', 'E38293', ['showing-request'], data)

Query events

events.query('space').stream()
events.query('space').by_user('userid').stream()
events.query('space').by_event('E38293').stream()
events.query('space').by_user_event('userid', 'E38293').stream()
events.query('space').by_user_event_tag('userid', 'E138329', 'request-showing').stream()

Add some couch options

events.query('space')
  .addQueryOpts({limit:1}) // add traditional couchdb query params
  .stream()

events.query('space')
  .by_user_event('38329823', 'login')
  .addQueryOpts({limit:3})
  .stream()

Settup Triggers

// trigger on a login
var conditions = {
  event: 'login'
}

// trigger on tags in an OR condition
conditions = {
  tagsOR: ['star', 'like']
}

// trigger on tags in an AND condition
conditions = {
  tagsAND: ['login', 'evening']
}

// trigger running through a module that is hotloaded
conditions = {
  module: 'app-user-events-conditions-validatejs',
  constraints: { // module is a declaritve object validator that uses this json
    awesome: {equality: true}
  }      
}

// trigger with one of these tags AND the module validation
conditions = {
  tagsOR: ['tag1', 'tag2'], // only trigger OR of these tags
  module: 'app-user-events-conditions-validatejs',
  constraints: { // module is a declaritve object validator that uses this json
    awesome: {equality: true}
  }
}

// specify the module to use when the trigger fires
var on_trigger = {
  module: 'app-user-events-hook-webhook',
  config: {
    url: 'http://salesforce.com/newPerson',
    headers: { 
      accessToken: 'dasdsadsasdaas' 
    }
  }
}

events.createTrigger('space', 'category', 'triggerName', conditions, on_trigger, function(err, success){
  success._id
  events.removeTrigger(success._id, function(err){
    
  })
})

Command Line Usage

Install

npm install app-user-events

Config. We use the rc configuration. The only required option is database which by default is http://localhost:5984/app-user-events

Post examples

post to space=timeline, event=E21221, user_id=1, tags=[star]

> app-user-events post timeline 1 E21221 star

post to space=timeline, event=E21221, user_id=1, with data from a json file

> app-user-events post timeline 1 E21221 -f ~/data/something.json

Query examples

All events in the timeline space

> app-user-events query timeline 

Add couch options, like limit

> app-user-events query timeline  -c limit=1

Query by_user=1

> app-user-events query timeline -q by_user 1

Query by_user = 1 with event = E21221

> app-user-events query timeline -q by_user_event 1 E21221

Query by_user = 1 with event = E21221, tagged star

> app-user-events query timeline -q by_user_event_tag 1 E21221 star

Query by_event=E21221, all users

> app-user-events query timeline -q by_event E21221

Create a trigger

> app-user-events createTrigger timeline property show-me-stars --conditions.tagsOR star --on_trigger.module app-user-events-hook-webhook

Create a trigger

> app-user-events createTrigger timeline users logins --conditions.event login --on_trigger.module app-user-events-hook-webhook

Create a trigger

> app-user-events createTrigger timeline users evening-logins --conditions.event login --conditions.tagsOR evening --on_trigger.module app-user-events-hook-webhook

License

MIT