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

@tryhaya/analytics

v1.0.2

Published

Haya Analytics SDK — Heatmaps, Session Replay, and Event Tracking for your website

Downloads

384

Readme

@tryhaya/analytics

Heatmaps, Session Replay, and Event Tracking for your website.

Haya is a lightweight analytics SDK that records what users actually do — clicks, scrolls, navigations, and full DOM replays — without sending any video. It works with any JavaScript framework and adds under 5 KB to your bundle after compression.


Installation

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

Quick Start

import haya from '@tryhaya/analytics';

haya.init('YOUR_SDK_KEY', {
  sessionReplay: true,
  heatmaps: true,
  autoTrack: { clicks: true, scrolls: true, pageviews: true },
  maskInputs: true,
});

Get your SDK key from the Haya dashboard.


Framework Setup

React

// src/main.jsx
import haya from '@tryhaya/analytics';

haya.init('YOUR_SDK_KEY', { sessionReplay: true, maskInputs: true });

ReactDOM.createRoot(document.getElementById('root')).render(<App />);

Next.js (App Router)

// components/HayaProvider.tsx
'use client';
import { useEffect } from 'react';
import haya from '@tryhaya/analytics';

export function HayaProvider() {
  useEffect(() => {
    haya.init(process.env.NEXT_PUBLIC_HAYA_SDK_KEY!, {
      sessionReplay: true,
      maskInputs: true,
    });
  }, []);
  return null;
}

Add <HayaProvider /> to your root layout.tsx. Also add to next.config.ts:

const nextConfig = {
  transpilePackages: ['@tryhaya/analytics'],
};

Vue 3

// src/main.ts
import haya from '@tryhaya/analytics';

haya.init(import.meta.env.VITE_HAYA_SDK_KEY, {
  sessionReplay: true,
  maskInputs: true,
});

createApp(App).use(router).mount('#app');

Plain HTML (CDN)

<script src="https://cdn.usehaya.io/haya.min.js"></script>
<script>
  haya.init('YOUR_SDK_KEY', { sessionReplay: true, maskInputs: true });
</script>

Configuration

haya.init('YOUR_SDK_KEY', {
  // Features
  sessionReplay: true,        // Record DOM replay in 40s chunks
  heatmaps: true,             // Collect click + scroll heatmap data

  // Auto-tracking
  autoTrack: {
    clicks: true,             // Track every click
    scrolls: true,            // Track scroll depth
    pageviews: true,          // Track page loads + SPA navigation
  },
  trackMousemove: false,      // Mouse position tracking (high volume)

  // Privacy
  maskInputs: true,           // Mask all input values in replays
  ignoreSelectors: [],        // CSS selectors to exclude from tracking

  // Transport
  endpoint: 'https://api.usehaya.io/e',  // Override for self-hosted backends
  flushInterval: 3000,        // ms between batch sends
  flushSize: 50,              // Flush early at this event count

  // Replay
  replayMaxDuration: 40,      // Seconds per replay chunk

  // Debug
  debug: false,               // Log SDK activity to console
});

Tracking Custom Events

haya.track('signup_completed', {
  plan: 'pro',
  source: 'pricing_page',
});

Session Replay

Haya records DOM snapshots using rrweb. Recording works in continuous 40-second chunks — each chunk is uploaded to storage and a new recording starts automatically.

Privacy defaults:

  • maskInputs: true masks all <input>, <textarea>, and <select> values (including type="text") as *** in replays
  • Add class="haya-block" to any element to block it from appearing in replays entirely
haya.init('YOUR_SDK_KEY', {
  sessionReplay: true,
  maskInputs: true,
  ignoreSelectors: ['.sensitive-widget', '#credit-card-form'],
});

API Reference

| Method | Description | |---|---| | haya.init(key, config) | Initialize the SDK | | haya.track(name, props) | Track a custom event | | haya.flush() | Flush the event buffer immediately | | haya.reset() | Tear down all listeners and flush remaining events | | haya.setDebug(true) | Toggle verbose console logging at runtime |


Offline Support

Batches that fail to send are saved to localStorage with a 72-hour TTL. When the user comes back online, the queue drains automatically with exponential backoff retry (up to 5 attempts).


How It Works

User action → SDK collector → Event buffer (3s flush interval)
                                      ↓
                              POST /e (HMAC signed)
                                      ↓
                           Haya Backend → MongoDB
                                      ↓
                      BullMQ worker → Cloudinary (replay storage)
  • Events (clicks, scrolls, pageviews) are batched and sent every 3 seconds
  • Replay snapshots are flushed immediately when a FullSnapshot is captured
  • Session finalization runs in a background worker — the ingest endpoint never blocks on Cloudinary uploads

TypeScript

Full TypeScript types are included. No separate @types package needed:

import haya, { HayaConfig } from '@tryhaya/analytics';

const config: Partial<HayaConfig> = {
  sessionReplay: true,
  replayMaxDuration: 60,
};

haya.init('YOUR_SDK_KEY', config);

License

MIT © Haya