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

@unisights/analytics

v0.0.13

Published

Unisights browser event tracking script

Readme

Unisights analytics

The Unisights analytics is a WebAssembly-powered analytics tracker built with Rust and TypeScript. It captures user interactions in the browser, encrypts data client-side, and sends it securely to your ingestion service — with minimal performance impact.


✨ Why Unisights

  • WASM Performance — Rust-compiled WASM offers faster execution and lower overhead than traditional JS trackers
  • Client-Side Encryption — Data is encrypted in the browser before it ever leaves the client
  • Lightweight — ~86KB gzipped, including WASM binary and web vitals tracking
  • Web Vitals Built-in — Automatically tracks CLS, INP, LCP, FCP, and TTFB
  • SPA Ready — Handles pushState, replaceState, and popstate for React, Next.js, Vue, etc.

📦 Installation

npm install @unisights/analytics
# or
pnpm add @unisights/analytics
# or
yarn add @unisights/analytics

🚀 Usage

Option 1 — CDN / Script Tag (Recommended)

Add the script tag to your HTML <head>. The SDK auto-initializes and exposes window.unisights.

<script
  type="module"
  id="unisights-script"
  async
  data-insights-id="your-insights-id"
  src="https://cdn.jsdelivr.net/npm/@unisights/[email protected]/dist/unisights.min.js"
></script>

data-insights-id - Your Unique Insights Identifier for the website or application.

Then use it anywhere in your app:

// Wait for SDK to be ready
window.unisights?.init();

// Log a custom event
window.unisights?.log("signup", { plan: "pro" });

// Flush events immediately
window.unisights?.flushNow();

// Register a custom event handler
const track = window.unisights?.registerEvent("click", (e) => {});
track("button_click", { id: "submit-btn" });

Usage in React / Next.js

import { useEffect } from "react";

export default function Layout({ children }) {
  useEffect(() => {
    const script = document.getElementById(
      "unisights-script",
    ) as HTMLScriptElement;

    const initSDK = () => {
      window.unisights?.init().catch(console.error);
    };

    if (window.unisights) {
      initSDK();
    } else {
      script?.addEventListener("load", initSDK);
      return () => script?.removeEventListener("load", initSDK);
    }
  }, []);

  return <>{children}</>;
}

Option 2 — Manual Init (Script Tag)

If you prefer to control when the SDK initializes, omit data-insights-id and call init() manually:

<script
  type="module"
  id="unisights-script"
  async
  data-insights-id="your-insights-id"
  src="https://cdn.jsdelivr.net/npm/@unisights/[email protected]/dist/unisights.min.js"
></script>

<script type="module">
  await window.unisights.init({
    endpoint: "https://your-ingestion-endpoint.com/collect",
    debug: false,
  });
</script>

⚙️ Configuration

All options are passed to init() or via data-analytics-config on the script tag.

| Option | Type | Default | Description | | ----------------- | --------- | ------- | ------------------------------- | | endpoint | string | env var | URL to send analytics events to | | debug | boolean | false | Log events to the console | | flushIntervalMs | number | 15000 | How often to flush events (ms) | | trackPageViews | boolean | true | Auto-track page views | | trackClicks | boolean | true | Auto-track click events | | trackScroll | boolean | true | Auto-track scroll depth |


🧩 API Reference

window.unisights.init(config?)

Initializes the SDK. Must be called before using other methods if auto-init is disabled.

await window.unisights.init({
  endpoint: "https://your-endpoint.com/collect",
  debug: true,
});

window.unisights.log(name, data)

Log a custom event with optional metadata.

window.unisights.log("purchase", {
  item: "pro-plan",
  amount: 49.99,
  currency: "USD",
});

window.unisights.flushNow()

Immediately send all buffered events to the endpoint.

window.unisights.flushNow();

window.unisights.registerEvent(eventType, handler)

Register a DOM event listener and get back a function to log custom events.

const track = window.unisights.registerEvent("click", (e) => {
  console.log("click captured", e);
});

// Later, log an event tied to this listener
track("cta_click", { label: "Get Started" });

🏗 TypeScript Support

The package ships with type declarations. If you use the SDK via script tag and want window.unisights typed in your TypeScript project, install the package for types only:

npm install @unisights/analytics

TypeScript will automatically pick up the Window augmentation — no extra configuration needed.

// Fully typed — no @ts-ignore needed
window.unisights?.log("event", { data: "value" });

📜 License

MIT — see LICENSE for details.