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

@teamofsilicons/space-station-web

v0.1.0

Published

Framework-agnostic browser analytics and events for Space Station.

Readme

@teamofsilicons/space-station-web

Framework-agnostic browser telemetry for React, Solid, Next, vanilla JavaScript, and other web apps.

npm install @teamofsilicons/space-station-web
// Run this in a client mount/effect (for example a client component useEffect/onMount), not while rendering SSR.
import { createSpaceStationWeb } from '@teamofsilicons/space-station-web';

const telemetry = createSpaceStationWeb({
  analyticsTable: 'spacestationfrontendanalytics',
  eventsTable: 'spacestationfrontendevents',
  endpoint: '/api/web/telemetry',
});

telemetry.track('table_created', { table_kind: 'orders' });
// call telemetry.destroy() from the matching unmount cleanup.

analyticsTable enables automatic page views, SPA navigation, errors, scroll depth, navigation timing, network outcomes, and coarse device/browser context. eventsTable is for explicit track() events. Either stream can be disabled by omitting its table. Automatic sampling is controlled with sampleRate (default 1).

The package never adds credentials or an authorization header. Automatic click records contain only the element tag, ARIA role, and an optional explicit data-spacestation-event marker; input contents, text, IDs, URLs with queries, and hashes are excluded. Event data is bounded and non-serializable or oversized values are replaced with a diagnostic marker.

Delivery is bounded: batches contain at most 40 events, the in-memory queue holds at most 200, and a failed batch is retried at most twice. flush() resolves with {sent, failed, dropped, queued} instead of rejecting, so telemetry cannot create an unhandled-rejection loop. Failed sends are retried after five seconds while data remains queued.

Set enabled: false initially or call setEnabled(false) to opt out and clear queued data. Call destroy() when the app is unmounted; it removes listeners, restores history/fetch hooks, cancels timers, and flushes what remains.

The endpoint receives POST {endpoint} with { table, events }. Authentication and authorization remain the host application's responsibility.

Table IDs use the server's lowercase letters and digits grammar; the examples above follow it. Keep the spacestation prefix when creating shared Space Station tables.

Use the same setup in React, Solid, Next, or vanilla JavaScript. In a Next/Solid server route (or any small same-origin proxy), keep the table keys in server environment variables, allowlist the incoming table name, and translate the request to normal ingest:

import { toIngestBatch } from '@teamofsilicons/space-station-web';

// POST /api/web/telemetry: body is { table, events }
const allowed = new Map([
  ['spacestationfrontendanalytics', process.env.SS_ANALYTICS_KEY],
  ['spacestationfrontendevents', process.env.SS_EVENTS_KEY],
]);
if (Number(request.headers.get('content-length') || 0) > 65536) return Response.json({ error: 'telemetry body too large' }, { status: 413 });
const origin = new URL(request.url).origin;
if (request.headers.get('origin') && request.headers.get('origin') !== origin) return Response.json({ error: 'cross-origin telemetry rejected' }, { status: 403 });
let body;
try { body = await request.json(); } catch (_) { return Response.json({ error: 'invalid telemetry JSON' }, { status: 400 }); }
if (JSON.stringify(body).length > 65536) return Response.json({ error: 'telemetry body too large' }, { status: 413 });
const { table, events } = body || {};
const key = allowed.get(table);
if (!key || !Array.isArray(events) || events.length > 40) return Response.json({ error: 'invalid telemetry table or batch' }, { status: 400 });
const ingest = toIngestBatch({ table, key, events });
const response = await fetch(`${process.env.SPACE_STATION_URL}/api/ingest`, {
  method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(ingest),
});
const ack = await response.json();
const rejected = (ack.rejected || []).filter((item) => item.code !== 'duplicate');
return Response.json(ack, { status: response.ok && rejected.length === 0 ? 202 : 400 });

The adapter preserves each event's stable id as metadata.record_id, so normal ingest deduplication also works across retries. Never expose table keys in browser code. The built-in browser sender continues to use /api/web/telemetry by default; change endpoint only when your host provides another same-origin route.