New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@unrevealed/node

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@unrevealed/node

Unrevealed SDK for Node

  • 0.2.1
  • npm
  • Socket score

Version published
Weekly downloads
147
increased by56.38%
Maintainers
1
Weekly downloads
 
Created
Source

Node SDK

The Node SDK helps you integrate Unrevealed in a Node server.

For Node.js in a serverless environment, check the serverless SDK instead.

Getting Started

npm install @unrevealed/node
yarn add @unrevealed/node
pnpm install @unrevealed/node

Usage

UnrevealedClient

The Unrevealed client takes an UnrevealedClientOptions object as a parameter:

const client = new UnrevealedClient({
  apiKey: UNREVEALED_API_KEY,
  logger: customLogger,
  defaults: {
    'feature-a': true,
  },
});
OptionTypeNote
apiKey*stringGenerate a Server API key on Unrevealed
loggerUnrevealedLoggerAn optional custom logger (compatible with winston loggers)
defaultsRecord<string, boolean>An optional map of default value for your feature flags. Used if the connection gets lost with the Unrevealed API
connect
await client.connect();

Call this once when initializing your server. The SDK will open a connection to our servers that will receive the rules for your feature flags, and real-time updates when any of those rules change. Rules are stored and evaluated locally, so evaluating feature flags is fast and synchronous.

close
client.close();

Closes the connection with the Unrevealed API.

isFeatureEnabled
client.isFeatureEnabled('feature-b', { user: { id: 'user-id', traits: {...} }, team: { id: 'team-id', traits: {...} } });

Returns true if a feature is enabled for a certain user in a certain team, false otherwise.

ParameterTypeNote
featureKey*stringThe key of the feature you want to check
options.user{ id: string, traits: object }An optional user
options.team{ id: string, traits: object }An optional team
getEnabledFeatures
client.getEnabledFeatures({ user: { id: 'user-id', traits: {...} }, team: { id: 'team-id', traits: {...} } });

Returns an array of the keys of all the features enabled for a certain user in a certain team.

ParameterTypeNote
options.user{ id: string, traits: object }An optional user
options.team{ id: string, traits: object }An optional team
identify
await client.identify({ user: { id: 'user-id', traits: {...} }, team: { id: 'team-id', traits: {...} } });

Identifies a user and its current team. This will make the user and its team show up in the Unrevealed app, allowing you to select them for a beta for example.

Type safety

You can make the identify and isFeatureEnabled functions type safe by using the code generator, and defining the traits of your users and teams in the app.

FAQs

Package last updated on 14 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc