Repository navigation
fix: record analytics against the canonical feature name - #428
Open
matthewelwell wants to merge 1 commit into
Open
matthewelwell wants to merge 1 commit into
matthewelwell wants to merge 1 commit into
Conversation
matthewelwell
requested review from
talissoncosta
and removed request for
a team
October 6, 2026 07:32
matthewelwell
commented
Oct 6, 2026
| }, | ||
| ]; | ||
|
|
||
| const instances: any[] = []; |
Contributor
Author
There was a problem hiding this comment.
Suggested change
| const instances: any[] = []; | |
| const flagsmithInstances: any[] = []; |
Can we not be more specific with the typing here too? Something like:
Suggested change
| const instances: any[] = []; | |
| const flagsmithInstances: Flagsmith[] = []; |
Comment on lines
+94
to
+104
| test('buckets unknown flags under the normalised key rather than the caller casing', async () => { | ||
| const { flagsmith, mockFetch } = await initWithMixedCaseFlags({ enableAnalytics: true }); | ||
| await delay(1); | ||
|
|
||
| flagsmith.getValue('Does Not Exist'); | ||
| flagsmith.getValue('does_not_exist'); | ||
|
|
||
| // @ts-ignore internal, normally driven by an interval | ||
| await flagsmith.analyticsFlags(); | ||
| expect(postedAnalytics(mockFetch)).toEqual({ does_not_exist: 2 }); | ||
| }); |
Contributor
Author
There was a problem hiding this comment.
Suggested change
| test('buckets unknown flags under the normalised key rather than the caller casing', async () => { | |
| const { flagsmith, mockFetch } = await initWithMixedCaseFlags({ enableAnalytics: true }); | |
| await delay(1); | |
| flagsmith.getValue('Does Not Exist'); | |
| flagsmith.getValue('does_not_exist'); | |
| // @ts-ignore internal, normally driven by an interval | |
| await flagsmith.analyticsFlags(); | |
| expect(postedAnalytics(mockFetch)).toEqual({ does_not_exist: 2 }); | |
| }); |
| this.sentryClient.getIntegrationByName( | ||
| "FeatureFlags", | ||
| )?.addFeatureFlag?.(key, res); | ||
| )?.addFeatureFlag?.(flag?.name || normalizeFlagKey(key), res); |
Contributor
Author
There was a problem hiding this comment.
The description of the PR mentions nothing about Sentry... why are we changing this too?
Comment on lines
+1020
to
+1022
| // As with evaluateFlag, report the feature's own name so that exposures for the | ||
| // same flag aggregate regardless of the casing the caller used. | ||
| const key = normalizeFlagKey(featureName); |
matthewelwell
force-pushed
the
feat/expose-feature-name
branch
2 times, most recently
from
October 6, 2026 09:42
44ce0be to
fe8068b
Compare
evaluateFlag bucketed by the caller's raw string rather than the resolved
flag, so getValue('MyFlag') and getValue('myflag') hit the same flag but
reported as two separate features.
The API resolves analytics with a case-sensitive name__in against
Feature.name, so neither spelling resolves unless it matches the feature
name exactly - meaning flags in projects that don't use lower-case names
never register as in use, which drives stale flag detection.
evaluateFlag, the Sentry addFeatureFlag call and trackExposureEvent now
all report the resolved flag's name, falling back to the normalised key
for flags that don't exist so two spellings of a missing flag collapse to
one bucket.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
matthewelwell
force-pushed
the
fix/analytics-feature-name-casing
branch
from
October 6, 2026 09:43
b8bd879 to
a9fc718
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.
Currently, flag analytics are recorded under the caller's casing rather than the feature name, so
getValue('MyFlag')andgetValue('myflag')both evaluate correctly in the client, but the analytics are reported as two separate features (because the API matches case sensitively).Stacked on #427, which adds the
namethis relies on.🤖 Generated with Claude Code