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

trackcel

v0.4.0

Published

Lightweight analytics for React and Next.js — pageviews, engaged time, Web Vitals, events, signups, revenue and AI crawler tracking

Readme

Trackcel - Analytics for React and Next.js

Trackcel is a lightweight analytics SDK for React and Next.js. It tracks pageviews, custom events, clicks, scroll depth, and session duration.

Installation

npm install trackcel

Get your Project ID and API Key from the Trackcel dashboard.


React (Vite, Create React App, etc.)

Use the Analytics component from the main trackcel package. Add it once at the root of your app.

// src/main.tsx or src/App.tsx
import { Analytics } from "trackcel";

function App() {
  return (
    <>
      <Analytics
        projectId="your-project-id"
        apiKey="sk_live_your_api_key"
        disableInDevelopment={true}
        endpoint="https://trackcel.vercel.app"
        debug={false}
      />
      {/* rest of your app */}
    </>
  );
}

Or use the hook directly:

import { useAnalytics } from "trackcel";

function App() {
  useAnalytics({
    projectId: "your-project-id",
    apiKey: "sk_live_your_api_key",
    disableInDevelopment: true,
  });

  return <YourRoutes />;
}

React Router

Analytics tracks the initial page load and browser back/forward. For client-side route changes, call trackPageView when the route changes:

import { useEffect } from "react";
import { useLocation } from "react-router-dom";
import { init } from "trackcel";

const analytics = init({
  projectId: "your-project-id",
  apiKey: "sk_live_your_api_key",
  disableInDevelopment: true,
});

analytics.attachInteractionListeners();

function RouteTracker() {
  const location = useLocation();

  useEffect(() => {
    analytics.trackPageView();
  }, [location.pathname, location.search]);

  return null;
}

// In your router setup:
function App() {
  return (
    <BrowserRouter>
      <RouteTracker />
      <Routes>{/* ... */}</Routes>
    </BrowserRouter>
  );
}

Next.js App Router

Use NextAnalytics from trackcel/next. It follows App Router navigations via usePathname and useSearchParams.

// app/providers/analytics.tsx
"use client";

import { Suspense } from "react";
import { NextAnalytics } from "trackcel/next";

export function AnalyticsProvider() {
  return (
    <Suspense fallback={null}>
      <NextAnalytics
        projectId={process.env.NEXT_PUBLIC_TRACKCEL_PROJECT_ID!}
        apiKey={process.env.NEXT_PUBLIC_TRACKCEL_API_KEY!}
        disableInDevelopment={true}
        endpoint={process.env.NEXT_PUBLIC_TRACKCEL_ENDPOINT}
      />
    </Suspense>
  );
}
// app/layout.tsx
import { AnalyticsProvider } from "./providers/analytics";

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

Next.js Pages Router

Use the main Analytics component in _app.tsx:

// pages/_app.tsx
import type { AppProps } from "next/app";
import { Analytics } from "trackcel";

export default function App({ Component, pageProps }: AppProps) {
  return (
    <>
      <Analytics
        projectId={process.env.NEXT_PUBLIC_TRACKCEL_PROJECT_ID!}
        apiKey={process.env.NEXT_PUBLIC_TRACKCEL_API_KEY!}
        disableInDevelopment={true}
        endpoint={process.env.NEXT_PUBLIC_TRACKCEL_ENDPOINT}
      />
      <Component {...pageProps} />
    </>
  );
}

Custom events

Works in both React and Next.js:

import { init } from "trackcel";

const analytics = init({
  projectId: "your-project-id",
  apiKey: "sk_live_your_api_key",
});

// Track a button click, signup, purchase, etc.
analytics.trackEvent("signup_click", { plan: "pro" });

Or use the shared tracker directly once <Analytics /> / <NextAnalytics /> is mounted:

import { track } from "trackcel";

track("signup_click", { plan: "pro" });

Signups and visitor profiles

Link a browser to one of your users so the dashboard can show their journey, mark them as converted, and attribute revenue to the source that brought them in:

import { identify, signup } from "trackcel";

identify(user.id, { email: user.email, name: user.name }); // after login
signup(user.id, { email: user.email });                    // after a confirmed signup

Server-side: revenue, confirmed signups, AI crawlers

trackcel/server runs on your backend (Node.js or Edge) with the project secret key (tc_secret_..., from the project's integrations settings). Never ship it to the browser.

import { createTrackcelServer } from "trackcel/server";

const trackcel = createTrackcelServer({ secretKey: process.env.TRACKCEL_SECRET_KEY! });

// Confirmed signup (visitorId comes from getVisitorId() in the browser, e.g. a hidden form field)
await trackcel.identify({ customerId: user.id, visitorId, email: user.email, signedUp: true });

// Payment succeeded / refunded (amounts in major units; transactionId makes retries safe)
await trackcel.revenue({ amount: 19, currency: "USD", transactionId: payment.id, customerId: user.id });
await trackcel.revenue({ type: "refund", amount: 19, currency: "USD", transactionId: refund.id, customerId: user.id });

Crawlers (GPTBot, ClaudeBot, PerplexityBot, Googlebot, ...) don't run JavaScript, so log them from middleware to fill the AI activity → Crawlers report:

// middleware.ts
import { NextResponse, type NextFetchEvent, type NextRequest } from "next/server";
import { createTrackcelServer } from "trackcel/server";

const trackcel = createTrackcelServer({ secretKey: process.env.TRACKCEL_SECRET_KEY! });

export function middleware(request: NextRequest, event: NextFetchEvent) {
  event.waitUntil(trackcel.crawlers(request));
  return NextResponse.next();
}

Package exports

| Import | Use case | |--------|----------| | trackcel | React, Vite, CRA, Next.js Pages Router (Analytics, track, identify, signup, getVisitorId) | | trackcel/next | Next.js App Router only (NextAnalytics, plus the same helpers) | | trackcel/server | Backend only: revenue, confirmed signups, crawler logging |


Configuration

| Option | Type | Description | |--------|------|-------------| | projectId | string | Required. From your Trackcel dashboard | | apiKey | string | Required. From your Trackcel dashboard | | disableInDevelopment | boolean | Skip tracking on localhost / 127.0.0.1 | | endpoint | string | Custom API URL (default: https://trackcel.vercel.app) | | debug | boolean | Log events to the browser console | | webVitals | boolean | Collect Core Web Vitals (LCP, INP, CLS, FCP, TTFB). Default true | | trackInteractions | boolean | Record clicks and scroll depth. Default true | | respectDoNotTrack | boolean | Skip visitors whose browser sends Do Not Track. Default false |

To exclude your own visits, run localStorage.setItem("trackcel_ignore", "true") in the browser console on your site.

Environment variables (Next.js)

| Variable | Description | |----------|-------------| | NEXT_PUBLIC_TRACKCEL_PROJECT_ID | Your project ID | | NEXT_PUBLIC_TRACKCEL_API_KEY | Your API key | | NEXT_PUBLIC_TRACKCEL_ENDPOINT | Optional custom collect endpoint |

For React / Vite, pass credentials as props (or read from import.meta.env.VITE_* yourself and pass them to Analytics).


Features

  • Pageview tracking, SPA navigation (history API) and App Router support
  • Visitor IDs and sessions that end after 30 minutes of inactivity
  • Engaged time (visible + active, idle time excluded) and time on page
  • Core Web Vitals field data (LCP, INP, CLS, FCP, TTFB) for the performance score
  • Custom events, identify() and signup() for visitor profiles and conversions
  • Server-side revenue, confirmed signups and AI/search crawler logging (trackcel/server)
  • Click heatmap data and scroll depth milestones (25%, 50%, 75%, 100%)
  • No CORS preflights (beacons sent as text/plain), works without crypto.randomUUID
  • Configurable endpoint for self-hosting, development-mode disable, opt-out switch

Need help?

Visit trackcel.vercel.app or open an issue on GitHub.