cal.com icon indicating copy to clipboard operation
cal.com copied to clipboard

feat: Implement flagsmith feature flags

Open ibex088 opened this issue 1 year ago • 7 comments

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_ID in .env with that api-key
  • create these flags in the dashboard, they should be exactly similar to the ones in our Feature table since it will replace those flags if the .env variable is set Screenshot 2024-01-26 at 5 28 49 PM

ibex088 avatar Jan 26 '24 12:01 ibex088

@SomayChauhan is attempting to deploy a commit to the cal Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Jan 26 '24 12:01 vercel[bot]

Thank you for following the naming conventions! 🙏 Feel free to join our discord and post your PR link.

github-actions[bot] avatar Jan 26 '24 12:01 github-actions[bot]

📦 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! 🙌

github-actions[bot] avatar Jan 26 '24 13:01 github-actions[bot]

@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.

sean-brydon avatar Jan 30 '24 08:01 sean-brydon

This PR is being marked as stale due to inactivity.

github-actions[bot] avatar Feb 14 '24 00:02 github-actions[bot]

@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?

keithwillcode avatar Feb 16 '24 15:02 keithwillcode

@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

ibex088 avatar Feb 16 '24 16:02 ibex088

@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.

keithwillcode avatar Feb 27 '24 14:02 keithwillcode