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

@rollgate/sdk-node

v1.2.1

Published

Rollgate Node.js SDK

Readme

@rollgate/sdk-node

CI npm version License: MIT

Official Node.js SDK for Rollgate - Feature flags made simple.

Requirements

  • Node.js 18+

Installation

npm install @rollgate/sdk-node

Quick Start

import { RollgateClient } from "@rollgate/sdk-node";

const client = new RollgateClient({
  apiKey: "sb_server_your_api_key",
});

await client.init();

if (client.isEnabled("new-checkout-flow")) {
  // New feature code
}

Configuration

const client = new RollgateClient({
  apiKey: "sb_server_your_api_key", // Required
  baseUrl: "https://api.rollgate.io", // Optional
  refreshInterval: 60000, // Polling interval in ms (0 to disable)
  enableStreaming: false, // Enable SSE for real-time updates
  events: {
    flushIntervalMs: 30000, // Event flush interval (default: 30s)
    maxBufferSize: 100, // Max buffered events before flush (default: 100)
  },
});

User Targeting

// Initialize with user context
await client.init({
  id: "user-123",
  email: "[email protected]",
  attributes: { plan: "premium" },
});

// Or identify later
await client.identify({
  id: "user-456",
  attributes: { country: "US" },
});

API

| Method | Description | | -------------------------------- | ------------------------------------------- | | init(user?) | Initialize client and fetch flags | | isEnabled(key, default?) | Check if a flag is enabled | | isEnabledDetail(key, default?) | Check flag with evaluation reason | | getValue(key, default) | Get typed flag value | | getString(key, default?) | Get string flag value | | getNumber(key, default?) | Get number flag value | | getJSON(key, default) | Get JSON flag value | | getValueDetail(key, default) | Get typed flag value with evaluation reason | | getAllFlags() | Get all flags as object | | identify(user) | Update user context | | reset() | Clear user context | | refresh() | Force refresh flags | | track(options) | Track a conversion event for A/B testing | | flushEvents() | Force flush buffered conversion events | | getEventStats() | Get event buffer stats | | close() | Clean up resources |

Evaluation Reasons

Get detailed information about why a flag evaluated to a particular value:

const detail = client.isEnabledDetail("my-flag", false);
console.log(detail.value); // boolean
console.log(detail.reason.kind); // "OFF" | "TARGET_MATCH" | "RULE_MATCH" | "FALLTHROUGH" | "ERROR" | "UNKNOWN"

Reason kinds:

| Kind | Description | | -------------- | ---------------------------------- | | OFF | Flag is disabled | | TARGET_MATCH | User is in the flag's target list | | RULE_MATCH | User matched a targeting rule | | FALLTHROUGH | Default rollout (no rules matched) | | ERROR | Error during evaluation | | UNKNOWN | Flag not found |

Events

client.on("ready", () => {
  /* Client initialized */
});
client.on("flag-changed", (key, newValue, oldValue) => {
  /* Flag changed */
});
client.on("flags-updated", (flags) => {
  /* Flags refreshed */
});
client.on("error", (error) => {
  /* Error occurred */
});
client.on("events-flush", (data) => {
  /* Conversion events flushed */
});
client.on("events-error", (err) => {
  /* Event tracking error */
});

Event Tracking

Track conversion events for A/B testing experiments:

// Track a conversion event
client.track({
  flagKey: "checkout-redesign",
  eventName: "purchase",
  userId: "user-123",
  variationId: "variant-b",
  value: 29.99,
  metadata: { currency: "EUR" },
});

// Force flush pending events (events auto-flush every 30s)
await client.flushEvents();

// Get event buffer stats
const stats = client.getEventStats();
console.log(stats.eventCount); // number of buffered events

TrackEventOptions

| Property | Type | Required | Description | | ------------- | ------------------------- | -------- | ------------------------------------------ | | flagKey | string | Yes | The flag key this event is associated with | | eventName | string | Yes | Event name (e.g., purchase, signup) | | userId | string | Yes | User ID | | variationId | string | No | Variation ID the user was exposed to | | value | number | No | Numeric value (e.g., revenue amount) | | metadata | Record<string, unknown> | No | Additional event metadata |

Events are buffered in memory and sent in batches. The buffer auto-flushes every 30 seconds (configurable via events.flushIntervalMs) or when the buffer reaches 100 events (configurable via events.maxBufferSize). On close(), remaining events are flushed automatically.

Documentation

Full documentation: docs.rollgate.io

About Rollgate

Rollgate is a feature management platform that helps teams release features safely with gradual rollouts, user targeting, and instant kill switches.

License

MIT