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

nudgekit-analytics

v0.6.0

Published

Privacy-light web analytics for NudgeKit with tracking, heatmaps, replay, and a live visitors widget.

Downloads

1,870

Readme

nudgekit-analytics

Privacy-light web analytics for NudgeKit. Drop-in tracking plus an optional public live-visitors widget.

Events are sent to https://api.nudgekit.app — no API URL configuration needed.

Install

npm i nudgekit-analytics
# pnpm i nudgekit-analytics
# yarn add nudgekit-analytics
# bun add nudgekit-analytics

Next.js (recommended)

Add the component to your root layout:

// app/layout.tsx
import { Analytics } from "nudgekit-analytics";

export default function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  return (
    <html lang="en">
      <body>
        {children}
        <Analytics siteId="site_your_id" />
      </body>
    </html>
  );
}

Get siteId from NudgeKit Analytics → site → Settings.

React (SPA)

import { Analytics } from "nudgekit-analytics";

export default function App() {
  return (
    <>
      {/* your app */}
      <Analytics siteId="site_your_id" />
    </>
  );
}

Live visitors widget (optional)

Add the public 30-minute widget anywhere on your React or Next.js site:

import { AnalyticsWidget } from "nudgekit-analytics";

export function LiveVisitors() {
  return <AnalyticsWidget siteId="site_your_id" />;
}

It renders a responsive dark card with total unique visitors, a 30-bar minute chart, the top three countries, and NudgeKit attribution. Data refreshes every 30 seconds and only aggregate counts are exposed—visitor and session ids are never returned.

Use it alongside <Analytics /> so visits are tracked:

<>
  <Analytics siteId="site_your_id" />
  <AnalyticsWidget siteId="site_your_id" />
</>

Widget options

| Option | Default | Description | |--------|---------|-------------| | siteId | required | Public site id used by <Analytics /> | | refreshIntervalMs | 30000 | Refresh frequency; 0 fetches once (minimum non-zero value: 10s) | | accentColor | #df704a | Bar and live-dot color | | title | Users in last 30 minutes | Custom card heading | | showBranding | true | Show the “Powered by NudgeKit” footer | | locale | browser locale | Number and chart-time locale | | timeZone | browser time zone | IANA time zone for chart labels | | baseUrl | NudgeKit API | Optional self-hosted/local API override | | data | — | Controlled widget data; disables fetching and polling | | className / style | — | Size and position the responsive widget | | onError | — | Called if public widget data cannot be loaded |

<AnalyticsWidget
  siteId="site_your_id"
  accentColor="#14b8a6"
  refreshIntervalMs={60_000}
  style={{ maxWidth: 520 }}
/>

Tracking options

| Option | Default | Description | |--------|---------|-------------| | siteId | required | Public site id from NudgeKit Analytics (e.g. site_xxx) | | autoTrack | true | Initial pageview + SPA history changes | | heartbeat | true | Online presence while tab is visible | | heartbeatIntervalMs | 30000 | Heartbeat interval | | timeoutMs | 10000 | Request timeout | | heatmaps | off | Opt-in click + scroll capture (see below) |

Heatmaps (opt-in)

<Analytics
  siteId="site_your_id"
  heatmaps={{
    sampleRate: 0.2,      // customer default; use 1 for dogfood
    captureText: false,   // element labels off by default
    includePaths: ["/"],  // exact pathnames only
  }}
/>

Sampled heatmap sessions also send one privacy-masked DOM snapshot per visited path. Inputs and visible text are masked before upload. This lets the dashboard reconstruct authenticated/private page layouts without collecting login credentials or cookies. Use data-nk-snapshot-block to remove a sensitive subtree entirely.

Without heatmaps, behavior is unchanged from earlier versions.

Session replay (opt-in)

Record masked visitor sessions and view complete journeys in the NudgeKit dashboard:

<Analytics
  siteId="site_your_id"
  sessionReplay={{
    sampleRate: 0.1,
    includePaths: ["/", "/pricing"],
  }}
/>

Identify a signed-in visitor with your own stable, non-email user id:

import { identify, resetIdentity } from "nudgekit-analytics";

identify("user_123");
// On logout:
resetIdentity();

Inputs are always masked. Add data-nk-snapshot-block to replace a sensitive subtree and data-nk-snapshot-ignore to ignore its mutations. Session replay is off unless sessionReplay is provided. Every recording has a hard 30-minute maximum; longer visits are split into fresh recording segments.

Imperative API

import { initAnalytics, track, trackPageview, destroyAnalytics } from "nudgekit-analytics";

await initAnalytics({ siteId: "site_xxx" });
await trackPageview();
await track("signup_completed", { plan: "free" });
destroyAnalytics();

What is tracked

  • pageview — on load + SPA history changes
  • heartbeat — every 30s while the tab is visible (online count)
  • event — a named custom conversion event sent with track(name, properties)
  • view — one sampled behavior-view per allowed page path when heatmaps are enabled
  • click — normalized click positions; form values are never captured
  • scroll — 25/50/75/100% reach milestones
  • page snapshot — one masked DOM state per sampled path for heatmap backgrounds

Give important elements a privacy-safe dashboard label without enabling general text capture:

<button data-nk-label="Hero signup CTA">Start free</button>
  • click / scroll — only when heatmaps is enabled (batched)

Visitor id lives in localStorage. Session rotates after 30 minutes idle.

License

MIT