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

@devcycle/devcycle-nodejs-sdk

Package Overview
Dependencies
Maintainers
4
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@devcycle/devcycle-nodejs-sdk

The Node SDK for DevCycle!

  • 0.0.0-alpha-3
  • latest
  • npm
  • Socket score

Version published
Maintainers
4
Created
Source

DevCycle NodeJS SDK

The NodeJS SDK for DevCycle!

Installation

Our library can be found on npm and installed by the following:

npm install @devcycle/devcycle-nodejs-sdk

To use in your project, import the initialize function:

Usage

import { DVC, Configuration }  from '@devcycle/devcycle-nodejs-sdk'
const config = new Configuration({
    apiKey: 'your_server_key_here'
})

const instance: DVC = new DVC(config)

User Object

The full user data must be passed into every request. The only required field is the user_id. The rest are optional and may affect the variables and features that are returned from the calls below.

const user = {
    user_id: 'user1',
    name: 'user 1 name',
    customData: {
        customKey: 'customValue'
    }
}

Getting All Features

You can wait on the features to be loaded from our servers by using getFeatures() function. It returns a promise that you can use to wait until features are ready to be used:

    const features = await instance.getFeatures(user)

Grabbing Variable Values

To get values from your Variables, getVariable() is used to fetch variable values using the identifier key coupled with a default value. The default value can be of type string, boolean, number, or object.

const variable = instance.getVariableByKey(user, 'YOUR_VARIABLE_KEY', 'default value')

To grab the value, there is a property on the object returned to grab the value

const variable = {
    _id,
    value,
    key,
    type
}

The variable also contains the variable _id, key, and type. In a situation where the default value is needed (e.g. the user in the request is not part of a feature that controls the variable), then the default value is used. In that case, the variable returned from the function will not contain the _id or type fields.

Grabbing All Variables

To grab all the Variables for a user:

   const variables = await instance.getVariables(user)

FAQs

Package last updated on 15 Nov 2021

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