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

@trkm/library-web

v0.1.0

Published

Places the tracking magic library and interface into the globalThis.trkm root.

Downloads

5

Readme

@trkm/library-web

Exposes the tracking magic library in the browser along with defaults.

Features

Usage

In the following example, the context of the webpage is stored in a session (trkm.session.merge(trkm.context())). The url parameter userName, if provided, is maintained between webpages.

<head>
  <!-- We don't recommend using github as a CDN. This is just for the example code-->
  <script src="./dist/bundle.js"></script>
  <title>Example Tracking Page</title>
</head>

<body>
<head>
  <!-- We don't recommend using github as a CDN. This is just for the example code-->
  <script src="./dist/bundle.js"></script>
  <title>Example Tracking Page</title>
</head>

<body>
  <form id='example_form'>
    <input id="document_title" />
    <input id="user_name" />
  </form>
  <script>
    // Persist the current page context into the session. This helps us capture
    // http parameters on a landing page which can be used later.
    trkm.session.merge(trkm.context());

    // setup a mapping between the page context and a form on the web page.
    const contextToFormMap = {
      formQuery: {
        tag: 'form',
        name: 'id',
        value: 'example_form'
      },
      destination: [
        {
          // pull a value from document.title
          pullFrom: {
            source: {
              type: 'context',
              jsonPath: 'document.title'
            }
          },
          // Find an input tag on the form using attribute name and the value
          destination: {
            tag: 'input',
            name: 'id',
            value: 'document_title'
          }
        },
        {
          pullFrom: {
            required: false,
            source: {
              type: 'context',
              jsonPath: 'document.url.urlParams.userName'
            }
          },
          destination: { value: 'user_name' }
        },
      ]
    };

    // At anytime, we can apply the mapping. formApply will find the
    // HTMLFormElement on the page 
    trkm.formApply(contextToFormMap, trkm.session.get());

  </script>
  <p>The form field should contain the title of the page.</p>
</body>

Development

See the monorepo readme.

License

Licensed under MIT.