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

unitrack-web

v0.1.0

Published

UniTrack — Web analytics SDK với auto-capture, offline queue, W3C trace context, Snowplow/HTTP fan-out.

Downloads

154

Readme

@unitrack/web

UniTrack web SDK — auto-capture screen + tap + network + crash, offline queue, W3C trace context, fan-out tới Snowplow / HTTP custom.

API parity với Flutter / iOS / Android version.

Install

npm install @unitrack/web

Hoặc <script> IIFE:

<script src="https://unpkg.com/@unitrack/web/dist/unitrack.iife.js"></script>

Quick start

import UniTrack, { SnowplowProvider } from '@unitrack/web';

UniTrack.initialize('utk_your_api_key', {
  endpoint: 'https://your-ingest.example.com/events',
  autoCapture: true,
  trackTaps: true,
  trackScreens: true,
  trackNetwork: true,
  piiSalt: 'your_pii_salt_hex',
  tracingAllowlistHosts: ['api.yourapp.com', '*.yourcompany.com'],
});

// Optional Snowplow
UniTrack.addProvider(new SnowplowProvider({
  endpoint:   'https://collector.yourapp.com',
  appId:      'web_app',
  igluVendor: 'com.yourcompany.tracker',
}));

// Identify sau khi user login
await UniTrack.identify(userEmail, { plan: 'pro' });

// Custom event
UniTrack.customTrack('purchase_completed', {
  action: 'completed',
  data: { order_id: 'A-1024', amount: 99000 },
  includeUser: true,
});

Demo

npm run build
python3 -m http.server 8000  # hoặc bất kỳ static server
# Mở http://localhost:8000/demo/

API

| Method | Mô tả | |---|---| | initialize(apiKey, config?) | Init 1 lần ở app bootstrap | | track(name, props?) | Manual track event | | customTrack(name, { action, data, includeUser }) | Custom event với stamp event_action + optional user_id | | identify(userId, traits?) | Hash PII trước khi cache (nếu piiSalt set) | | reset() | Clear identity, logout flow | | setScreen(name) | Override screen name | | currentSessionId() / sessionIndex() / previousSessionId() | Session getter | | rotateSession() | Force rotate (logout / switch-account) | | addProvider(p) | Register provider (Snowplow, HttpProvider, ...) | | flush() | Force flush mọi provider |

Auto-capture

Cờ trong initialize(config):

| Cờ | Event tự bắt | |---|---| | trackTaps: true | click — document-level capture, resolve element_key qua data-track-id > id > aria-label > text | | trackScreens: true | screen_viewed + screen_load_completed — hook pushState/replaceState + popstate + hashchange | | trackNetwork: true | network_request / network_error — patch fetch + XMLHttpRequest |

App có thể override tên event qua screenStartEvent, screenLoadEvent, clickEvent config.

W3C Trace Context

tracingAllowlistHosts: ['api.yourapp.com', '*.yourcompany.com']

→ SDK tự inject header traceparent: 00-<trace>-<span>-01 vào fetch/XHR đi tới host trong list. Fail-closed: empty list = không inject. BE phải Access-Control-Allow-Headers: traceparent mới nhận được CORS.

Offline queue

IndexedDB — event lưu khi navigator.onLine === false, tự flush khi online event fire. Fallback: navigator.sendBeacon khi page unload.

PII hash

SHA-256(salt + raw) qua crypto.subtle. Cache in-memory để tránh re-hash. Salt rotate → cache tự invalidate.