Skip to content

ref(dart): Make feature flags hub/scope-based#3848

Merged
buenaflor merged 4 commits into
v10-branchfrom
buenaflor/ref/feature-flags-hub-based
Jul 6, 2026
Merged

ref(dart): Make feature flags hub/scope-based#3848
buenaflor merged 4 commits into
v10-branchfrom
buenaflor/ref/feature-flags-hub-based

Conversation

@buenaflor

Copy link
Copy Markdown
Contributor

Feature-flag handling moves off FeatureFlagsIntegration and onto Hub/Scope, so Sentry.addFeatureFlag() follows the same path as every other scope mutation (Sentry → Hub → Scope) instead of reaching into options.integrations to 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 existing setContexts path, so the native scope sync is preserved. Hub.addFeatureFlag mirrors addBreadcrumb: it no-ops with a warning when disabled, otherwise delegates to the scope. The public Sentry.addFeatureFlag(String, dynamic) signature and its non-bool guard 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

FeatureFlagsIntegration is removed. It was never exported from package:sentry, so the only source break is code importing it via package:sentry/src/feature_flags_integration.dart, which was never supported.

As a result, events no longer list "FeatureFlagsIntegration" under sdk.integrations. Usage is instead tracked via a "featureFlags" entry in sdk.features, recorded when a flag is actually added rather than unconditionally at init. Sentry-side analytics keyed on the old sdk.integrations marker should move to the new sdk.features signal.

Changelog Entry

  • Breaking: Feature flags are now hub/scope-based and FeatureFlagsIntegration has been removed. Sentry.addFeatureFlag() is unchanged, but events no longer report FeatureFlagsIntegration under sdk.integrations; feature-flag usage is tracked via featureFlags in sdk.features.

Part of #3487. Fixes #3837.

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]>
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Semver Impact of This PR

None (no version bump detected)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


Features

  • (flutter) Support SwiftPM on Flutter 3.44+ by buenaflor in #3784
  • (telemetry) Align span attributes with Sentry Conventions by buenaflor in #3805
  • Add feature flags to hub span by denrase in #3806

Dependencies

Flutter

  • Bump jni to 1.0.0 and jnigen to 0.16.0 in v10 by buenaflor in #3765
  • Bump sentry-cocoa to 9.17.1 in v10 by buenaflor in #3764

Internal Changes

Dart

  • Breaking: Feature flags are now hub/scope-based and FeatureFlagsIntegration has been removed. Sentry.addFeatureFlag() is unchanged, but events no longer report FeatureFlagsIntegration under sdk.integrations; feature-flag usage is tracked via featureFlags in sdk.features. by buenaflor in #3848
  • Part of Major v10 Task Collection #3487. Fixes [v10] Make FeatureFlagsIntegration hub-based #3837. by buenaflor in #3848

Other

  • (feedback) Remove deprecated SentryFeedbackWidget by buenaflor in #3844
  • (file) Remove file.async attributes from instrumentation by buenaflor in #3841
  • (logs) Remove deprecated SentryLogAttribute by buenaflor in #3843
  • Make clone() internal and remove deprecated protocol clones by buenaflor in #3845

🤖 This preview updates automatically when you update the PR.

@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.38462% with 5 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (v10-branch@48a1579). Learn more about missing BASE report.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
packages/dart/lib/src/hub.dart 94.28% 2 Missing ⚠️
packages/dart/lib/src/hub_adapter.dart 0.00% 2 Missing ⚠️
packages/dart/lib/src/noop_hub.dart 0.00% 1 Missing ⚠️
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           
Flag Coverage Δ
sentry 87.59% <90.38%> (?)
sentry_dio 97.73% <ø> (?)
sentry_drift 93.57% <ø> (?)
sentry_file 64.45% <ø> (?)
sentry_firebase_remote_config 100.00% <ø> (?)
sentry_flutter 91.61% <ø> (?)
sentry_grpc 99.09% <ø> (?)
sentry_hive 77.48% <ø> (?)
sentry_isar 74.37% <ø> (?)
sentry_link 21.50% <ø> (?)
sentry_logging 97.01% <ø> (?)
sentry_sqflite 88.81% <ø> (?)
sentry_supabase 97.27% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@buenaflor
buenaflor marked this pull request as ready for review July 2, 2026 08:09
@buenaflor
buenaflor requested a review from denrase as a code owner July 2, 2026 08:09
Copilot AI review requested due to automatic review settings July 2, 2026 08:09
Comment thread packages/dart/lib/src/hub.dart

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 addFeatureFlag logic into Hub.addFeatureFlag and Scope.addFeatureFlag, preserving the public Sentry.addFeatureFlag(String, dynamic) facade.
  • Remove FeatureFlagsIntegration and its tests; update existing tests and add new coverage for scope/hub feature-flag behavior.
  • Track usage via featureFlags in sdk.features (instead of sdk.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.

Comment thread packages/dart/lib/src/hub.dart Outdated
Comment thread packages/dart/lib/src/scope.dart
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 buenaflor changed the title ref(dart)!: Make feature flags hub/scope-based ref(dart): Make feature flags hub/scope-based Jul 2, 2026
Comment thread packages/dart/lib/src/scope.dart
Comment thread packages/dart/lib/src/hub.dart
@denrase

denrase commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

@buenaflor Probaly need to update to keep setting flgas on active span, which also went though the integration.

buenaflor and others added 2 commits July 6, 2026 13:28
…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]>
@buenaflor
buenaflor merged commit 6416504 into v10-branch Jul 6, 2026
146 of 148 checks passed
@buenaflor
buenaflor deleted the buenaflor/ref/feature-flags-hub-based branch July 6, 2026 12:18
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.

3 participants