Skip to content

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

Open
buenaflor wants to merge 2 commits into
v10-branchfrom
buenaflor/ref/feature-flags-hub-based
Open

ref(dart): Make feature flags hub/scope-based#3848
buenaflor wants to merge 2 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) <noreply@anthropic.com>
@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

  • (grpc) Add integration support for GRPC by lucas-zimerman in #3721

Fixes

  • Correct feature flag scope buffer updates by denrase in #3797

Dependencies

Deps

  • chore(deps): update Android SDK to v8.46.0 by github-actions in #3793
  • chore(deps): update Native SDK to v0.15.2 by github-actions in #3785

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

  • (skills) Expand test-guidelines and drop stale deps by buenaflor in #3807
  • Add PR template checkbox for cross sdk review on public API changes by antonis in #3822
  • Block manual CHANGELOG.md edits by buenaflor in #3810
  • Fix Dependabot pub paths and pin GitHub Action by buenaflor in #3804
  • Add AI Use section to CONTRIBUTING.md by christophaigner in #3803

🤖 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 86.36364% with 3 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (v10-branch@59d7c7b). Learn more about missing BASE report.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
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.37%           
=============================================
  Files                 ?      336           
  Lines                 ?    12255           
  Branches              ?        0           
=============================================
  Hits                  ?    10708           
  Misses                ?     1547           
  Partials              ?        0           
Flag Coverage Δ
sentry 87.20% <86.36%> (?)
sentry_dio 97.73% <ø> (?)
sentry_drift 93.57% <ø> (?)
sentry_file 65.29% <ø> (?)
sentry_firebase_remote_config 100.00% <ø> (?)
sentry_flutter 91.66% <ø> (?)
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
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) <noreply@anthropic.com>
@buenaflor buenaflor changed the title ref(dart)!: Make feature flags hub/scope-based ref(dart): Make feature flags hub/scope-based Jul 2, 2026
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.

2 participants