Using Feature Flags/Gates in your app is simple and straightforward. This article will show you a step-by-step process of creating a simple Node.js app that responds to feature gate changes in almost-real-time.
This article assumes you haveĀ npmĀ installed on your dev environment. More detailedĀ documentation is available here.
If you donāt already have an account, create one for free atĀ https://www.statsig.com/Ā and create a new Feature Gate named āFirst AppĀ Testā
The first step to creating the Node app in your command line terminalĀ is:
$ mkdir statsigNodeApp && cd statsigNodeApp
$ npm init --yes
This will create aĀ package.jsonĀ file in theĀ statsigNodeAppĀ directory.
Next, letās install statsig-node SDK.
$ npm install statsig-node
Now, weāre all set to write our main appās logic. Hereās the code that checks the gate we just created every second and writes out whether it passes or not. Copy and paste this into a file namedĀ index.js.
https://medium.com/media/153cc5e35683db3d164c4e419232f32b/href
One last thing is you need to replace the āsecret-API-KEYā with your own API key, which you can find in your projectās settings:
With that replaced, you are ready to run this app by issuing thisĀ command:
$ node index.js
You will see something like this in theĀ output:
This means that the flag is evaluating to āfalseā all the time. Letās go ahead and create a new rule that turns on this feature for everyone.
And letās make sure to hit that āSave ChangesāĀ button.
Now, if we had kept that Node App running, youāll notice that it has started saying āpassedā automatically, since now this feature flag is turned on to everyone.
You can now try turning off this feature in theĀ console.
Which will immediately make the feature fail the check and the app will go from āpassedā to āfailedā to reflect theĀ change.
Hope this was helpful in getting you started and on your way to creating more complex features! As always weāre here to help out. You can join our Slack community here:Ā https://statsig.com/community.
The Statsig <> Azure AI Integration is a powerful solution for configuring, measuring, and optimizing AI applications. Read More ⇾
Take an inside look at how we built Statsig, and why we handle assignment the way we do. Read More ⇾
Learn the takeaways from Ron Kohavi's presentation at Significance Summit wherein he discussed the challenges of experimentation and how to overcome them. Read More ⇾
Learn how the iconic t-test adapts to real-world A/B testing challenges and discover when alternatives might deliver better results for your experiments. Read More ⇾
See how weāre making support faster, smarter, and more personal for every user by automating what we can, and leveraging real, human help from our engineers. Read More ⇾
Marketing platforms offer basic A/B testing, but their analysis tools fall short. Here's how Statsig helps you bridge the gap and unlock deeper insights. Read More ⇾