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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@heuric/web-sdk

v1.0.0

Published

Easy setup SDK for tracking user interactions

Downloads

11

Readme

Heuric Web SDK

A lightweight, drop-in UX analytics SDK that automatically captures user interactions (clicks and scrolls) and sends them to your backend in clean, privacy-focused batches.

Installation

Install the package via npm:

npm install @heuric/web-sdk

Alternative Local Installation

  1. Download the repository.
  2. Run npm install and then npm run build.
  3. Copy the resulting dist/heuric.esm.js file into your own project (e.g., src/lib/heuric.esm.js).

Usage and Setup

1. Initialise the SDK

Initialise the SDK once in your application's root component or layout.

For Next.js / React (App Router): Create a client component (Tracker.tsx):

"use client";

import { useEffect } from "react";
import { initHeuric } from "@heuric/web-sdk"; // or "@/lib/heuric.esm.js" if using local installation

export default function HeuricTracker() {
  useEffect(() => {
    initHeuric({
      endpoint: "https://your-api.com/webhooks/events",
      projectId: "your-project-id",
      // Optional: flushInterval: 5000, 
      // Optional: flushThreshold: 20
    });
  }, []);

  return null;
}

2. Add to your Root Layout

Add the <HeuricTracker /> component into your main layout so it runs on every page:

import HeuricTracker from "./components/HeuricTracker";

export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <body>
        <HeuricTracker />
        {children}
      </body>
    </html>
  );
}

3. Setup Supabase Database Table

To actually catch and store the data your SDK captures, you need a database table mapped to the specific JSON payload.

  1. Create a project on Supabase.
  2. Open the SQL Editor in your Supabase dashboard.
  3. Run the SQL schema in supabase/schema.sql to create your events table. (We use JSONB columns so you can change the payload later without breaking your database).

4. Deploy the Ingestion API

The SDK cannot communicate directly to your database securely. So I have provided a pre-configured Supabase Edge Function that handles CORS and safely inserts the data.

  1. Install the Supabase CLI and log in.
  2. Open your terminal in the project's root folder and link this folder to your Supabase project:
    # You can find the project-ref in your Supabase dashboard URL
    supabase link --project-ref <your-project-ref>
  3. Deploy the ingestion function (note: this bypasses JWT checks so the public SDK can freely send data):
    supabase functions deploy collect
  4. Retrieve the endpoint URL from the dashboard and use it to update your endpoint from Step 1. The link will be given to you in the terminal (e.g. https://supabase.com/dashboard/project//functions).

5. View Your Live Data

That's it! Your UX tracker is now fully operational. As users interact with your application, you will immediately see live UX analytics data populate the events table inside your Supabase dashboard.


Privacy, Security and Performance Defaults

By default, the SDK heavily prioritises user privacy:

  • Password and hidden inputs are strictly ignored.
  • Credit Card inputs (autocomplete="cc-*") are ignored.
  • Emails and Numbers inside clicked text are scrubbed and replaced with [EMAIL] and [NUMBER] before being sent to your database.
  • Elements with the .heuric-ignore class are completely ignored by the click tracker.
  • The SDK uses navigator.sendBeacon with text/plain blobs to bypass aggressive CORS preflights, ensuring your event batches arrive safely even on cross-origin requests.

Testing Locally

If you want to quickly test how the SDK behaves without installing it in a full React application, we provide a standalone test playground.

  1. Start a local server in the project root (try python3 -m http.server 3456 because browsers usually block modules from loading with file:// protocol).
  2. Open http://localhost:3456/test.html in your browser.
  3. At the bottom of the file, replace the endpoint with a testing webhook (like Webhook.site) (or just right-click > Inspect Element > Network).
  4. Click around the page, scroll down, and watch your webhook site or browser's Network tab for POST requests.