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

@flags-sdk/bucket adapter #96

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

@flags-sdk/bucket adapter #96

wants to merge 2 commits into from

Conversation

dferber90
Copy link
Collaborator

@dferber90 dferber90 commented Mar 9, 2025

Usage

Reading the isEnabled status of a feature

// definition
export const exampleFlag = flag<boolean, Context>({
  key: "example-flag",
  description: "An example flag",
  identify,
  adapter: bucketAdapter.feature(/* accepts options passed to bucketClient.getFeature(options) */),
});

// usage
const example = await exampleFlag() // returns a boolean

Reading the feature itself

// definition
export const exampleFlag = flag<
  Feature<FeatureRemoteConfig>,
  Context
>({
  key: "example-flag",
  identify,
  adapter: bucketAdapter.featureConfig(),
});

// usage
const exampleFeature = await exampleFlag()
exampleFeature.isEnabled;
exampleFeature.config.color;
exampleFeature.track()

Caveats (need to be resolved before merging)

  • does not implement a provider as Bucket does not offer an API to load descriptions and available options
  • featureConfig does not work with precompute due to it returning a feature object containing a track function which can't be serialized
  • does not work with Edge Runtime due to node:crypto
  • we should likely rename bucketAdapter.feature() to bucketAdapter.isEnabled()

Copy link

vercel bot commented Mar 9, 2025

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

Name Status Preview Comments Updated (UTC)
flags-sdk-snippets ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 9, 2025 1:36pm
shirt-shop ✅ Ready (Inspect) Visit Preview Mar 9, 2025 1:36pm

Copy link

New dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@bucketco/[email protected] environment, filesystem, network +1 236 kB roncohen1

View full report↗︎

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

Successfully merging this pull request may close these issues.

1 participant