cal.com
cal.com copied to clipboard
feat: Implement flagsmith feature flags
What does this PR do?
This PR introduces way to release features in a phased roll-out manner. Its a fully opt in feature such that if the env variable is set it fetches flags from flagsmith otherwise it fetches flags from our local db.
Fixes #12598
Type of change
- New feature (non-breaking change which adds functionality)
- This change requires a documentation update (probably)
How should this be tested?
- Go to https://github.com/Flagsmith/flagsmith
- you can either run their docker container or visit their hosted service
- create a new project, this will automatically generate a new api-key
- replace
FLAGSMITH_ENVIRONMENT_IDin .env with that api-key - create these flags in the dashboard, they should be exactly similar to the ones in our
Featuretable since it will replace those flags if the .env variable is set
@SomayChauhan is attempting to deploy a commit to the cal Team on Vercel.
A member of the Team first needs to authorize it.
Thank you for following the naming conventions! 🙏 Feel free to join our discord and post your PR link.
📦 Next.js Bundle Analysis for @calcom/web
This analysis was generated by the Next.js Bundle Analysis action. 🤖
This PR introduced no changes to the JavaScript bundle! 🙌
@zomars i know we've talked about feature flags being a core feature and that we shouldn't rely on another service. LMK what you think - granted we can self host this service.
This PR is being marked as stale due to inactivity.
@SomayChauhan To be able to flight features using Flagsmith, would we need to write some sort of sync tool that lines us Cal.com user accounts with Flagsmith user accounts?
@SomayChauhan To be able to flight features using Flagsmith, would we need to write some sort of sync tool that lines us Cal.com user accounts with Flagsmith user accounts?
no, I believe we don't require any synchronization tool. there are 2 instances of flags, global flags (same for all users) and user specific flags,
initially there will be no user in flagsmith, when we make an request to get the flags for a user using this api, flagsmith will check if this user already exist? If the user exists, it returns the flags for that user. otherwise flagsmith will create an instance of that user on its end, create a new set of flags for that user (which will just be a copy of global flags) and return it to us.
Additionally, notice how we also pass additonal information about user to flagsmith - this information will help us to devide user into groups based on some trait and toggle a feature for that entire group.
now if some information about user was to change lets say his organizationId changes then the next time we call this api we will be passing the update information and flagsmith will update it on its end
@SomayChauhan Amazing contribution. Thanks again. We've decided to close this PR and instead rely on building out these features directly into the app and not rely on a 3rd party. We have ab middleware now as part of the app router migration and we intend to leverage that moving forward for percentage-based flighting of features.