Skip to content

fix(flagsmith): Fetch identity flags when context changes #1351

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

rolodato
Copy link
Contributor

@rolodato rolodato commented Jul 10, 2025

This PR

Use updated traits in the evaluation context whenever it changes.

Various README improvements.

Related Issues

Fixes #1232

Notes

N/A

Follow-up Tasks

Created an issue for the Flagsmith SDK to natively support Date objects: Flagsmith/flagsmith-js-client#329

How to test

Added a failing test which is fixed by this PR.

rolodato added 2 commits July 10, 2025 17:17
Signed-off-by: Rodrigo López Dato <rodrigo.lopezdato@flagsmith.com>
Signed-off-by: Rodrigo López Dato <rodrigo.lopezdato@flagsmith.com>
@rolodato rolodato force-pushed the fix/flagsmith-update-context branch from b6fa0df to dd18406 Compare July 10, 2025 20:17
@rolodato
Copy link
Contributor Author

One for @kyle-ssg to have a look maybe? I can't assign reviewers for this PR while it's still in draft.

Signed-off-by: Rodrigo López Dato <rodrigo.lopezdato@flagsmith.com>
Co-authored-by: Zaimwa9 <wadii.zaim@flagsmith.com>
@rolodato rolodato force-pushed the fix/flagsmith-update-context branch from 24bec79 to 8ec4423 Compare July 11, 2025 12:51
@rolodato rolodato marked this pull request as ready for review July 11, 2025 13:02
@rolodato rolodato requested review from a team as code owners July 11, 2025 13:02
Signed-off-by: Rodrigo López Dato <rodrigo.lopezdato@flagsmith.com>
@beeme1mr
Copy link
Member

Hey @rolodato, thanks for the PR. It looks like this PR only includes changes to the docs and a test. If that's intentional, I'm happy to review, but the PR description implies a larger change.

@rolodato
Copy link
Contributor Author

Thanks @beeme1mr - there is actually a behavior change in this PR here, in case you missed it: https://github.com/open-feature/js-sdk-contrib/pull/1351/files#diff-6f058ad4a6f79177acf735cd905843b3a9f0a1f28e1493058d6dc3449a0fd3d2

Copy link
Member

@beeme1mr beeme1mr left a comment

Choose a reason for hiding this comment

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

The change looks good but I noticed something unrelated to your change that hopefully you can clarify the intended behavior.

@@ -52,7 +52,24 @@ export class FlagsmithClientProvider implements Provider {
...(context || {}),
});
this.events.emit(ProviderEvents.Stale, { message: 'context has changed' });
return isLogout ? this._client.logout() : this._client.getFlags();
if (isLogout) {
return this._client.logout();
Copy link
Member

Choose a reason for hiding this comment

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

I see this isn't new behavior but I'm curious why this is necessary. Do you know why the logout would need to be called during initialization?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It confused me as well for sure. I speculate that this was a shortcut, since this provider implements onContextChange by directly calling initialize: https://github.com/rolodato/js-sdk-contrib/blob/453c70cf829cfee02720e73d78736ddc89d82ce3/libs/providers/flagsmith-client/src/lib/flagsmith-client-provider.ts#L106

A better solution could have been to keep the post-initialization logic in onContextChange, and only have initialization logic in initialize.

After this fix, we'd still need to upgrade the Flagsmith SDK dependency to v9, since this provider uses a quite out of date version. I'd prefer leaving this PR as-is and make the code nicer when we're making that upgrade.

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.

Flagsmith: Inconsistent Identity Propagation in FlagsmithClientProvider on Context Updates
2 participants