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

@signal-js/node

v1.0.6

Published

Signal SDK for Node.js - Server-side event capture and analytics

Readme

@signal-js/node

Signal SDK for Node.js - Server-side event capture and analytics. Uses @signal-js/core and @signal-js/browser (for HttpEventSink); both are included as dependencies.

Installation

npm install @signal-js/node
# or
pnpm add @signal-js/node
# or
yarn add @signal-js/node

Quick Start

import { createSignalNode } from '@signal-js/node';

const signal = createSignalNode({
  endpoint: 'https://your-api.com',
  apiKey: 'your-api-key',
});

// Capture an event
signal.capture({
  distinctId: 'user-123',
  event: 'purchase_completed',
  properties: {
    amount: 99.99,
    currency: 'USD',
  },
});

// Identify a user
signal.identify({
  distinctId: 'user-123',
  properties: {
    email: '[email protected]',
    name: 'John Doe',
    plan: 'premium',
  },
});

// Associate with a group
signal.group('user-123', 'company', 'acme-corp', {
  name: 'Acme Corp',
  plan: 'enterprise',
});

// Graceful shutdown
await signal.shutdown();

Configuration

const signal = createSignalNode({
  // Required
  endpoint: 'https://your-api.com',
  apiKey: 'your-api-key',
  
  // Optional
  projectId: 'my-project',          // Default: 'default'
  debug: false,                      // Enable debug logging
  flushBatchSize: 20,               // Events per batch
  flushInterval: 10000,             // Flush interval (ms)
  timeout: 30000,                   // Request timeout (ms)
  compression: true,                // Enable gzip compression
});

API

capture(options)

Capture an event.

signal.capture({
  distinctId: 'user-123',
  event: 'page_viewed',
  properties: {
    page: '/dashboard',
    referrer: '/home',
  },
  timestamp: new Date(),  // Optional
  groups: {               // Optional
    company: 'acme-corp',
    team: 'engineering',
  },
});

identify(options)

Identify a user.

signal.identify({
  distinctId: 'user-123',
  properties: {
    email: '[email protected]',
    name: 'John Doe',
    createdAt: '2024-01-01',
  },
});

setPersonProperties(distinctId, properties)

Set user properties.

signal.setPersonProperties('user-123', {
  plan: 'enterprise',
  last_seen: new Date().toISOString(),
});

setPersonPropertiesOnce(distinctId, properties)

Set user properties only if not already set.

signal.setPersonPropertiesOnce('user-123', {
  first_seen: new Date().toISOString(),
});

group(distinctId, groupType, groupKey, properties?)

Associate a user with a group.

signal.group('user-123', 'company', 'acme-corp', {
  name: 'Acme Corp',
  plan: 'enterprise',
  employee_count: 500,
});

groupIdentify(options)

Identify a group (set group properties).

signal.groupIdentify({
  groupType: 'company',
  groupKey: 'acme-corp',
  properties: {
    name: 'Acme Corp',
    plan: 'enterprise',
  },
});

alias(distinctId, alias)

Create an alias for a user.

signal.alias('user-123', 'email:[email protected]');

flush()

Flush all queued events immediately.

await signal.flush();

shutdown()

Gracefully shutdown (flush remaining events).

await signal.shutdown();

Edge Runtime Support

The package includes an edge-compatible build for Cloudflare Workers, Vercel Edge, etc.

// Automatic (runtime detection)
import { createSignalNode } from '@signal-js/node';

// Or explicit edge import
import { createSignalNode } from '@signal-js/node/edge';

Usage Examples

Express.js

import express from 'express';
import { createSignalNode } from '@signal-js/node';

const app = express();
const signal = createSignalNode({
  endpoint: process.env.SIGNAL_ENDPOINT!,
  apiKey: process.env.SIGNAL_API_KEY!,
});

app.post('/api/checkout', async (req, res) => {
  const { userId, amount, items } = req.body;
  
  signal.capture({
    distinctId: userId,
    event: 'checkout_completed',
    properties: { amount, item_count: items.length },
  });
  
  res.json({ success: true });
});

// Graceful shutdown
process.on('SIGTERM', async () => {
  await signal.shutdown();
  process.exit(0);
});

Next.js API Routes

// pages/api/track.ts
import type { NextApiRequest, NextApiResponse } from 'next';
import { createSignalNode } from '@signal-js/node';

const signal = createSignalNode({
  endpoint: process.env.SIGNAL_ENDPOINT!,
  apiKey: process.env.SIGNAL_API_KEY!,
});

export default async function handler(req: NextApiRequest, res: NextApiResponse) {
  if (req.method === 'POST') {
    const { userId, event, properties } = req.body;
    
    signal.capture({
      distinctId: userId,
      event,
      properties,
    });
    
    res.status(200).json({ success: true });
  }
}

License

MIT