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

@basetime/pintail-sdk-ts

v0.1.10

Published

Pintail SDK for TypeScript

Readme

Pintail SDK

The Pintail SDK is a lightweight TypeScript client for sending events to the Pintail event-tracking API. It exposes a small Client class — and a ready-to-use default instance — that lets your application record named events, optionally enriched with structured extras, with a single track() call. The SDK is dependency-free at runtime, uses the platform's built-in fetch, and ships with full TypeScript type definitions.

Usage

Server Side

Install the package:

npm install @basetime/pintail-sdk-ts

Then, use the pintail instance to track events:

import { pintail } from '@basetime/pintail-sdk-ts';

// The first argument is the campaign codename.
// The second argument is the event extras and can be anything
// you want to send to the event endpoint.
await pintail.track('tic6QBYHSJDdd55ao', {
  plan: 'pro',
  referrer: 'newsletter',
  vip: true,
});

The optional third argument lets you forward the originating client request so the event is attributed to the end user instead of your server. Pass an object containing the request headers and the client ip:

import { pintail } from '@basetime/pintail-sdk-ts';

// Example using an Express-style request object.
app.post('/signup', async (req, res) => {
  await pintail.track(
    'tic6QBYHSJDdd55ao',
    {
      plan: 'pro',
      referrer: 'newsletter',
      vip: true,
    },
    {
      headers: req.headers,
      ip: req.ip,
    },
  );

  res.sendStatus(204);
});

Browser Side

Using the client in the browser:

<!-- Begin Pintail Code -->
<script>
  (function(t,n,i,r){
    t.pintail=t.pintail||{q:[],track:function(){t.pintail.q.push(arguments)}};
    var e=n.createElement(i);e.async=!0,e.src=r;
    var a=n.getElementsByTagName(i)[0];a.parentNode.insertBefore(e,a)
  })(window,document,"script","https://cdn.pintail.io/event/latest.js");

  // The first argument is the campaign codename.
  // The second argument is the event extras and can be anything
  // you want to send to the event endpoint.
  pintail.track('tic6QBYHSJDdd55ao', {
    plan: 'pro',
    referrer: 'newsletter',
    vip: true,
  });
</script>
<!-- End Pintail Code -->

Place this snippet anywhere in your HTML (including <head>). The loader installs a window.pintail stub immediately, so any pintail.track(...) calls you make are queued and replayed once the bundle finishes downloading. The script is loaded asynchronously and does not block page rendering.

Note: when you call pintail.track(...) before the bundle has loaded, the call is queued and returns undefined (not a Promise). After the bundle loads, calls return Promise<{ success: boolean }> as documented under API.

Reliability and error handling

track() is built to be safe to call from anywhere — it never throws and never rejects. Any transport, serialization, timeout, or server-side error is surfaced through console.warn and reported back as { success: false }, so you can use it inside event handlers, lifecycle hooks, and unload paths without try/catch.

In the browser, the SDK prefers navigator.sendBeacon when available, which is highly reliable through corporate proxies and during page unload. Because sendBeacon is fire-and-forget, a { success: true } result on that path reflects a successful enqueue rather than a server acknowledgement. When sendBeacon is unavailable or refuses the payload, the SDK falls back to fetch with a 5-second timeout and a CORS-safelisted content type so the request does not trigger a preflight OPTIONS.