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

@senzops/web

v1.3.7

Published

Senzor Web Analytics and RUM SDK

Readme

@senzops/web

The official, lightweight, and privacy-conscious Web Analytics & Real User Monitoring (RUM) SDK for Senzor.

Senzor Web is a tiny (< 4KB gzipped) TypeScript agent designed to track page views, visitor sessions, Core Web Vitals, frontend exceptions, and distributed traces without impacting your website's performance. It works seamlessly with Single Page Applications (SPAs) like React, Next.js, and Vue.

🚀 Installation

Option 1: NPM (Recommended for React/Vue/Next.js)

npm install @senzops/web
# or
yarn add @senzops/web

Option 2: CDN (HTML Script Tag)

Add this to the of your website:

<script src="https://cdn.jsdelivr.net/gh/senzops/web-agent/dist/index.global.js"></script>
<script>
 // Opt-in to Web Analytics (Marketing/Product)
 window.Senzor.init({
  webId: "YOUR_WEB_ID_HERE",
 });

// Opt-in to Web APM / RUM (Engineering)
 window.Senzor.initRum({
  apiKey: "YOUR_RUM_API_KEY_HERE",
  sampleRate: 0.1, // 10% of sessions
  allowedOrigins: ["https://api.yourdomain.com"] // For distributed tracing
 });
</script>

🛠 Usage

In React / Next.js

Initialize the agent once in your root layout or main app component. Senzor cleanly separates Web Analytics (100% sampling, privacy-focused) from Web APM / RUM (performance tracing, configurable sampling). You can use either, or both!

import { useEffect } from "react";
import { Senzor } from "@senzops/web";

export default function App({ Component, pageProps }) {
 useEffect(() => {
 // 1. Web Analytics (Page views, Bounce rates, Sessions)
 Senzor.init({
  webId: "req_123456789", // Get this from your Senzor Dashboard
 });

    // 2. Web APM / RUM (Core Web Vitals, Network Spans, JS Errors)
    Senzor.initRum({
      apiKey: "rum_987654321", // Get this from your Senzor Dashboard
      sampleRate: 1.0, // Trace 100% of sessions (Adjust for high-traffic sites)
      allowedOrigins: ["https://api.mycompany.com"] // Inject W3C trace headers here
    });

}, []);

return <Component {...pageProps} />;
}

🧠 Working Principle

The Senzor Agent is designed to be "Fire and Forget". It operates asynchronously to ensure it never blocks the main thread or slows down page loads.

Part 1: Web Analytics (Marketing & Product)

  • Identity & Sessions: We generate random UUIDs in localStorage and sessionStorage. This allows us to track unique visitors and calculate Bounce Rates without using cookies.
  • Event Tracking: Detects SPA route changes via history.pushState and popstate.
  • Duration Pings: Calculates precise time-on-page by listening to visibilitychange and beforeunload, sending a final duration "ping" when the user leaves.

Part 2: Web APM & RUM (Engineering & Performance)

  • Core Web Vitals (CWV): Passively listens via PerformanceObserver to capture Google Web Vitals (LCP, INP, CLS, FCP) without stalling the main thread.
  • Distributed Tracing: Safely intercepts window.fetch and XMLHttpRequest. If a request targets an allowedOrigins domain, it injects a W3C traceparent header, connecting frontend clicks directly to your Node.js backend database queries.
  • UX Frustrations: Detects "Rage Clicks" (rapid clicking on one element) and "Dead Clicks" (clicking non-interactive elements) to highlight poor UX.
  • Universal Error Engine: Captures uncaughtException and unhandledRejection, attaching a "Breadcrumb" trail of the user's last 15 actions (clicks, navigations) leading up to the crash.

Data Transmission

We prioritize data reliability using navigator.sendBeacon. It queues data to be sent by the browser even after the tab is closed. If unavailable, it falls back to a standard fetch request with keepalive: true.

⚙️ Configuration Options

Analytics Options (Senzor.init)

| Option | Type | Default | Description | | :------- | :----- | :---------------- | :------------------------------------------- | | webId | string | Required | The unique Analytics ID of your website. | | endpoint | string | api.senzor.dev... | Ingestion API URL. Use this if self-hosting. |

RUM Options (Senzor.initRum)

| Option | Type | Default | Description | | :------------- | :----- | :---------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------- | | apiKey | string | Required | The unique RUM API Key of your website. | | sampleRate | number | 1.0 | Percentage of performance traces to capture (0.0 to 1.0). Errors are ALWAYS 100% captured regardless of this setting. | | allowedOrigins | array | [] | Array of strings or RegEx. The agent will only inject W3C traceparent headers into requests targeting these origins (prevents CORS failures on 3rd-party APIs). | | endpoint | string | api.senzor.dev... | Ingestion API URL. Use this if self-hosting. |

📦 Development

To build the agent locally:

  1. Clone & Install
   git clone https://github.com/Senzops/web-agent.git
   cd web-agent
   npm install
  1. Build
    Uses tsup to bundle for ESM, CJS, and IIFE (Global variable).
npm run build
  1. Output
    • dist/index.js (CommonJS)
    • dist/index.mjs (ES Modules)
    • dist/index.global.js (Browser Script)

📄 License

MIT © Senzor