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

@orville-wang/nomos-sdk

v0.1.1

Published

Official Nomos SDK for event tracking and analytics.

Downloads

142

Readme

@nomos/sdk

Official Nomos SDK for event tracking and analytics. Track user behavior, events, and analytics data with ease.

Features

  • 🚀 Simple and intuitive API
  • 🔒 Secure HMAC-SHA256 request signing
  • 📦 Automatic event batching and queuing
  • 🔄 Automatic retry with exponential backoff
  • 🌐 Works in both browser and Node.js environments
  • 📝 Full TypeScript support
  • ⚡ Lightweight with minimal dependencies

Installation

npm install @nomos/sdk

Or with yarn:

yarn add @nomos/sdk

Or with pnpm:

pnpm add @nomos/sdk

Quick Start

import NomosSDK from '@nomos/sdk';

// Initialize the SDK
const nomos = new NomosSDK({
  projectId: 'your_project_id',
  secretKey: 'your_secret_key',
  apiUrl: 'http://localhost:8504', // Optional, defaults to production
});

// Track an event
await nomos.track('page_view', {
  page: '/home',
  referrer: 'google',
});

// Identify a user after login
nomos.identify('user_01HXXX');

// Track user events
await nomos.track('button_click', {
  button_name: 'subscribe',
  plan: 'premium',
});

API Reference

Constructor

new NomosSDK(config: NomosConfig)

Configuration Options:

| Option | Type | Required | Default | Description | |--------|------|----------|---------|-------------| | projectId | string | Yes | - | Your project ID from Nomos dashboard | | secretKey | string | Yes | - | Secret key for HMAC signature | | apiUrl | string | No | https://api.nomos.com | API base URL | | batchSize | number | No | 10 | Number of events to batch before auto-flush | | flushInterval | number | No | 5000 | Auto-flush interval in milliseconds | | maxRetries | number | No | 3 | Maximum retry attempts for failed requests | | debug | boolean | No | false | Enable debug logging |

Methods

track(eventName, properties?, metadata?)

Track a single event.

await nomos.track('event_name', {
  // Custom properties
  key: 'value',
}, {
  // Optional metadata
  platform: 'web',
  browser: 'Chrome',
});

Parameters:

  • eventName (string): Name of the event
  • properties (object, optional): Custom event properties
  • metadata (object, optional): Device and session metadata

trackBatch(events)

Track multiple events in a batch.

await nomos.trackBatch([
  { event_name: 'event1', properties: { a: 1 } },
  { event_name: 'event2', properties: { b: 2 } },
]);

identify(userId)

Identify a logged-in user.

nomos.identify('user_01HXXX');

Parameters:

  • userId (string): User ID in ULID format (26 characters)

setDistinctId(distinctId)

Set an anonymous user ID.

nomos.setDistinctId('anon_01HXXX');

Parameters:

  • distinctId (string): Anonymous user ID in ULID format (26 characters)

flush()

Manually flush the event queue.

await nomos.flush();

destroy()

Clean up and destroy the SDK instance.

nomos.destroy();

Usage Examples

Basic Event Tracking

import NomosSDK from '@nomos/sdk';

const nomos = new NomosSDK({
  projectId: 'proj_01HXXX',
  secretKey: 'sk_xxxxxxxxxxxxxxxx',
});

// Track page views
await nomos.track('page_view', {
  page: '/products',
  category: 'electronics',
});

// Track button clicks
await nomos.track('button_click', {
  button_id: 'checkout',
  location: 'header',
});

User Identification

// Anonymous user tracking
nomos.track('product_view', {
  product_id: 'prod_123',
});

// User logs in
nomos.identify('user_01HXXX');

// Now events are associated with the user
nomos.track('add_to_cart', {
  product_id: 'prod_123',
  quantity: 1,
});

Batch Tracking

// Track multiple events at once
await nomos.trackBatch([
  {
    event_name: 'page_view',
    properties: { page: '/home' },
  },
  {
    event_name: 'button_click',
    properties: { button: 'signup' },
  },
  {
    event_name: 'form_submit',
    properties: { form: 'newsletter' },
  },
]);

Custom Configuration

const nomos = new NomosSDK({
  projectId: 'proj_01HXXX',
  secretKey: 'sk_xxxxxxxxxxxxxxxx',
  apiUrl: 'https://analytics.example.com',
  batchSize: 20,           // Batch 20 events before auto-flush
  flushInterval: 10000,    // Flush every 10 seconds
  maxRetries: 5,           // Retry up to 5 times
  debug: true,             // Enable debug logging
});

Error Handling

try {
  await nomos.track('event_name', { key: 'value' });
} catch (error) {
  console.error('Failed to track event:', error);
}

// Or use flush to ensure events are sent
await nomos.flush();

Cleanup

// When done, clean up the SDK
nomos.destroy();

Event Structure

Events sent to Nomos have the following structure:

{
  event_id: string;        // Unique event ID (auto-generated)
  event_name: string;      // Event name
  project_id: string;      // Your project ID
  user_id?: string;        // Logged-in user ID (ULID, 26 chars)
  distinct_id?: string;    // Anonymous user ID (ULID, 26 chars)
  timestamp: number;       // Event timestamp in milliseconds
  properties?: object;     // Custom event properties
  metadata?: object;       // Device and session metadata
}

Note: Either user_id or distinct_id must be present. The SDK automatically manages this based on whether you've called identify().

TypeScript Support

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

import NomosSDK, {
  type NomosConfig,
  type Event,
  type EventProperties
} from '@nomos/sdk';

const config: NomosConfig = {
  projectId: 'proj_01HXXX',
  secretKey: 'sk_xxxxxxxxxxxxxxxx',
};

const nomos = new NomosSDK(config);

Development

Install Dependencies

npm install

Run Tests

npm run test

Build

npm run build

Type Check

npm run typecheck

License

MIT

Support

For issues and questions, please visit GitHub Issues.