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

@habeetat/sdk-browser

v0.2.2

Published

Framework-free browser client for Habeetat platform analytics (track, page views, consent)

Readme

@habeetat/sdk-browser

Framework-free browser client for Habeetat platform analytics. Use it on pages that do not run the React SDK — an Astro landing page, a static site — and get the same identity the app uses after login. @habeetat/sdk-react wraps this same client.

npm install @habeetat/sdk-browser

A public page (anonymous events)

<script>
  import { createAnalytics } from '@habeetat/sdk-browser';

  const analytics = createAnalytics({
    // same-origin proxy to the platform's /sdk/ — or https://api.<your-platform-domain>
    platformUrl: '',
    publishableKey: 'hpk_…', // Platform Manager → app → Credentials
    consent: 'pending',      // wait for the cookie banner
  });

  document.querySelector('#cta')?.addEventListener('click', () => analytics.track('cta_clicked'));
  window.addEventListener('cookie-consent', (e) => analytics.setConsent(e.detail ? 'granted' : 'denied'));
</script>

The page's origin must be declared in the app's manifest (spec.capabilities.analytics.anonymousOrigins). Anonymous events carry no user and no tenant — only the browser's anonymous id, which the app's own events carry too after login, so the platform links the landing history to the user without any identify call.

Another domain (a portal that sends visitors to the app)

A first-party id cannot cross domains by itself: the portal on portal.example and the app on app.example would give one visitor two ids. The link carries it.

On the portal, add the id when a link to the app is followed, not in the static href (a copied link would hand the id to whoever opens it):

document.querySelectorAll('a[href^="https://app.example/"]').forEach((a) =>
  a.addEventListener('click', () => { a.href = analytics.linkUrl(a.href); }),
);

linkUrl adds ?hid=<anonymous id> once consent is granted, and leaves the url as it is before that. getAnonymousId() returns the id itself, or null without consent.

On the app's side the client (this one, or @habeetat/sdk-react's) reads hid when it starts. If the value is a UUID, the client:

  • removes it from the address before anything is recorded;
  • adopts it only when this browser has no anonymous id yet;
  • stores it only once consent is granted.

A hid that is not a UUID is left alone. Both sites send to the same app, so the portal's origin goes in the app's anonymousOrigins.

What the client does

| | | |---|---| | Delivery | batches (20 events or 10 s), retries network errors / 503 / 429 with backoff, same messageIds so a retry counts once; queue capped at 1000 | | Identity | anonymous id in localStorage['habeetat.aid']; with cookieDomain also a first-party cookie shared by subdomains; in memory if storage is blocked; from another domain through ?hid= (above) | | Session | rotates after 30 minutes idle, emits $session_start | | Page views | $page_view on load and every pushState / replaceState / back; autoPageViews: false to call page() yourself | | Consent | granted (default) · pending (hold in memory, persist nothing) · denied (discard, stop); setConsent() from your banner; on granted an id the browser already stored wins over the one used while waiting | | Routing | signed in (getAccessToken returns a token) → /sdk/v1/events; else with a key → /sdk/v1/events/anonymous; else hold until sign-in | | Unload | delivers the queue with fetch(..., { keepalive: true }) when the page is hidden | | Refusals | none pending denied blocked origin-not-allowed unknown-key … stop that route for the session with one console warning; never retried |

track() and page() never throw and never wait for delivery. Personal data in properties and end-user consent are the page's responsibility.