Feature Flag a Checkout Flow
Learn how to wrap a new checkout experience behind a feature flag and roll it out safely.
Prerequisites
- FeatureSignals server running (locally or hosted)
- An API key for your environment
- Node.js SDK installed (
npm install @featuresignals/node)
Step 1: Create the Flag
bash
curl -X POST https://api.featuresignals.com/v1/projects/{projectID}/flags \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"key": "new-checkout", "name": "New Checkout Flow", "type": "boolean", "defaultValue": false}'Step 2: Install and Initialize
javascript
const { FeatureSignals } = require('@featuresignals/node');
const client = new FeatureSignals({
apiKey: process.env.FEATURESIGNALS_API_KEY,
});
await client.initialize();Step 3: Wrap Your Checkout
javascript
app.post('/checkout', async (req, res) => {
const user = req.user;
const useNewCheckout = await client.boolVariation('new-checkout', {
userID: user.id,
email: user.email,
plan: user.plan,
}, false);
if (useNewCheckout) {
return handleNewCheckout(req, res);
}
return handleLegacyCheckout(req, res);
});Step 4: Enable in Staging First
- Go to the Environments tab for the
new-checkoutflag - Select your Staging environment, toggle Enabled to
true - Run your test suite against staging to verify
Step 5: Roll Out to Production
Start with a canary release:
- Select Production environment
- Set percentage to 10% for a canary release
- Monitor error rates and conversion metrics
- Gradually increase to 50%, then 100%
Step 6: Clean Up
javascript
// After cleanup — no more flag check
app.post('/checkout', async (req, res) => {
return handleNewCheckout(req, res);
});