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

sentret

v0.0.7

Published

Declarative User Click Tracking

Downloads

3

Readme

   

When doing client side analytics, you'll be tracking UI and programmatic events. Sentret helps you with the UI events.

Declarative usage

<div>
  <span>What would you like to buy?</span>

  <!-- We declare events as data attributes (configurable) -->
  <button data-event="SELECTED_BANANA">Banana (green)</button>
  <button data-event="SELECTED_BANANA" data-properties='{"ripe": true}'>
    Banana (ripe)
  </button>

  <button data-event="CHECKOUT" data-properties='{"from": "products-page"}'>
    Checkout
  </button>
</div>

Reminders

data-* attributes can only ever be strings. When using a data binding framework like Vue or React, make sure to convert any objects to JSON for data-properties

And the setup

import {Sentret} from 'sentret'

// Our sample stack uses Segment (analytics.js) to ship events to the
// server, so we can plug it in directly as the handler
Sentret({log: true}).on('event', analytics.track)

Supported Options

{
  log: true,
  eventAttribute: 'event', // data-event
  propertiesAttribute: 'properties' // data-properties
}

Methods

Documentation is in TypeScript for clarity. Typescript is not required

interface SentretInstance {
  // Listen for UI events
  on: (eventType: 'event', cb: SentretClickCallback) => void

  // Sometimes components from poorly written external libraries don't
  // propagate clicks. In such cases you may forward them to Sentret using
  // this method
  click: (event: MouseEvent) => void

  // If your workflow requires it, you may destroy this Sentret instance
  // which will clean up any event listeners on the DOM
  destroy: () => void
}

// The UI event callback should accept an event name and a data object
type SentretClickCallback = (eventName: string, data?: object) => any