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

@the-grid-data/analytics

v0.3.0

Published

Shared Grid analytics emitter — emitGridEvent + bot/AI matchers + viewer-role resolver + sampling. Single source of truth for the unified PostHog telemetry contract across every Grid surface.

Readme

@the-grid-data/analytics

The single shared emitter for The Grid's unified PostHog telemetry contract. Every Grid surface — Discovery, Directory subdomains, the Network portal, admin, reports, GridMCP — emits the same six events with the same property shape through this package, so analytics are consistent across surfaces and cross-surface joins (impression → click → view) work.

The six-event contract at a glance

| Event | When | Emitted from | |---|---|---| | category_page_viewed | A category/list page renders | client | | profile_impression | A result card is ≥50% visible for ≥500ms | client (./react) | | category_result_clicked | A result card is clicked | client | | profile_viewed | A profile page is served | server (adblocker-immune) | | profile_lens_displayed | A lens (profile/product/asset/contract) shows | client | | profile_url_clicked | An outbound profile URL is clicked | client |

Every event carries a 16-field shared property contract (profile + surface identity, lens, viewer role, session, bot/AI classification, referrer source, versioning). buildGridEventPayload assembles and validates it: null is a valid value, missing is rejected. The funnel joins on list_instance_id (impression ↔ click ↔ view) and session_id.

Install

pnpm add @the-grid-data/analytics
# peer deps — install the ones your runtime uses:
pnpm add posthog-js        # browser emits
pnpm add posthog-node      # server emits

React (for ./react and ./next/client) is also an optional peer.

Subpath map

| Import | What it is | Deps | |---|---|---| | . / ./core | Pure contract: types, enums, payload builder, bot/AI matchers, viewer-role resolver, sampling, list_instance_id helpers | none | | ./client | emitGridEvent bound to a posthog-js instance you provide | posthog-js | | ./server | emitGridEvent bound to a posthog-node client you provide | posthog-node | | ./react | useImpressionObserver + ListContextProvider (impression primitive) | react | | ./next | Next.js server helpers: createRelayRewrites, emitServerProfileViewed, deriveSessionId, request guards | posthog-node (lazy) | | ./next/client | Next.js browser helpers: createGridPosthog, useGridPosthog, GridAnalyticsProvider | posthog-js, react |

core is dependency-free by design and safe to import anywhere; the bindings never call posthog.init or read env. The ./next layer is the opinionated exception: it owns instance creation and reads the canonical env var so a new app wires up in four mechanical steps.

Quickstart (Next.js)

  1. Set NEXT_PUBLIC_GRID_ANALYTICS_POSTHOG_KEY (the PostHog project write key — public-safe). Helpers warn once and no-op when it is unset.

  2. Proxy browser ingest through a first-party path (next.config.ts):

import { createRelayRewrites } from '@the-grid-data/analytics/next';

nextConfig.skipTrailingSlashRedirect = true;
nextConfig.rewrites = async () => ({
  beforeFiles: createRelayRewrites({ region: 'eu' }),
});
  1. Mount the browser instance and emit client events:
'use client';
import { useGridPosthog } from '@the-grid-data/analytics/next/client';
import { emitGridEvent } from '@the-grid-data/analytics/client';
import { GRID_EVENTS } from '@the-grid-data/analytics';

const posthog = useGridPosthog({ persistenceName: 'ph_grid_myapp' });
// once ready (non-null):
emitGridEvent(posthog, GRID_EVENTS.CATEGORY_PAGE_VIEWED, { shared, props });
  1. Emit the server-side profile_viewed from middleware:
import { emitServerProfileViewed } from '@the-grid-data/analytics/next';

export function middleware(request: NextRequest, event: NextFetchEvent) {
  emitServerProfileViewed(request, event, {
    surface: 'myapp',
    surfaceSlug: slug,
    profileSlug,
  });
}
  1. Wire lists with ListContextProvider + useImpressionObserver (./react) and hand the list_instance_id across clicks with withListContext.

The full wiring guide — client/server event routing, the named-instance and persistence incantations, proxy traps, prefetch/bot guards, session-id conventions, sampling, and the release flow — is in docs/INTEGRATION.md (shipped in this package).

License

MIT