feat: expose original feature name on flags - #427
Open
matthewelwell wants to merge 1 commit into
Open
matthewelwell wants to merge 1 commit into
matthewelwell wants to merge 1 commit into
Conversation
This was referenced Oct 6, 2026
matthewelwell
commented
Oct 6, 2026
Comment on lines
+44
to
+49
| test('getAllFlags can be re-keyed by original feature name', async () => { | ||
| const { flagsmith } = await initWithMixedCaseFlags(); | ||
| const flagsByName = byName(flagsmith.getAllFlags()); | ||
| expect(Object.keys(flagsByName).sort()).toEqual(['MyFeatureFlag', 'another_flag']); | ||
| expect(flagsByName.MyFeatureFlag.value).toBe('on'); | ||
| }); |
Contributor
Author
There was a problem hiding this comment.
This test is just a pointless duplication of the above test.
Suggested change
| test('getAllFlags can be re-keyed by original feature name', async () => { | |
| const { flagsmith } = await initWithMixedCaseFlags(); | |
| const flagsByName = byName(flagsmith.getAllFlags()); | |
| expect(Object.keys(flagsByName).sort()).toEqual(['MyFeatureFlag', 'another_flag']); | |
| expect(flagsByName.MyFeatureFlag.value).toBe('on'); | |
| }); |
Comment on lines
+58
to
+65
| test('falls back to the flag key when name is absent, as with defaultFlags', async () => { | ||
| const { flagsmith, initConfig } = getFlagsmith({ | ||
| preventFetch: true, | ||
| defaultFlags: { my_default: { enabled: true, value: 1 } }, | ||
| }); | ||
| await flagsmith.init(initConfig); | ||
| expect(byName(flagsmith.getAllFlags()).my_default).toEqual({ enabled: true, value: 1 }); | ||
| }); |
Contributor
Author
There was a problem hiding this comment.
As far as I can tell, this test is also pointless.
Suggested change
| test('falls back to the flag key when name is absent, as with defaultFlags', async () => { | |
| const { flagsmith, initConfig } = getFlagsmith({ | |
| preventFetch: true, | |
| defaultFlags: { my_default: { enabled: true, value: 1 } }, | |
| }); | |
| await flagsmith.init(initConfig); | |
| expect(byName(flagsmith.getAllFlags()).my_default).toEqual({ enabled: true, value: 1 }); | |
| }); |
Comment on lines
+71
to
+72
| // Flags are stored lower-cased with spaces replaced, so that callers can look a flag | ||
| // up by any casing. The feature's original name is kept on the flag itself as `name`. |
Contributor
Author
There was a problem hiding this comment.
Suggested change
| // Flags are stored lower-cased with spaces replaced, so that callers can look a flag | |
| // up by any casing. The feature's original name is kept on the flag itself as `name`. |
matthewelwell
force-pushed
the
feat/expose-feature-name
branch
from
October 6, 2026 09:42
67c6577 to
44ce0be
Compare
Flag keys in getAllFlags() are lower-cased with spaces replaced, and the feature's original name was discarded at ingest, so consumers who want a map keyed by their real feature names had no way to recover it. Each flag now carries the feature's own name as `name`. This is purely additive - flag keys are unchanged. `name` is absent on flags supplied via defaultFlags and on flags restored from a cache written by an older SDK, hence the `?? key` fallback in the documented snippet. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
matthewelwell
force-pushed
the
feat/expose-feature-name
branch
from
October 6, 2026 09:42
44ce0be to
fe8068b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an optional
nameto each flag carrying the feature's original casing, sogetAllFlags()can be re-keyed by real feature names rather than reading flags one at a time — additive, flag keys are unchanged.🤖 Generated with Claude Code