Skip to content

feat: expose original feature name on flags, fix analytics casing - #426

Closed
matthewelwell wants to merge 1 commit into
mainfrom
feat/flag-name-and-analytics-casing
Closed

matthewelwell wants to merge 1 commit into
mainfrom
feat/flag-name-and-analytics-casing

Conversation

@matthewelwell

@matthewelwell matthewelwell commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Adds an optional name to each flag carrying the feature's original casing, so getAllFlags() can be re-keyed by real feature names — additive, flag keys are unchanged.

Fixes analytics being recorded under the caller's casing rather than the feature name; the API matches Feature.name case-sensitively, so flags in projects not using lower-case names never registered as in use.

🤖 Generated with Claude Code

Flag keys in `getAllFlags()` are lower-cased with spaces replaced, and the
feature's original name was discarded at ingest. Consumers who want a map
keyed by their real feature names - e.g. to hold every flag in app state
rather than reading them one at a time - had no way to recover it.

Each flag now carries the feature's own name as `name`:

    const flagsByName = Object.fromEntries(
        Object.entries(flagsmith.getAllFlags()).map(([key, flag]) => [flag.name ?? key, flag])
    )

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.

Also fixes analytics being recorded against the caller's casing rather
than the feature's name. The API resolves analytics with a case-sensitive
match on Feature.name, so getValue('MyFlag') and getValue('myflag') were
reported as two separate features and neither resolved unless it matched
exactly - meaning flags in projects that don't use lower-case names never
registered as in use. evaluateFlag, the Sentry addFeatureFlag call and
trackExposureEvent now all report the resolved flag's name.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@matthewelwell
matthewelwell requested a review from a team as a code owner October 6, 2026 07:16
@matthewelwell
matthewelwell requested review from talissoncosta and removed request for a team October 6, 2026 07:16
@matthewelwell

Copy link
Copy Markdown
Contributor Author

Superseded by #427 (feat) and #428 (fix).

@matthewelwell
matthewelwell deleted the feat/flag-name-and-analytics-casing branch October 6, 2026 07:32
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