|
| 1 | +<img width="100%" src="https://raw.githubusercontent.com/SolidStateGroup/bullet-train-frontend/master/hero.png"/> |
| 2 | + |
| 3 | +# Bullet Train Client |
| 4 | +[](https://gitter.im/SolidStateGroup/bullettrain?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) |
| 5 | +[](https://badge.fury.io/js/bullet-train-nodejs) |
| 6 | +[](https://www.jsdelivr.com/package/npm/bullet-train-nodejs) |
| 7 | + |
| 8 | +The SDK clients for Ruby [https://bullet-train.io/](https://www.bullet-train.io/). Bullet Train allows you to manage feature flags and remote config across multiple projects, environments and organisations. |
| 9 | + |
| 10 | +## Getting Started |
| 11 | + |
| 12 | +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. |
| 13 | + |
| 14 | +## Installing |
| 15 | + |
| 16 | +### VIA gem |
| 17 | +```gem install bullet-train``` |
| 18 | + |
| 19 | +## Usage |
| 20 | +**Retrieving feature flags for your project** |
| 21 | + |
| 22 | +**For full documentation visit [https://docs.bullet-train.io](https://docs.bullet-train.io)** |
| 23 | +```javascript |
| 24 | +var bulletTrain = require("bullet-train-nodejs"); |
| 25 | + |
| 26 | +bulletTrain.init({ |
| 27 | + environmentID:"<YOUR_ENVIRONMENT_KEY>" |
| 28 | +}); |
| 29 | + |
| 30 | + |
| 31 | +bulletTrain.hasFeature("header", '<My User Id>') |
| 32 | +.then((featureEnabled) => { |
| 33 | + if (featureEnabled) { |
| 34 | + //Show my awesome cool new feature to this one user |
| 35 | + } |
| 36 | +}); |
| 37 | +bulletTrain.hasFeature("header") |
| 38 | +.then((featureEnabled) => { |
| 39 | + if (featureEnabled) { |
| 40 | + //Show my awesome cool new feature to the world |
| 41 | + } |
| 42 | +}); |
| 43 | + |
| 44 | +bulletTrain.getValue("header", '<My User Id>') |
| 45 | +.then((value) => { |
| 46 | + //Show some unique value to this user |
| 47 | +}); |
| 48 | + |
| 49 | +bulletTrain.getValue("header") |
| 50 | +.then((value) => { |
| 51 | + //Show a value to the world |
| 52 | +}); |
| 53 | +``` |
| 54 | +**Available Options** |
| 55 | + |
| 56 | +| Property | Description | Required | Default Value | |
| 57 | +| ------------- |:-------------:| -----:| -----:| |
| 58 | +| ```environmentID``` | Defines which project environment you wish to get flags for. *example ACME Project - Staging.* | **YES** | null |
| 59 | +| ```onError``` | Callback function on failure to retrieve flags. ``` (error)=>{...} ``` | **NO** | null |
| 60 | +| ```defaultFlags``` | Defines the default flags if there are any | **NO** | null |
| 61 | +| ```api``` | Use this property to define where you're getting feature flags from, e.g. if you're self hosting. | **NO** | https://bullet-train-api.dokku1.solidstategroup.com/api/v1/ |
| 62 | + |
| 63 | +**Available Functions** |
| 64 | + |
| 65 | +| Property | Description | |
| 66 | +| ------------- |:-------------:| |
| 67 | +| ```init``` | Initialise the sdk against a particular environment |
| 68 | +| ```hasFeature(key)``` | Get the value of a particular feature e.g. ```bulletTrain.hasFeature("powerUserFeature") // true``` |
| 69 | +| ```hasFeature(key, userId)``` | Get the value of a particular feature for a user e.g. ```bulletTrain.hasFeature("powerUserFeature", 1234) // true``` |
| 70 | +| ```getValue(key)``` | Get the value of a particular feature e.g. ```bulletTrain.getValue("font_size") // 10``` |
| 71 | +| ```getValue(keym userId)``` | Get the value of a particular feature for a specificed user e.g. ```bulletTrain.getValue("font_size", 1234) // 15``` |
| 72 | +| ```getFlags()``` | Trigger a manual fetch of the environment features, if a user is identified it will fetch their features |
| 73 | +| ```getFlagsForUser(1234)``` | Trigger a manual fetch of the environment features with a given user id |
| 74 | + |
| 75 | + |
| 76 | +**Identifying users** |
| 77 | + |
| 78 | +Identifying users allows you to target specific users from the [Bullet Train dashboard](https://www.bullet-train.io/). |
| 79 | +You can include an optional user identifier as part of the `hasFeature` and `getValue` methods to retrieve unique user flags and variables. |
| 80 | + |
| 81 | + |
| 82 | +## Contributing |
| 83 | + |
| 84 | +Please read [CONTRIBUTING.md](https://gist.github.com/kyle-ssg/c36a03aebe492e45cbd3eefb21cb0486) for details on our code of conduct, and the process for submitting pull requests to us. |
| 85 | + |
| 86 | +## Getting Help |
| 87 | + |
| 88 | +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. |
| 89 | + |
| 90 | +## Get in touch |
| 91 | + |
| 92 | +If you have any questions about our projects you can email < a href= "mailto:[email protected]"> [email protected]</ a>. |
0 commit comments