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

@teachable/iris

v2.3.0

Published

`Iris` is a framework agnostic library for dynamically attaching event handlers to DOM elements and sending those events to an upstream source.

Downloads

704

Readme

Iris is a framework agnostic library for dynamically attaching event handlers to DOM elements and sending those events to an upstream source.

Installation

yarn add @teachable/iris

Developing

For development, a package can be linked into another project. This is often useful to test out new features or when trying to debug an issue in a package that manifests itself in another project.

Yarn

Yarn creates the symlink for Iris to be used in other repos i.e. Fedora. When you are finished, make sure you unlink Iris.

yarn link
yarn build # Must be performed for changes to take effect
yarn unlink

Init

Once initialized, Iris automatically attaches itself to window.iris to make itself globally accessible.

import { iris } from '@teachable/iris'

iris.init({
  selector: 'my-selector',
  source: 'my-app',
  noun: 'my-id-key',
  noun_id: 'my-id-value',
  url: 'my-url'
})

Please keep properties snake_cased.

| Property | Description | |----------|---------------------------------------------------------------| | selector | This is the root element that Iris will watch for changes. | | source | Resource for your events. e.g. https://my-api.com/${source} | | noun | Name or type of identifier being sent. | | noun_id | Value of the identifier. | | url | The URL to POST data to. |

Usage

There are 3 possible ways for Iris to send data upstream.

HTML

Iris will automatically detect any new elements that are added to and attach itself to those elements if the iris attribute is present. Iris will automatically remove all iris-* attributes from the element once it's attached itself.

<div
  iris
  iris-event="click"
  iris-verb="User clicked the button"
  iris-meta-foo="bar"
  iris-meta-fizz="bang"
>Click Me!</div>

Currently, the only supported DOM event is click. More will be added as needed in the future.

Manual Attachment

It's also possible to attach iris programmatically. It's important to note that this is a lower level Iris API method. Once this element is removed from the DOM it's up to you to re-attach to it if it's inserted back in.

import '@teachable/iris'

const myElement = document.querySelector('my-element')

iris.attach(myElement, 'click', 'My Event', { foo: 'bar', meta: 'data' })

Forced Emit

Iris also exposes the emit method. This is especially useful for sending events for non-user actions, such as page load.

import '@teachable/iris'

iris.emit('My Event', { foo: 'bar', meta: 'data' })

Anonymous User Tracking

The Iris JS client automatically tracks anonymous user ids via the _afid cookie, which is simply a UUID. If the cookie is not currently set in the browser, Iris will generate one when it initializes and store it in the browser cookie. Use this cookie for tracking users in a funnel from an anonymous (pre-authenticated) to an identified (post-authenticated) state.

This cookie can be used for Mixpanel tracking purposes. Simply set the noun_id for the emitted event(s) to the _afid cookie, and Mixpanel will assign all events to that distinct ID.

Todo

[x] Actually send API calls...

[x] Plain JS helper functions

[ ] AngularJS directive

[ ] React higher order component