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

@jmp-technologies/analytics

v0.1.7

Published

Browser client for JMP Analytics event ingestion

Readme

@jmp-technologies/analytics

Browser client for POST {baseUrl}/api/events plus published blog/FAQ content helpers for client websites.

New client website (full process)

  1. Deploy JMP Analytics (jmp-dashboard) to a stable HTTPS URL.
  2. Create a website row (domain + tracking_key) and assign it to the client user.
  3. On the client site: npm install @jmp-technologies/analytics, set NEXT_PUBLIC_JMP_ANALYTICS_URL and NEXT_PUBLIC_JMP_TRACKING_KEY (same key for browser and server in Next.js), wire trackPageView (and optional events).
  4. Verify POST /api/events returns 201 and data appears in the dashboard.

Step-by-step checklist: Client onboarding

API, CORS, examples: Tracking integration

If your GitHub org/repo name differs, replace jmp-technologies/jmp-dashboard in those URLs.


Monorepo / local docs

From this repo, the same files are at docs/client-onboarding.md and docs/tracking-integration.md.

Quick setup (env helpers)

Set NEXT_PUBLIC_JMP_ANALYTICS_URL and NEXT_PUBLIC_JMP_TRACKING_KEY (used for browser tracking, server content fetches, and getJmpServerContentConfigFromEnv).

Next.js App Router (least client code)

  1. Install peers: react, react-dom, next (already present in a Next app).
  2. In app/layout.tsx (or the root layout that wraps all pages), add one client line:
import type { ReactNode } from "react"
import { JmpNextAnalytics } from "@jmp-technologies/analytics/next"

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

That enables automatic page_view on first load and on client-side navigations (includes query string). No jmp-analytics-client.ts, no useEffect + usePathname boilerplate.

Optional: track phone clicks without custom handlers — use JmpTrackedTelLink from the same module:

import { JmpNextAnalytics, JmpTrackedTelLink } from "@jmp-technologies/analytics/next"

<JmpTrackedTelLink href="tel:+15551234567" className="...">
  Call us
</JmpTrackedTelLink>

Hooks: useJmpAnalytics() from @jmp-technologies/analytics/next or @jmp-technologies/analytics/react for forms and custom events.


Optional server-side page views for crawler visibility

Browser analytics may miss bots/crawlers that do not execute JavaScript. To capture AI crawler user agents more reliably, forward server requests from Next.js proxy.ts or route code:

import {
  getJmpServerContentConfigFromEnv,
  trackJmpServerPageView,
} from "@jmp-technologies/analytics"

export async function proxy(request: Request) {
  const config = getJmpServerContentConfigFromEnv()
  if (config) {
    void trackJmpServerPageView(config, { request }).catch(() => {})
  }
}

Use this only on page routes you want counted. Avoid static assets, health checks, API routes, and duplicate tracking if a page already has browser tracking and you do not want both server and browser page views.


Optional AI crawler robots.txt policy

Clients can switch AI crawler blocking on or off in JMP dashboard settings. To make that setting visible to crawlers, serve the generated policy from the client site's robots.txt route:

import {
  getJmpRobotsTxt,
  getJmpServerContentConfigFromEnv,
} from "@jmp-technologies/analytics"

export async function GET() {
  const config = getJmpServerContentConfigFromEnv()
  const body = config
    ? await getJmpRobotsTxt(config)
    : "# JMP Analytics is not configured.\n"

  return new Response(body, {
    headers: {
      "Content-Type": "text/plain; charset=utf-8",
    },
  })
}

Place that in app/robots.txt/route.ts for Next.js App Router sites. The policy uses robots.txt Disallow rules for known AI crawler user agents; crawlers that ignore robots.txt or use undisclosed names may still access public pages.


Manual browser (any framework)

Browser (client components) — one module-level singleton per tab, default pageViewDedupeMs (800):

import { getOrCreateJmpAnalyticsFromBrowserEnv } from "@jmp-technologies/analytics"

const analytics = getOrCreateJmpAnalyticsFromBrowserEnv()
void analytics?.trackPageView()

Server — blog / FAQ / content API:

import { getJmpBlogPosts, getJmpServerContentConfigFromEnv } from "@jmp-technologies/analytics"

export default async function BlogPage() {
  const config = getJmpServerContentConfigFromEnv()
  if (!config) return null
  const posts = await getJmpBlogPosts(config)
  // ...
}

Or createJmpContentClientFromServerEnv() for getBlogPosts() / getBlogPost() / getFaqs() in one object.

Configured? isJmpBrowserAnalyticsEnvConfigured() and isJmpServerContentEnvConfigured().


Blog and FAQ content

Manage content in the JMP dashboard at /content, then render it on the client website from the client site's own routes:

import { getJmpBlogPosts, getJmpServerContentConfigFromEnv } from "@jmp-technologies/analytics"

export default async function BlogPage() {
  const config = getJmpServerContentConfigFromEnv()
  if (!config) return null
  const posts = await getJmpBlogPosts(config)

  return (
    <main>
      <h1>Blog</h1>
      {posts.map((post) => (
        <article key={post.id}>
          <h2>{post.title}</h2>
          <p>{post.excerpt}</p>
        </article>
      ))}
    </main>
  )
}

Available helpers:

FAQ items include a stable slug field. Use that slug, rather than the id, when building FAQ URLs so tracked page views are stored as readable paths.

Config from env

  • getJmpBrowserAnalyticsConfigFromEnv() / getJmpServerContentConfigFromEnv()
  • getOrCreateJmpAnalyticsFromBrowserEnv() (browser singleton)
  • createJmpContentClientFromServerEnv()
  • isJmpBrowserAnalyticsEnvConfigured() / isJmpServerContentEnvConfigured()

Next.js (@jmp-technologies/analytics/next)

  • JmpNextAnalytics / JmpNextPageViewTracker — App Router page views
  • Re-exports: JmpTrackedTelLink, useJmpAnalytics

React (@jmp-technologies/analytics/react)

  • JmpTrackedTelLink, useJmpAnalytics — Vite, CRA, etc. (no automatic route tracking; call trackPageView yourself or use your router)

Content

  • getJmpBlogPosts(config)
  • getJmpBlogPost(config, slug)
  • getJmpFaqs(config)
  • getJmpRobotsTxt(config)
  • createJmpContentClient(config)

For SEO, call these helpers from server-rendered pages whenever the client site framework supports it.

Build

npm run build in this package (or root prepare after npm install).

Publish to npm (org jmp-technologies)

npm publish from this directory after npm run build (package sets publishConfig.access to public).