1.0.6 • Published 4 years ago

bullet-train-nodejs v1.0.6

Weekly downloads
373
License
MIT
Repository
github
Last release
4 years ago

Bullet Train Client

Gitter npm version npm.io

The SDK clients for NodeJS https://bullet-train.io/. Bullet Train allows you to manage feature flags and remote config across multiple projects, environments and organisations.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See running in production for notes on how to deploy the project on a live system.

Installing

VIA npm

npm i bullet-train-nodejs --save

Usage

Retrieving feature flags for your project

For full documentation visit https://docs.bullet-train.io

var bulletTrain = require("bullet-train-nodejs");

bulletTrain.init({
    environmentID:"<YOUR_ENVIRONMENT_KEY>"
});

bulletTrain.hasFeature("header", '<My User Id>')
.then((featureEnabled) => {
    if (featureEnabled) {
        //Show my awesome cool new feature to this one user
    }
});
bulletTrain.hasFeature("header")
.then((featureEnabled) => {
    if (featureEnabled) {
        //Show my awesome cool new feature to the world
    }
});

bulletTrain.getValue("header", '<My User Id>')
.then((value) => {
    //Show some unique value to this user
});

bulletTrain.getValue("header")
.then((value) => {
    //Show a value to the world
});

Available Options

PropertyDescriptionRequiredDefault Value
environmentIDDefines which project environment you wish to get flags for. example ACME Project - Staging.YESnull
onErrorCallback function on failure to retrieve flags. (error)=>{...}NOnull
defaultFlagsDefines the default flags if there are anyNOnull
apiUse this property to define where you're getting feature flags from, e.g. if you're self hosting.NOhttps://bullet-train-api.dokku1.solidstategroup.com/api/v1/

Available Functions

PropertyDescription
initInitialise the sdk against a particular environment
hasFeature(key)Get the value of a particular feature e.g. bulletTrain.hasFeature("powerUserFeature") // true
hasFeature(key, userId)Get the value of a particular feature for a user e.g. bulletTrain.hasFeature("powerUserFeature", 1234) // true
getValue(key)Get the value of a particular feature e.g. bulletTrain.getValue("font_size") // 10
getValue(key, userId)Get the value of a particular feature for a specificed userId e.g. bulletTrain.getValue("font_size", 1234) // 15
getFlags()Trigger a manual fetch of the environment features, if a user is identified it will fetch their features
getFlagsForUser(userId)Trigger a manual fetch of the environment features with a given userId
setTrait(userId, key, value)Set the name/value pair for the specified userId
getTrait(userId, key)Retrieve the value for the specified userId and Trait key

Identifying users

Identifying users allows you to target specific users from the Bullet Train dashboard. You can include an optional user identifier as part of the hasFeature and getValue methods to retrieve unique user flags and variables.

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Getting Help

If you encounter a bug or feature request we would like to hear about it. Before you submit an issue please search existing issues in order to prevent duplicates.

Get in touch

If you have any questions about our projects you can email support@bullet-train.io.

Useful links

Website

Documentation

Code Examples

Youtube Tutorials

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

5 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago

1.0.0

6 years ago