Imagine you have an online application, a product, with numerous users hitting your API client-side, and everything seems fine.
But one day, your application encounters a severe bug in the payments section. Someone accidentally discovered a bug that allows infinite money withdrawal on your cashout, and they're withdrawing or attempting to withdraw like crazy. It's as if they're exploiting a GTA5 glitch to generate endless money.
You urgently alert the entire development team about the issue. After discussing it, everyone agrees that until the problem is resolved, it's best to take down the production app to prevent anyone from exploiting the infinite withdrawal glitch.
As a result, you shut down the entire application due to a single bug.
⛳ Feature flags
Imagine if you had a magic button that could disable only one feature (like your cashout in this case) for everyone, allowing you and your team to work more calmly and effectively.
That's exactly where we're heading.
Feature Flags are essentially an if statement that helps minimize damage.
You can implement it natively, creating your backend with various boolean values that are toggled through a custom admin dashboard.
But I'll show you at the end one of the many tools that can make your life easier, especially for indie hackers and self-made developers who lack time and resources.
This way, you can temporarily remove a feature, work on fixing it securely, and once everything is resolved, reintroduce it into the production environment.
More Than Just an If
I know, I initially described it as just an if for simplicity, but it can be more than that.
For instance, you can roll out a feature to only 50% of users, monitor its performance, and then release it to the remaining users.
In an application with 100k users, after fixing the issue, you can release it to 10k users, then another 20k, followed by 30k, and finally, to everyone.
The possibilities are vast when it comes to rolling out features. But the core idea remains the same.
If true, show it. If false, don't show it and move on.
User-Specific Flags
Additionally, you can create flags that carry parameters like user id to make changes for a specific user or a group of users with common characteristics.
This helps maintain your platform and gives you greater control over each user.
PostHog and Tools
One way to save time is by using a ready-made tool.
The best one I've tested so far is PostHog.
I could teach you how to implement it step by step, but honestly, their documentation is so good that it would be redundant for me to explain.
It's the only documentation I've copied and pasted that worked without needing any changes or bug fixes.
https://posthog.com/docs/feature-flags
For Next.js - https://posthog.com/tutorials/nextjs-analytics
Don't Just Disappear
When deactivating a feature, especially if it's a core part of your product like cashout, you shouldn't just make the button disappear and leave your user confused. This could overwhelm your support team due to the missing button.
For better UX, inform your users about what's happening. Ask for their patience and reward them with improvements.
In a chaotic scenario, preparing this way significantly helps reduce damage.
If you enjoy this kind of content and plan to launch your own SaaS someday, follow me for daily content on Twitter and weekly videos on YouTube.
This article will also be available in video format soon on my YouTube channel:
https://youtube.com/@daniellimae
Top comments (0)