Skip to content

Adds Flagsmith adapter#103

Merged
dferber90 merged 2 commits intovercel:mainfrom
tiagoapolo:adapter-flagsmith
Aug 22, 2025
Merged

Adds Flagsmith adapter#103
dferber90 merged 2 commits intovercel:mainfrom
tiagoapolo:adapter-flagsmith

Conversation

@tiagoapolo
Copy link
Contributor

@tiagoapolo tiagoapolo commented Mar 13, 2025

This pull request introduces a new provider adapter for the Flags SDK that integrates with Flagsmith. The changes include adding configuration files, updating dependencies, and creating the necessary code for the adapter.

Flagsmith documentation: https://docs.flagsmith.com/clients/next-ssr

Usage

import { createFlagsmithAdapter } from '@flags-sdk/adapter-flagsmith';
import { flag } from 'flags';

// Create the Flagsmith adapter
const flagsmithAdapter = createFlagsmithAdapter({
  environmentID: 'your-environment-id',
  // Optional: Add any other Flagsmith configuration options
  // See: https://docs.flagsmith.com/clients/javascript/
});

// Define your flags
const myFeatureFlag = flag({
  key: 'my-feature',
  adapter: flagsmithAdapter,
});

// Use the flag in your application
const flag = await myFeatureFlag();

@vercel
Copy link
Contributor

vercel bot commented Mar 13, 2025

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

A member of the Team first needs to authorize it.

@socket-security
Copy link

socket-security bot commented Mar 13, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedflagsmith@​9.0.51001008095100

View full report

@tiagoapolo tiagoapolo marked this pull request as ready for review March 14, 2025 14:08
@tiagoapolo tiagoapolo marked this pull request as draft March 14, 2025 14:08
@tiagoapolo tiagoapolo marked this pull request as ready for review March 14, 2025 14:11
Copy link
Collaborator

@dferber90 dferber90 left a comment

Choose a reason for hiding this comment

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

Thank you for your contributions so far! I left a bit of early guidance

@@ -0,0 +1,64 @@
# Flags SDK - Flagsmith Provider

A provider adapter for the Flags SDK that integrates with [Flagsmith](https://flagsmith.com/), allowing you to use Flagsmith's feature flags and remote configuration in your application.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you work for Flagsmith? If we merge this PR we'd also put up some actual docs on flags-sdk.dev. Would you be wiling to link to our Flags SDK and those docs from https://docs.flagsmith.com?

Choose a reason for hiding this comment

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

Hey @dferber90, just jumping in here since Tiago is on vacation - yes, Tiago works for Flagsmith.

In answer to your question, for sure, we'd be happy to link to your docs from https://docs.flagsmith.com - would you be happy with adding reciprocal backlink(s) too?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Great! We'd add you to https://flags-sdk.dev/providers and create a docs page for FlagSmith

@tiagoapolo
Copy link
Contributor Author

@dferber90 could you take one more look at my PR ?

@dferber90
Copy link
Collaborator

@tiagoapolo I‘m out of office this week, but @AAorris will take over leading adapter work and help you get this finalized, listed and released 👍

Copy link
Contributor

@AAorris AAorris left a comment

Choose a reason for hiding this comment

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

Thanks for your PR! Please consider the following input:

Strongly recommended:

  • Support identity through entities
  • Optimize performance for multiple features in one request

Recommended:

  • Add origin to link flags to your customers' dashboards

@dferber90 dferber90 removed their request for review April 21, 2025 07:05
@tiagoapolo tiagoapolo requested review from AAorris and dferber90 April 29, 2025 21:04
Copy link
Contributor

@AAorris AAorris left a comment

Choose a reason for hiding this comment

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

The progress here is looking good!

It looked ready enough while reviewing that I started to explore an example app using the adapter. However, I found several issues while testing in an app.

To continue the review with me, please develop an example that uses the adapter based on an existing one

You can build, test, and deploy the demo using your local adapter code by following these instructions

Please share a link to the example app with your next review request. I look forward to it!

@tiagoapolo
Copy link
Contributor Author

@AAorris in this branch you have my example running https://github.com/tiagoapolo/examples/tree/flagsmith-adapter. Also it's deployed in vercel at: https://flags-sdk-template-ff5v5lyuk-tiagos-projects-e9d5728f.vercel.app/
Here's quick demo:

flags_compressed.mov

@tiagoapolo tiagoapolo requested a review from AAorris May 6, 2025 22:34
@AAorris
Copy link
Contributor

AAorris commented May 28, 2025

Hi @tiagoapolo, thanks for your work and sorry for the delay. I'm back and will be reviewing this week if possible.

I don't see your code pushed up to the branch, could you make sure it's available for me to reproduce?

It would be great if the example shows how to replicate the flags in the same way as other examples:

  • Free Delivery: 50% staged feature rollout by ID
  • Summer Sale: 50% staged feature rollout by ID
  • Proceed to Checkout: "red" | "green" | "blue" multivariant string staged 33% each by ID
  • Dev tools widget is able to update the ID to see different variants

@tiagoapolo
Copy link
Contributor Author

Hi @tiagoapolo, thanks for your work and sorry for the delay. I'm back and will be reviewing this week if possible.

I don't see your code pushed up to the branch, could you make sure it's available for me to reproduce?

It would be great if the example shows how to replicate the flags in the same way as other examples:

  • Free Delivery: 50% staged feature rollout by ID
  • Summer Sale: 50% staged feature rollout by ID
  • Proceed to Checkout: "red" | "green" | "blue" multivariant string staged 33% each by ID
  • Dev tools widget is able to update the ID to see different variants

Hi @AAorris I'll add an example replicating that and let you know once it's available.

@tiagoapolo
Copy link
Contributor Author

Hi @tiagoapolo, thanks for your work and sorry for the delay. I'm back and will be reviewing this week if possible.

I don't see your code pushed up to the branch, could you make sure it's available for me to reproduce?

It would be great if the example shows how to replicate the flags in the same way as other examples:

  • Free Delivery: 50% staged feature rollout by ID
  • Summer Sale: 50% staged feature rollout by ID
  • Proceed to Checkout: "red" | "green" | "blue" multivariant string staged 33% each by ID
  • Dev tools widget is able to update the ID to see different variants
  • Free Delivery

@AAorris is the split done on your end?

@AAorris
Copy link
Contributor

AAorris commented Jun 6, 2025

The split is usually done in the flag provider, ex. a feature flag with "a percentage rollout based on distinct user IDs" configured in your dashboard, or "an A/B test with 50% allocation to the test variant"

@tiagoapolo
Copy link
Contributor Author

tiagoapolo commented Jun 10, 2025

The split is usually done in the flag provider, ex. a feature flag with "a percentage rollout based on distinct user IDs" configured in your dashboard, or "an A/B test with 50% allocation to the test variant"

Thanks @AAorris, new example created. I was able to run it locally but I had issues when deploying it to vercel, can you check if there's anything not properly set?
vercel/examples#1144

@AAorris
Copy link
Contributor

AAorris commented Jun 11, 2025

👋 I'm out of office right now so I'll look for assistance from the team in continuing to review

Copy link
Member

@chriswdmr chriswdmr left a comment

Choose a reason for hiding this comment

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

Thanks for your patience, I just had a look!

You can find my review for the example here: vercel/examples#1144 (review)

Have you planned adding some docs for the Flags SDK adapter on your end? I was unable to find them on your site.

I noticed that you used environmentID and projectID (with a capital "D"). It's just a nitpick, but our other providers use standard camel casing.

We handle the CHANGELOG.md automatically for you, you can remove it and just run the changeset command and commit the outputs

@tiagoapolo
Copy link
Contributor Author

Thanks for your patience, I just had a look!

You can find my review for the example here: vercel/examples#1144 (review)

Have you planned adding some docs for the Flags SDK adapter on your end? I was unable to find them on your site.

I noticed that you used environmentID and projectID (with a capital "D"). It's just a nitpick, but our other providers use standard camel casing.

We handle the CHANGELOG.md automatically for you, you can remove it and just run the changeset command and commit the outputs

Hi @chriswdmr, thank you for reviewing it. My plan is to add documentation on our side about Flags SDK at https://docs.flagsmith.com/ and we agreed with @dferber90 to have a back link to vercel flags docs on our docs and to have a link to flagsmith docs on your docs. I also updated the variables to camel case

adds tests

fix README

fix documentation

remove asdf file

implements getFeature pattern

update README

Update packages/adapter-flagsmith/README.md

Co-authored-by: Aaron Morris <aaron@vercel.com>

address changes

implements provider

adds different methods for different types of flags

fix tests

changeset
@tiagoapolo tiagoapolo force-pushed the adapter-flagsmith branch from b4d45a4 to 6ab9423 Compare July 8, 2025 02:26
@AAorris AAorris removed their request for review August 12, 2025 14:08
@tiagoapolo
Copy link
Contributor Author

@chriswdmr can you do a final review on this one?

@@ -0,0 +1,6 @@
---
'@flags-sdk/flagsmith': major
'flags': minor
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't need to make a new release of the flags package

Suggested change
'flags': minor
-'flags': minor


function createFlagsmithAdapter(params: IInitConfig): AdapterResponse {
async function initialize() {
await flagsmith.init({ fetch: globalThis.fetch, ...params });
Copy link
Collaborator

@dferber90 dferber90 Aug 22, 2025

Choose a reason for hiding this comment

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

Since flagsmith is a singleton, does this mean there can only ever be one instance of the adapter at the same time?

If it gets called twice to connect to different projects the first adapter would get reconfigured, right?

That could be quite surprising, but I'm fine with this if we document it

const adapterA = createFlagsmithAdapter(projectA)
const adapterB = createFlagsmithAdapter(projectB)

Due to the singleton adapterA would now also connect to projectB 🐛

@dferber90
Copy link
Collaborator

dferber90 commented Aug 22, 2025

Merging so we can test directly within this repo

@dferber90 dferber90 merged commit 63edc40 into vercel:main Aug 22, 2025
1 of 4 checks passed
@dferber90
Copy link
Collaborator

dferber90 commented Aug 22, 2025

I merged this today with the intention of testing and releasing but I ran out of time. Will pick this back up again next week. It is merged but unreleased for now.

dferber90 added a commit that referenced this pull request Sep 9, 2025
@dferber90
Copy link
Collaborator

I reverted briefly as we needed to merge something else and I did not get around to review yet.

dferber90 added a commit that referenced this pull request Sep 10, 2025
@dferber90
Copy link
Collaborator

Continuing this in #167

dferber90 added a commit that referenced this pull request Oct 14, 2025
dferber90 added a commit that referenced this pull request Oct 14, 2025
…182)

* Revert "Revert "Adds Flagsmith adapter (#103)""

This reverts commit bf85f97.

* prepare flagsmith adapter for release

* adjust changeset

* update lockfile

* shrink readme

* feat: get-mv-options-to-build-possible-values

---------

Co-authored-by: Dominik Ferber <dominik.ferber@gmail.com>
dferber90 added a commit that referenced this pull request Oct 14, 2025
* Revert "Revert "Adds Flagsmith adapter (#103)""

This reverts commit bf85f97.

* prepare flagsmith adapter for release

* adjust changeset

* update lockfile

* shrink readme

* feat: get-mv-options-to-build-possible-values

* feat: reworked-decide-signature-and-readme

* feat: rebase

* adjust changeset

* update lockfile

* feat: reworked-decide-signature-and-readme

* feat: updated-tests

* feat: fix-pnpm-lok

---------

Co-authored-by: Dominik Ferber <dominik.ferber@gmail.com>
dferber90 added a commit that referenced this pull request Oct 17, 2025
* Revert "Revert "Adds Flagsmith adapter (#103)""

This reverts commit bf85f97.

* prepare flagsmith adapter for release

* adjust changeset

* update lockfile

* shrink readme

* feat: get-mv-options-to-build-possible-values

* feat: reworked-decide-signature-and-readme

* feat: rebase

* adjust changeset

* update lockfile

* feat: reworked-decide-signature-and-readme

* feat: updated-tests

* feat: fix-pnpm-lok

* feat: added-documentation-for-identify

* feat: added-full-example

---------

Co-authored-by: Dominik Ferber <dominik.ferber@gmail.com>
dferber90 added a commit that referenced this pull request Oct 30, 2025
* Revert "Revert "Adds Flagsmith adapter (#103)""

This reverts commit bf85f97.

* prepare flagsmith adapter for release

* adjust changeset

* update lockfile

* shrink readme

* feat: get-mv-options-to-build-possible-values

* feat: reworked-decide-signature-and-readme

* feat: rebase

* adjust changeset

* update lockfile

* feat: reworked-decide-signature-and-readme

* feat: updated-tests

* feat: fix-pnpm-lok

* feat: added-documentation-for-identify

* feat: added-full-example

* feat: added-type-free-coercion-method

* feat: removed-per-type-functions-in-favor-of-get-value

---------

Co-authored-by: Dominik Ferber <dominik.ferber@gmail.com>
dferber90 added a commit that referenced this pull request Oct 30, 2025
* Revert "Revert "Adds Flagsmith adapter (#103)""

This reverts commit bf85f97.

* prepare flagsmith adapter for release

* adjust changeset

* update lockfile

* shrink readme

* provider @flags-sdk/flagsmith with correct options for Flag Explorer (#182)

* Revert "Revert "Adds Flagsmith adapter (#103)""

This reverts commit bf85f97.

* prepare flagsmith adapter for release

* adjust changeset

* update lockfile

* shrink readme

* feat: get-mv-options-to-build-possible-values

---------

Co-authored-by: Dominik Ferber <dominik.ferber@gmail.com>

* update lockfile

* Flagsmith (#186)

* Revert "Revert "Adds Flagsmith adapter (#103)""

This reverts commit bf85f97.

* prepare flagsmith adapter for release

* adjust changeset

* update lockfile

* shrink readme

* feat: get-mv-options-to-build-possible-values

* feat: reworked-decide-signature-and-readme

* feat: rebase

* adjust changeset

* update lockfile

* feat: reworked-decide-signature-and-readme

* feat: updated-tests

* feat: fix-pnpm-lok

---------

Co-authored-by: Dominik Ferber <dominik.ferber@gmail.com>

* Flagsmith (#190)

* Revert "Revert "Adds Flagsmith adapter (#103)""

This reverts commit bf85f97.

* prepare flagsmith adapter for release

* adjust changeset

* update lockfile

* shrink readme

* feat: get-mv-options-to-build-possible-values

* feat: reworked-decide-signature-and-readme

* feat: rebase

* adjust changeset

* update lockfile

* feat: reworked-decide-signature-and-readme

* feat: updated-tests

* feat: fix-pnpm-lok

* feat: added-documentation-for-identify

* feat: added-full-example

---------

Co-authored-by: Dominik Ferber <dominik.ferber@gmail.com>

* rewrite changeset

* Feat/flagsmith coercion method (#194)

* Revert "Revert "Adds Flagsmith adapter (#103)""

This reverts commit bf85f97.

* prepare flagsmith adapter for release

* adjust changeset

* update lockfile

* shrink readme

* feat: get-mv-options-to-build-possible-values

* feat: reworked-decide-signature-and-readme

* feat: rebase

* adjust changeset

* update lockfile

* feat: reworked-decide-signature-and-readme

* feat: updated-tests

* feat: fix-pnpm-lok

* feat: added-documentation-for-identify

* feat: added-full-example

* feat: added-type-free-coercion-method

* feat: removed-per-type-functions-in-favor-of-get-value

---------

Co-authored-by: Dominik Ferber <dominik.ferber@gmail.com>

* rm next-13

* esm

---------

Co-authored-by: Zaimwa9 <wadii.zaim@gmail.com>
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.

5 participants