Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
bullet-train-client
Advanced tools
Readme
The SDK clients for web and React Native for https://bullet-train.io/. Bullet Train allows you to manage feature flags and remote config across multiple projects, environments and organisations.
For full documentation visit https://docs.bullet-train.io/clients/javascript/
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.
npm i bullet-train-client --save
Retrieving feature flags for your project
import bulletTrain from "bullet-train-client"; //Add this line if you're using bulletTrain via npm
bulletTrain.identify("bullet_train_sample_user");
bulletTrain.init({
environmentID:"<YOUR_ENVIRONMENT_KEY>",
cacheFlags: true,
onChange: (oldFlags,params)=>{ //Occurs whenever flags are changed
const {isFromServer} = params; //determines if the update came from the server or local cached storage
//Check for a feature
if (bulletTrain.hasFeature("myCoolFeature")){
myCoolFeature();
}
//Or, use the value of a feature
const bannerSize = bulletTrain.getValue("bannerSize");
//Check whether value has changed
const bannerSizeOld = oldFlags["bannerSize"] && oldFlags["bannerSize"].value;
if (bannerSize !== bannerSizeOld) {
}
}
});
Initialisation options
Property | Description | Required | Default Value |
---|---|---|---|
environmentID | Defines which project environment you wish to get flags for. example ACME Project - Staging. | YES | null |
onChange | Your callback function for when the flags are retrieved (flags,{isFromServer:true/false})=>{...} | YES | null |
onError | Callback function on failure to retrieve flags. (error)=>{...} | null | |
cacheFlags | Any time flags are retrieved they will be cached, flags and identities will then be retrieved from local storage before hitting the API ``` | null | |
enableLogs | Enables logging for key bullet train events ``` | null | |
defaultFlags | Allows you define default features, these will all be overridden on first retrieval of features. | null | |
api | Use this property to define where you're getting feature flags from, e.g. if you're self hosting. | https://featureflagger.3qqe.flynnhub.com/api/ |
Available Functions
Property | Description |
---|---|
init | Initialise the sdk against a particular environment |
hasFeature(key) | Get the value of a particular feature e.g. bulletTrain.hasFeature("powerUserFeature") // true |
getValue(key) | Get the value of a particular feature e.g. bulletTrain.getValue("font_size") // 10 |
getTrait(key) | Once used with an identified user you can get the value of any trait that is set for them e.g. bulletTrain.getTrait("accepted_cookie_policy") |
setTrait(key, value) | Once used with an identified user you can set the value of any trait relevant to them e.g. bulletTrain.setTrait("accepted_cookie_policy", true) |
setTraits(object) | Set multiple traits e.g. bulletTrain.setTraits({foo:"bar",numericProp:1,boolProp:true}) . Setting a value of null for a trait will remove that trait. |
incrementTrait(key, value) | You can also increment/decrement a particular trait them e.g. bulletTrain.incrementTrait("click_count", 1) |
startListening(ticks=1000) | Poll the api for changes every x milliseconds |
stopListening() | Stop polling the api |
getFlags() | Trigger a manual fetch of the environment features, if a user is identified it will fetch their features |
identify(userId) | Identify as a user, this will create a user for your environment in the dashboard if they don't exist, it will also trigger a call to getFlags() |
logout() | Stop identifying as a user, this will trigger a call to getFlags() |
identify
, setTrait
and setTraits
all trigger calls to getFlags
, which in turn hits the get flags endpoint. This is due to identities and traits affecting flags that are returned.
However, you can avoid these extra calls to get flags if you call these functions before bulletTrain.init
.
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
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.
If you have any questions about our projects you can email projects@solidstategroup.com.
FAQs
Feature flagging to support continuous development
The npm package bullet-train-client receives a total of 100 weekly downloads. As such, bullet-train-client popularity was classified as not popular.
We found that bullet-train-client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.