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

@inferevents/sdk

v0.1.13

Published

Event collection SDK for Infer — analytics designed for AI agents, not dashboards

Readme

@inferevents/sdk

Event collection SDK for Infer — analytics designed for AI agents, not dashboards.

3KB. Zero dependencies. Auto-tracks page views, clicks, sessions, and errors out of the box.

Install

npm install @inferevents/sdk

Quick start

import { init, track, identify } from "@inferevents/sdk";

init({
  projectId: "pk_write_...",  // your write key (safe to embed in client JS)
  autoTrack: true,            // auto-tracks page views, clicks, sessions, errors
});

// Track custom events
track("signup_completed", { plan: "pro" });

// Identify a user (links anonymous activity to a known user)
identify("user_123", { email: "[email protected]" });

API

init(config)

Initialize the SDK. Must be called before other methods (events queued before init are replayed automatically).

init({
  projectId: string;       // Required. Your write key (pk_write_...)
  endpoint?: string;       // API endpoint (default: https://api.infer.events)
  autoTrack?: boolean;     // Enable auto-tracking (default: false)
  batchSize?: number;      // Events per batch (default: 20)
  flushInterval?: number;  // Flush interval in ms (default: 10000)
  debug?: boolean;         // Console logging (default: false)
});

track(eventName, properties?)

Track a custom event.

track("purchase", { amount: 49.99, currency: "USD" });
track("feature_used", { feature: "export" });

identify(userId, traits?)

Link the current anonymous user to a known user ID. All past and future events are associated with this identity.

identify("user_123", { name: "Alice", plan: "pro" });

page(name?)

Track a page view. Called automatically if autoTrack: true.

page("Pricing");

screen(name)

Track a screen view (React Native / mobile).

screen("Settings");

flush()

Manually flush the event queue. Events are batched and sent automatically, but you can force a flush.

await flush();

reset()

Clear the current user identity. Use on logout to start a new anonymous session.

reset();

destroy()

Tear down the SDK, clear timers and listeners.

Auto-tracking

When autoTrack: true, the SDK automatically captures:

| Event | Trigger | |-------|---------| | page_view | Page navigation (History API) | | session_start | New browser session | | click | Clicks on interactive elements (buttons, links) | | form_submit | Form submissions | | error | Uncaught JavaScript errors |

Context

Every event includes auto-collected context:

| Field | Source | |-------|--------| | browser | User agent | | os | Parsed from UA (macOS, Windows, iOS, Android, Linux) | | device_type | Mobile, Tablet, or Desktop | | page_url | window.location.href | | pathname | window.location.pathname | | referrer | document.referrer | | locale | navigator.language | | timezone | Intl.DateTimeFormat timezone | | screen_width / screen_height | Screen dimensions |

Server-side geo enrichment (country, city, region) is added at ingestion time.

How it works

  • Events are queued in memory and flushed every 10 seconds (or when batch size is reached)
  • On page unload, queued events are sent via fetch with keepalive: true
  • Unflushed events are persisted to localStorage and restored on next page load
  • Failed sends are retried with exponential backoff
  • Each event gets a UUID for deduplication (server-side ON CONFLICT DO NOTHING)

License

MIT