Reputation: 3
I want to discuss how do you manage multiple features for different user group on the same service, for instance, there's a Coupon discount
feature we want to release for user groupA, and allow user groupB to use Dark mode
feature, and so on, we can manage a feature table to decide which feature should be open for some group, but we have to add new feature key every single time, and frontend have to do something like (or this is necessary?)
if (isUserA && isFeatureA) {
...
}
if (isUserB && isFeatureB) {
...
}
further more, if the feature is relate to HTML, much more complex it is (especially the project has no framework like vue or react)
<div class="container">
<div id="feature-a"> ... </div>
<div id="feature-b"> ... </div>
</div>
if (isApplyFeatureA) {
FeatureB.parentNode.removeChild(FeatureB)
}
if (isApplyFeatureB) {
FeatureA.parentNode.removeChild(FeatureA)
}
...
once the features getting more and more, it'll be tons of conditions, how do you split feature flags generally ?
Upvotes: 0
Views: 813
Reputation: 961
To do this properly, I'd suggest using a Feature Flag tool. There are quite a few out there, it's one of the things I'd really suggest not building from scratch to reinvent the wheel.
I open sourced one a couple years back called Flagsmith.
With a tool like this the approach would be
1 - On the feature flag service, create a feature you want to manage (Coupon discount)
2 - On the feature flag service, set feature values on a per user basis or on a segment based on their user properties e.g. amount spent > 100.
3 - On your app (server or client side) identify your user against the feature flag service along with any properties you'd want to determine whether they should get featureA/B/N e.g. amount spent identify("userA", {userProperties})
. This would return whether FeatureA/FeatureB would be enabled.
Then you're in a pretty great position as you could modify whether they get a coupon instantly without building any code.
Upvotes: 1