Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add feature flag mechanism #321

Merged
merged 2 commits into from
Nov 15, 2024
Merged

Conversation

twrichards
Copy link
Collaborator

@twrichards twrichards commented Nov 5, 2024

As a pre-requisite to #312 we needed a way for users to gradually enrol into the new functionality as they receive 'training', which needed to persist across machines and work consistently in different tools, so storing a new column in the DB seemed sensible ...

  • new JSONB column, called featureFlags on the User table
  • becomes a field of the MyUser type (just a JSON string, parsed in the client)
  • parsed feautureFlags shared around the app via the GlobalStateContext
  • new GraphQL mutation changeFeatureFlag which writes key/values to the featureFlags JSONB column
  • consumes changes to feature flags via query params with prefix pinboardFeatureFlag_, dropping them from URL once the new mutation changeFeatureFlag has been called with the new value (true or false) -- this allows trainers to provide a URL with feature flag query param to users and then it will remain on for the user indefinitely following their training
  • renames/broadens the GraphQL subscription onManuallyOpenedPinboardIdsChanged to become onMyUserChanges and now fires based on the new mutation too, which allows all connected clients to hear about changes to featureFlags and react accordingly

add new database column script run against:

  • CODE
  • PROD

…pe (as json string) and updated via new mutation `changeFeatureFlag`
@twrichards twrichards force-pushed the feature-flagging-via-users-DB-table branch from 6657969 to 4e2ee67 Compare November 5, 2024 10:42
@twrichards twrichards force-pushed the feature-flagging-via-users-DB-table branch from 4e2ee67 to 6337e7e Compare November 5, 2024 10:45
@twrichards twrichards marked this pull request as ready for review November 5, 2024 11:22
@twrichards twrichards requested a review from a team as a code owner November 5, 2024 11:22
Copy link
Member

@andrew-nowak andrew-nowak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code lgtm
tested on code, also looks good, though worth noting that I initially get "undefined" as the value of my feature flag
image
I think that's expected behaviour, but may need bearing in mind for any usages of the feature flags

@twrichards twrichards merged commit aa3ff0d into main Nov 15, 2024
3 checks passed
@twrichards twrichards deleted the feature-flagging-via-users-DB-table branch November 15, 2024 12:49
@prout-bot
Copy link
Collaborator

Seen on PROD (merged by @twrichards 4 minutes and 15 seconds ago) Please check your changes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants