ref(dart): Make feature flags hub/scope-based#3848
Conversation
Move the feature-flag buffer logic off FeatureFlagsIntegration and onto Scope/Hub, mirroring the addBreadcrumb path. Sentry.addFeatureFlag now delegates through the hub instead of reaching into options.integrations. FeatureFlagsIntegration is deleted, so events no longer report "FeatureFlagsIntegration" in sdk.integrations. Usage is now tracked via the "featureFlags" entry in sdk.features, recorded on actual use. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Semver Impact of This PR⚪ None (no version bump detected) 📋 Changelog PreviewThis is how your changes will appear in the changelog. Features
DependenciesFlutter
Internal ChangesDart
Other
🤖 This preview updates automatically when you update the PR. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## v10-branch #3848 +/- ##
=============================================
Coverage ? 87.57%
=============================================
Files ? 337
Lines ? 12309
Branches ? 0
=============================================
Hits ? 10780
Misses ? 1529
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
There was a problem hiding this comment.
Pull request overview
Refactors feature-flag handling in the core Dart SDK to be hub/scope-based (following the same mutation path as other scope state), removing the dedicated FeatureFlagsIntegration and recording usage via sdk.features when flags are actually added.
Changes:
- Move
addFeatureFlaglogic intoHub.addFeatureFlagandScope.addFeatureFlag, preserving the publicSentry.addFeatureFlag(String, dynamic)facade. - Remove
FeatureFlagsIntegrationand its tests; update existing tests and add new coverage for scope/hub feature-flag behavior. - Track usage via
featureFlagsinsdk.features(instead ofsdk.integrations).
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/dart/lib/src/sentry.dart | Stops wiring/looking up FeatureFlagsIntegration; delegates to Hub.addFeatureFlag. |
| packages/dart/lib/src/hub.dart | Adds Hub.addFeatureFlag and delegates to the current Scope. |
| packages/dart/lib/src/scope.dart | Implements buffering/dedup/cap logic and writes feature flags via setContexts; records sdk.features usage. |
| packages/dart/lib/src/noop_hub.dart | Adds no-op addFeatureFlag to satisfy the Hub interface. |
| packages/dart/lib/src/hub_adapter.dart | Adds addFeatureFlag forwarding through the Sentry facade. |
| packages/dart/lib/src/constants.dart | Introduces SentryFeatures.featureFlags constant for usage tracking. |
| packages/dart/lib/src/feature_flags_integration.dart | Removes the integration implementation. |
| packages/dart/test/sentry_test.dart | Updates expectations to no longer require FeatureFlagsIntegration; renames feature-flag test. |
| packages/dart/test/scope_test.dart | Adds new tests for scope feature-flag buffering/ordering/cap behavior and usage tracking. |
| packages/dart/test/hub_test.dart | Adds tests for hub feature-flag delegation and disabled no-op behavior. |
| packages/dart/test/feature_flags_integration_test.dart | Removes integration-focused tests now that the integration is removed. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Avoid copying the whole contexts map via the public getter on each addFeatureFlag call; read the internal _contexts field instead. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
@buenaflor Probaly need to update to keep setting flgas on active span, which also went though the integration. |
…eature-flags-hub-based Resolves conflicts with #3806 (feature flags on active spans), which landed on the removed FeatureFlagsIntegration: - Span forwarding (flag.evaluation.* attributes, 10-per-span cap) moves into Hub.addFeatureFlag, ahead of the scope buffer delegation. - The scope buffer fix from #3806 was already implemented in Scope.addFeatureFlag, no change needed. - Span tests from feature_flags_integration_test.dart are ported to hub_test.dart against the real Hub; end-to-end tests merged into sentry_test.dart unchanged. Co-Authored-By: Claude Fable 5 <[email protected]>
v10-branch #3847 added a Hint parameter to OnProcessSpan while the thread info tests from #3821 landed in parallel still using the single-argument constructor, breaking compilation on the base branch. Pass an empty Hint like the other call sites. Co-Authored-By: Claude Fable 5 <[email protected]>
Feature-flag handling moves off
FeatureFlagsIntegrationand ontoHub/Scope, soSentry.addFeatureFlag()follows the same path as every other scope mutation (Sentry → Hub → Scope) instead of reaching intooptions.integrationsto find and mutate an integration instance.Scope.addFeatureFlag(flag, result)now owns the buffer (dedup → move-to-newest, cap at 100, drop oldest only when adding a new flag over the limit) and writes through the existingsetContextspath, so the native scope sync is preserved.Hub.addFeatureFlagmirrorsaddBreadcrumb: it no-ops with a warning when disabled, otherwise delegates to the scope. The publicSentry.addFeatureFlag(String, dynamic)signature and its non-boolguard are unchanged, so callers (firebase_remote_config, the Flutter framework integration, apps) need no changes.The buffer algorithm and the 100-entry cap are a verbatim move — no behavior change to what gets stored or serialized.
Breaking change
FeatureFlagsIntegrationis removed. It was never exported frompackage:sentry, so the only source break is code importing it viapackage:sentry/src/feature_flags_integration.dart, which was never supported.As a result, events no longer list
"FeatureFlagsIntegration"undersdk.integrations. Usage is instead tracked via a"featureFlags"entry insdk.features, recorded when a flag is actually added rather than unconditionally at init. Sentry-side analytics keyed on the oldsdk.integrationsmarker should move to the newsdk.featuressignal.Changelog Entry
FeatureFlagsIntegrationhas been removed.Sentry.addFeatureFlag()is unchanged, but events no longer reportFeatureFlagsIntegrationundersdk.integrations; feature-flag usage is tracked viafeatureFlagsinsdk.features.Part of #3487. Fixes #3837.