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

feat: use featureFlagGroup claim for feature flags #329

Merged
merged 2 commits into from
Oct 31, 2024

Conversation

codeincontext
Copy link
Collaborator

@codeincontext codeincontext commented Oct 31, 2024

In #320 we added local evaluation of feature flags. Local evaluation calculates the feature flags for the user, but only has user data from the session token. That works for feature flags which are either on or off, but we sometimes want feature flags for a specific group of users, like the AI team or external testers

This work:

  • Adds featureFlagGroup to the labs Clerk metadata. We can manually populate this with ai-team for the team
  • Passes the featureFlagGroup into the feature flag evaluation, so that we can calculate the user's flags without needing their email address

Testing:

  • See that the download-all-button feature flag is enabled for the group ai-team
  • Log in with a user with ai-team set in clerk metadata (I've set it for all of our Oak emails)
  • Load the homepage
    • Look for Bootstrapping feature flags { 'download-all-button': true } in the server log
  • Sign in with another account
    • Look for Bootstrapping feature flags { 'download-all-button': false } in the server log

Copy link

vercel bot commented Oct 31, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
oak-ai-lesson-assistant ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 31, 2024 5:32pm

Copy link

Playwright test results

passed  13 passed
skipped  1 skipped

Details

report  Open report ↗︎
stats  14 tests across 13 suites
duration  1 minute, 48 seconds
commit  759534a

Skipped tests

No persona › tests/auth.test.ts › authenticate through Clerk UI

});

log.info("Bootstrapping feature flags", features);
Copy link
Contributor

Choose a reason for hiding this comment

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

Worth logging some of the new properties here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nice idea. Will do


const distinctId = userId ?? getDistinctIdFromCookie(headers) ?? "0";
log.info("Evaluating feature flags for", distinctId);

const personProperties = sessionClaims?.labs?.featureFlagGroup
Copy link
Contributor

Choose a reason for hiding this comment

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

Is labs already decided? I believe we're using "aila" as the name for everything now

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, we already have a number of keys under labs. It comes from when the teacher squad started their proof of concept for Clerk. They have owa and we have labs. There's no reason why we can't change it, but we'd need some code to read both for a time

Copy link

@codeincontext codeincontext merged commit 6c64c04 into main Oct 31, 2024
8 checks passed
@codeincontext codeincontext deleted the feat/feature-flag-groups branch October 31, 2024 22:06
@oak-machine-user
Copy link
Collaborator

🎉 This PR is included in version 1.14.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

3 participants