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

@revhold/node

v1.0.0

Published

Official Node.js SDK for RevHold - AI business assistant for SaaS analytics

Readme

@revhold/node

Official Node.js SDK for RevHold - AI business assistant for SaaS analytics.

Installation

npm install @revhold/node
# or
yarn add @revhold/node

Quick Start

import { RevHold } from '@revhold/node';

const revhold = new RevHold({
  apiKey: process.env.REVHOLD_API_KEY,
});

// Track a usage event
await revhold.trackEvent({
  userId: 'user_123',
  eventName: 'document_created',
  eventValue: 1,
});

// Ask AI a question
const insight = await revhold.askAI({
  question: 'Which users are most engaged this week?',
});
console.log(insight.answer);

API Reference

Constructor

const revhold = new RevHold({
  apiKey: string;       // Required: Your RevHold API key
  baseURL?: string;     // Optional: Override API base URL
});

trackEvent(params)

Track a single usage event.

await revhold.trackEvent({
  userId: 'user_123',           // Required
  eventName: 'feature_used',    // Required
  eventValue: 1,                // Optional, defaults to 1
  timestamp: '2025-01-07T...',  // Optional, defaults to now
});

Returns: Promise<TrackEventResponse>

{
  success: boolean;
  message: string;
  eventId: string;
}

trackBatch(events)

Track multiple events efficiently.

await revhold.trackBatch([
  { userId: 'user_1', eventName: 'feature_used' },
  { userId: 'user_2', eventName: 'document_created' },
  { userId: 'user_3', eventName: 'export_completed' },
]);

Returns: Promise<{ success: boolean; message: string; count: number }>

askAI(params)

Ask the AI a question about your usage data.

const result = await revhold.askAI({
  question: 'Which users are most engaged this week?',
});

console.log(result.answer);      // AI-generated insight
console.log(result.confidence);  // 'high' | 'medium' | 'low'
console.log(result.dataPoints);  // Number of events analyzed

Returns: Promise<AskAIResponse>

{
  answer: string;
  confidence: 'high' | 'medium' | 'low';
  dataPoints: number;
}

getUsage(options?)

Retrieve recent usage events.

const usage = await revhold.getUsage({
  limit: 10,               // Optional: max 1000
  userId: 'user_123',      // Optional: filter by user
});

console.log(usage.events);
console.log(usage.total);

Returns: Promise<GetUsageResponse>

{
  events: Array<{
    eventId: string;
    userId: string;
    eventName: string;
    eventValue: number;
    timestamp: string;
  }>;
  total: number;
  limit: number;
}

Error Handling

The SDK throws RevHoldError for all API errors:

import { RevHold, RevHoldError } from '@revhold/node';

try {
  await revhold.trackEvent({
    userId: 'user_123',
    eventName: 'feature_used',
  });
} catch (error) {
  if (error instanceof RevHoldError) {
    console.error('Status:', error.status);
    console.error('Code:', error.code);
    console.error('Message:', error.message);
    
    if (error.status === 429) {
      console.log('Rate limit - retry after 60s');
    } else if (error.status === 402) {
      console.log('Plan limit reached - upgrade');
    }
  }
}

Error Properties

  • status: number - HTTP status code (401, 402, 429, 500, etc.)
  • code: string - Machine-readable error code
  • message: string - Human-readable error message
  • details?: any - Additional error context

TypeScript Support

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

import type { 
  TrackEventParams,
  AskAIParams,
  TrackEventResponse,
  AskAIResponse,
  UsageEvent,
} from '@revhold/node';

Examples

Track user activity

// When a user creates a document
await revhold.trackEvent({
  userId: req.user.id,
  eventName: 'document_created',
  eventValue: 1,
});

// When a user exports data
await revhold.trackEvent({
  userId: req.user.id,
  eventName: 'data_exported',
  eventValue: 1,
});

Batch tracking

// Track multiple events efficiently
const events = users.map(user => ({
  userId: user.id,
  eventName: 'daily_active',
  eventValue: 1,
}));

await revhold.trackBatch(events);

AI insights

// Get churn insights
const churnAnalysis = await revhold.askAI({
  question: 'Which users are at risk of churning?',
});

// Identify upsell opportunities
const upsellOpportunities = await revhold.askAI({
  question: 'Which trial users are most likely to upgrade?',
});

// Analyze feature adoption
const featureAdoption = await revhold.askAI({
  question: 'What features do power users use most?',
});

Rate Limits

  • Usage events: 1,000 requests/minute
  • AI questions: 10 requests/minute
  • Get usage: 100 requests/minute

Rate limit info is included in error responses:

catch (error) {
  if (error.status === 429) {
    console.log('Retry after:', error.details?.retryAfter);
  }
}

Support

License

MIT