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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@orbit-js/sdk

v1.1.5

Published

Official Orbit SDK for JavaScript/TypeScript

Downloads

29

Readme

@orbit-js/sdk

Official Orbit SDK for JavaScript/TypeScript

✨ Funciona com Next.js e REST APIs - Integração simplificada para aplicações Next.js e APIs REST em geral.

Installation

npm install @orbit-js/sdk
# or
yarn add @orbit-js/sdk
# or
pnpm add @orbit-js/sdk

Quick Start

Environment Variables

First, add these environment variables to your .env file:

ORBIT_API_KEY=your-api-key-here
ORBIT_API_URL=https://orbit.vercel.app

# Optional
ORBIT_DEBUG=false

Basic Usage

import { OrbitClient } from '@orbit-js/sdk';

const orbit = new OrbitClient({
  apiKey: process.env.ORBIT_API_KEY!,
  apiUrl: process.env.ORBIT_API_URL!,
});

// Track an event
orbit.event('user_signup', {
  plan: 'premium',
  source: 'landing_page',
});

// Track a metric
orbit.metric('revenue', 99.99, {
  currency: 'USD',
  plan: 'premium',
});

// Track an error
try {
  // your code
} catch (error) {
  orbit.error(error as Error, {
    userId: user.id,
  });
}

Configuration

const orbit = new OrbitClient({
  apiKey: 'your-api-key',              // Required - Your Orbit API key
  apiUrl: 'https://orbit.vercel.app',  // Required - Orbit API URL
  bufferSize: 100,                     // Optional (default: 100)
  flushInterval: 30000,                // Optional (default: 30000ms)
  debug: false,                        // Optional (default: false)
  disabled: false,                     // Optional (default: false)
});

Configuration Options

  • apiKey (required): Your Orbit API key. Get it from your Orbit dashboard.
  • apiUrl (required): The Orbit API URL where events will be sent. Use https://orbit.vercel.app for production.
  • bufferSize: Maximum number of events to buffer before auto-flushing.
  • flushInterval: Time in milliseconds between automatic flushes.
  • debug: Enable debug logging to console.
  • disabled: Disable all tracking (useful for development).

API

event(name: string, properties?: object)

Track a custom event.

orbit.event('button_clicked', {
  button_id: 'cta-signup',
  page: '/pricing',
});

metric(name: string, value: number, dimensions?: object)

Track a numeric metric.

orbit.metric('api_response_time', 245, {
  endpoint: '/api/users',
  method: 'GET',
});

error(error: Error, context?: object)

Track an error.

orbit.error(new Error('Payment failed'), {
  userId: '123',
  amount: 99.99,
});

performance(name: string, duration: number, metadata?: object)

Track a performance metric.

orbit.performance('page_load', 1250, {
  page: '/dashboard',
});

flush(): Promise<void>

Manually flush all pending events.

await orbit.flush();

shutdown(): Promise<void>

Stop the client and flush pending events.

await orbit.shutdown();

Automatic Tracking (Middleware)

New in v1.1.4+ - Automatically track all HTTP requests with Next.js middleware.

Quick Setup

Create middleware.ts in your project root:

import { createOrbitMiddleware, defaultMatcher } from '@orbit-js/sdk/middleware';

export const middleware = createOrbitMiddleware({
  apiKey: process.env.ORBIT_API_KEY!,
  apiUrl: 'https://orbit.yourdomain.com', // Required
  workspaceId: process.env.ORBIT_WORKSPACE_ID,
});

export const config = {
  matcher: defaultMatcher,
};

What's Tracked Automatically

  • ✅ All page views
  • ✅ All API calls
  • ✅ Response times
  • ✅ Status codes
  • ✅ Geographic data (country, city, region)
  • ✅ User agent information
  • ✅ IP addresses (anonymized)

Edge Runtime Compatible

The middleware is fully compatible with Next.js Edge Runtime and Vercel Edge Functions.

📖 Full Documentation: See MIDDLEWARE_SETUP.md for complete setup guide and advanced configuration.

TypeScript

The SDK is written in TypeScript and includes full type definitions.

import { OrbitClient, OrbitConfig, Metric } from '@orbit-js/sdk';
import { createOrbitMiddleware, defaultMatcher } from '@orbit-js/sdk/middleware';

License

MIT © Orbit Team