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: add FeatureFlagProvider #353

Merged
merged 1 commit into from
Nov 14, 2024
Merged

Conversation

codeincontext
Copy link
Collaborator

@codeincontext codeincontext commented Nov 7, 2024

Description

In #320 we added server-side generation of feature flags. That populated the initial flags bootstrapped on posthog.init, and we could then query posthog to get the feature flag status

It turns out that this has two problems:

  • Posthog is initialised in a useEffect, so the server render and initial client render don't have information about flags
  • useAnalyticsService only initialises posthog when cookie consent is granted. If the user denies consent or never interacts with the cookie banner, posthog won't work as expected

This PR:

  • Creates FeatureFlagProvider
  • Passes bootstrapped server feature flags to FeatureFlagProvider
  • Makes useClientSideFeatureFlag consume the provider, and fall back to a bootstrapped value if posthog hasn't loaded flags

Testing:

Copy link

vercel bot commented Nov 7, 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 Nov 7, 2024 5:50pm

@codeincontext codeincontext force-pushed the feat/feature-flag-provider branch from 2ee5d29 to f72fa5d Compare November 7, 2024 17:42
Copy link

sonarqubecloud bot commented Nov 7, 2024

Copy link

github-actions bot commented Nov 7, 2024

Playwright test results

passed  14 passed
skipped  1 skipped

Details

report  Open report ↗︎
stats  15 tests across 14 suites
duration  2 minutes, 8 seconds
commit  f72fa5d

Skipped tests

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

@codeincontext codeincontext marked this pull request as ready for review November 7, 2024 17:57
@codeincontext codeincontext requested review from a team, JBR90 and tomwisecodes November 7, 2024 17:58
Copy link
Contributor

@JBR90 JBR90 left a comment

Choose a reason for hiding this comment

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

LGTM, tested the 'cool new feature' and worked as expected

@codeincontext
Copy link
Collaborator Author

LGTM, tested the 'cool new feature' and worked as expected

Great. Thanks Joe

@codeincontext codeincontext merged commit 1d4995e into main Nov 14, 2024
15 checks passed
@codeincontext codeincontext deleted the feat/feature-flag-provider branch November 14, 2024 10:49
@oak-machine-user
Copy link
Collaborator

🎉 This PR is included in version 1.16.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