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

@throughlinehq/browser

v0.1.1

Published

Record Throughline Events from a tenant's frontend, for the Contact whose session it is.

Readme

@throughlinehq/browser

Record Throughline Events from your frontend, for the Contact whose session it is.

npm install @throughlinehq/browser

It has no runtime dependencies and ships about 2.5 kB minified and gzipped.

How it fits together

A browser may only record Events. It cannot create, read, export or erase Contacts: that stays on your backend with @throughlinehq/server.

A publishable key alone says which site may record Events, never who is using the page, so anyone could name any Contact. Your server therefore proves the identity by computing an IdentityHash for the signed-in user and handing it to the page.

1. On your server

import { identityHash } from '@throughlinehq/server';

const hash = await identityHash({
  signingSecret: process.env.THROUGHLINE_SIGNING_SECRET!,
  externalId: user.id,
});

Find the signing secret and its key ID under Settings → API keys → Signing secret. Pass the hash, the key ID and the externalId down with the page, or store the hash beside the user: it never changes for a Contact and does not expire.

Never compute the IdentityHash in the browser. Doing so ships the signing secret to every visitor, and any one of them can then record Events as anyone.

2. In the browser

import { ThroughlineBrowserClient } from '@throughlinehq/browser';

const throughline = new ThroughlineBrowserClient({
  publishableKey: 'pk_live_…',
  externalId: user.id,
  identityHash: user.throughlineIdentityHash,
  identityKeyId: user.throughlineIdentityKeyId,
});

await throughline.track({ eventName: 'pricing_viewed', properties: { plan: 'pro' } });

The client defaults to https://browser.api.throughline.dk; you never pass a base URL.

The publishable key is expected to be visible in your bundle and in the network tab. That is safe by design: it can only record Events, only from the origins you list on the key, and only for a Contact your server has signed. Allow only the origins you actually serve from.

What it does not do

  • No anonymous tracking. There is no visitor id, no aliasing and no queue of events recorded before the Contact is known. You supply the identity your application already holds.
  • No cookie and no storage. It sets no cookie and writes no persistent identifier, to localStorage or anywhere else, so adopting it does not oblige you to change your consent banner.
  • No Contact methods. The browser surface has none.

Leaving the page

Events still in flight when the page is hidden or unloaded are re-sent immediately with fetch(…, { keepalive: true }), so they survive navigation. That re-send is a single attempt that never waits on a retry backoff. Each Event keeps its DedupKey, so a re-send of one that had already landed collapses on the server for 60 seconds.

A keepalive request is capped by the browser at 64 kB, so a page that still has more than that in flight when it unloads may lose the excess.

Frameworks

Each adapter only holds one client and shares it with your components. The frameworks are optional peer dependencies, so installing the package pulls in none of them.

React

import { ThroughlineProvider, useThroughline } from '@throughlinehq/browser/react';

<ThroughlineProvider key={user.id} publishableKey="pk_live_…" externalId={user.id} identityHash={user.throughlineIdentityHash} identityKeyId={user.throughlineIdentityKeyId}>
  <App />
</ThroughlineProvider>;

const throughline = useThroughline();

Vue

import { createThroughline, useThroughline } from '@throughlinehq/browser/vue';

createApp(App).use(createThroughline({ publishableKey: 'pk_live_…', externalId: user.id, identityHash, identityKeyId }));

const throughline = useThroughline();

Angular

import { injectThroughline, provideThroughline } from '@throughlinehq/browser/angular';

bootstrapApplication(AppComponent, {
  providers: [provideThroughline({ publishableKey: 'pk_live_…', externalId: user.id, identityHash, identityKeyId })],
});

private readonly throughline = injectThroughline();

Errors

Every error extends ThroughlineError.

| Error | When | | -------------------------------- | ------------------------------------------------------------------------------- | | ThroughlineAuthenticationError | The publishable key, its origin allowlist or this page's origin was rejected. | | ThroughlineScopeError | The IdentityHash does not match externalId, or its key is unknown or revoked. | | ThroughlineRejectedEventsError | The Contact does not exist, so nothing was recorded. | | ThroughlineRateLimitError | The origin's request budget is spent and the call could not be retried in time. | | ThroughlineNetworkError | The API could not be reached, or the call ran out of time. | | ThroughlineInvalidRequestError | The event or an option was malformed. | | ThroughlineServerError | The API answered with a 5xx after the retries were spent. |

Options

| Option | Default | Meaning | | ---------------- | ------------------------------------ | -------------------------------------------------------------------- | | publishableKey | — | The pk_live_… key from Settings → API keys. | | externalId | — | The externalId of the Contact whose session this is. | | identityHash | — | The IdentityHash your server computed for externalId. | | identityKeyId | — | The id of the key whose signing secret produced the hash. | | baseUrl | https://browser.api.throughline.dk | Where the browser API lives. | | fetch | global fetch | A test double or runtime-specific implementation. | | timeoutMs | 10000 | Total time one track call may take, retries included. Under 60000. | | maxRetries | 3 | How many times a failed track call may be retried. |

License

MIT