Skip to content

chore: Add SDK features for beforeSend callbacks#3608

Merged
buenaflor merged 12 commits into
mainfrom
chore/add-sdk-to-feature-for-beforesend
Apr 16, 2026
Merged

chore: Add SDK features for beforeSend callbacks#3608
buenaflor merged 12 commits into
mainfrom
chore/add-sdk-to-feature-for-beforesend

Conversation

@buenaflor

@buenaflor buenaflor commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

📜 Description

Register configured beforeSend callbacks as SDK features at SentryClient construction time. When a user configures any of the beforeSend callbacks, the corresponding feature string is added via sdk.addFeature():

  • beforeSendbeforeSendEvent
  • beforeSendTransactionbeforeSendTransaction
  • beforeSendFeedbackbeforeSendFeedback
  • beforeSendLogbeforeSendLog
  • beforeSendMetricbeforeSendMetric

Since addFeature deduplicates, re-creating the client is safe.

💡 Motivation and Context

This lets us track which beforeSend APIs users have configured as SDK metadata, without needing to know how often the callbacks are actually invoked.

💚 How did you test it?

Added 6 unit tests in sentry_client_test.dart covering:

  • Each callback type adds its corresponding feature when configured
  • No features are added when no callbacks are set

📝 Checklist

  • I reviewed submitted code
  • I added tests to verify changes
  • No new PII added or SDK only sends newly added PII if sendDefaultPii is enabled
  • I updated the docs if needed
  • All tests passing
  • No breaking changes

🔮 Next steps

Register configured beforeSend callbacks as SDK features at
SentryClient construction time. This lets us track which
beforeSend APIs users have configured (beforeSendEvent,
beforeSendTransaction, beforeSendFeedback, beforeSendLog,
beforeSendMetric) without caring about invocation frequency.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@codecov

codecov Bot commented Mar 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.96%. Comparing base (aaa2730) to head (7cdf24a).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3608      +/-   ##
==========================================
- Coverage   86.96%   86.96%   -0.01%     
==========================================
  Files         320      321       +1     
  Lines       10789    10802      +13     
==========================================
+ Hits         9383     9394      +11     
- Misses       1406     1408       +2     
Flag Coverage Δ
sentry 87.84% <100.00%> (-0.01%) ⬇️
sentry_dio 97.73% <ø> (ø)
sentry_drift 93.57% <ø> (ø)
sentry_file 63.52% <ø> (ø)
sentry_firebase_remote_config 100.00% <ø> (ø)
sentry_flutter 91.38% <ø> (ø)
sentry_hive 72.51% <ø> (ø)
sentry_isar 73.66% <ø> (ø)
sentry_link 3.95% <ø> (ø)
sentry_logging 97.01% <ø> (ø)
sentry_sqflite 88.40% <ø> (ø)
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 Sentry.
📢 Have feedback on the report? Share it here.

@sentry

sentry Bot commented Mar 30, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
sentry_flutter_example io.sentry.flutter.sample 9.17.0 (1) Release

⚙️ sentry-flutter Build Distribution Settings

@github-actions

github-actions Bot commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

Android Performance metrics 🚀

  Plain With Sentry Diff
Startup time 377.81 ms 370.79 ms -7.02 ms
Size 14.31 MiB 15.49 MiB 1.19 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
1f639ee 429.98 ms 476.60 ms 46.62 ms
d3fb366 391.49 ms 385.85 ms -5.64 ms
c26ed0a 465.52 ms 476.38 ms 10.86 ms
75284dc 512.39 ms 530.87 ms 18.48 ms
73a3c38 478.18 ms 526.62 ms 48.44 ms
ea06d23 371.10 ms 358.56 ms -12.54 ms
e3f3ea1 420.16 ms 436.54 ms 16.39 ms
0fb45d0 482.79 ms 554.02 ms 71.23 ms
caa8620 384.46 ms 363.30 ms -21.16 ms
2f63d89 415.95 ms 424.21 ms 8.26 ms

App size

Revision Plain With Sentry Diff
1f639ee 13.93 MiB 15.00 MiB 1.06 MiB
d3fb366 13.93 MiB 15.06 MiB 1.13 MiB
c26ed0a 13.93 MiB 14.93 MiB 1.00 MiB
75284dc 13.93 MiB 14.93 MiB 1.00 MiB
73a3c38 6.54 MiB 7.69 MiB 1.15 MiB
ea06d23 13.93 MiB 15.18 MiB 1.25 MiB
e3f3ea1 13.93 MiB 15.18 MiB 1.25 MiB
0fb45d0 6.54 MiB 7.70 MiB 1.17 MiB
caa8620 14.31 MiB 15.49 MiB 1.19 MiB
2f63d89 14.09 MiB 15.28 MiB 1.19 MiB

Previous results on branch: chore/add-sdk-to-feature-for-beforesend

Startup times

Revision Plain With Sentry Diff
ca3699d 371.70 ms 367.13 ms -4.57 ms
cf5c86e 431.48 ms 436.42 ms 4.94 ms
deaf764 415.45 ms 406.02 ms -9.43 ms
1f6d08f 402.14 ms 408.65 ms 6.50 ms
818b360 436.56 ms 436.38 ms -0.18 ms
81a66ec 369.79 ms 387.10 ms 17.31 ms
79041c1 376.42 ms 379.20 ms 2.79 ms
6d251b8 393.08 ms 388.85 ms -4.23 ms
99a3f86 417.35 ms 426.19 ms 8.84 ms
9d57491 381.10 ms 403.27 ms 22.17 ms

App size

Revision Plain With Sentry Diff
ca3699d 14.31 MiB 15.49 MiB 1.19 MiB
cf5c86e 14.31 MiB 15.49 MiB 1.19 MiB
deaf764 14.31 MiB 15.49 MiB 1.19 MiB
1f6d08f 14.31 MiB 15.49 MiB 1.19 MiB
818b360 14.31 MiB 15.49 MiB 1.19 MiB
81a66ec 14.31 MiB 15.49 MiB 1.19 MiB
79041c1 14.31 MiB 15.49 MiB 1.19 MiB
6d251b8 14.31 MiB 15.49 MiB 1.19 MiB
99a3f86 14.31 MiB 15.49 MiB 1.19 MiB
9d57491 14.31 MiB 15.49 MiB 1.19 MiB

@github-actions

github-actions Bot commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

iOS Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1254.43 ms 1257.70 ms 3.27 ms
Size 5.73 MiB 6.17 MiB 453.62 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
40751bf 1245.65 ms 1269.81 ms 24.16 ms
cfca825 1244.71 ms 1249.96 ms 5.24 ms
0929dbf 1275.89 ms 1282.22 ms 6.33 ms
3615e19 1225.02 ms 1234.57 ms 9.55 ms
8825ed8 1243.35 ms 1240.39 ms -2.96 ms
2f63d89 1251.67 ms 1263.94 ms 12.27 ms
0fb3800 1256.60 ms 1266.28 ms 9.68 ms
a909995 1259.83 ms 1258.66 ms -1.17 ms
caa8620 1261.15 ms 1262.62 ms 1.46 ms
0e2b9b0 1248.69 ms 1252.22 ms 3.54 ms

App size

Revision Plain With Sentry Diff
40751bf 5.73 MiB 6.17 MiB 455.47 KiB
cfca825 5.66 MiB 6.10 MiB 453.28 KiB
0929dbf 7.86 MiB 9.54 MiB 1.69 MiB
3615e19 7.86 MiB 9.44 MiB 1.58 MiB
8825ed8 5.53 MiB 5.97 MiB 453.71 KiB
2f63d89 5.65 MiB 6.09 MiB 446.25 KiB
0fb3800 7.86 MiB 9.44 MiB 1.58 MiB
a909995 5.66 MiB 6.10 MiB 451.85 KiB
caa8620 5.73 MiB 6.17 MiB 455.47 KiB
0e2b9b0 5.73 MiB 6.17 MiB 453.79 KiB

Previous results on branch: chore/add-sdk-to-feature-for-beforesend

Startup times

Revision Plain With Sentry Diff
ca3699d 1258.04 ms 1254.79 ms -3.25 ms
1f6d08f 1257.94 ms 1263.27 ms 5.33 ms
79041c1 1241.49 ms 1246.77 ms 5.28 ms
99a3f86 1253.55 ms 1264.33 ms 10.77 ms
6d251b8 1245.80 ms 1250.63 ms 4.83 ms
818b360 1237.47 ms 1245.49 ms 8.02 ms
deaf764 1224.25 ms 1223.42 ms -0.83 ms
afc86cf 1250.63 ms 1251.04 ms 0.41 ms
9d57491 1248.14 ms 1257.52 ms 9.38 ms
cf5c86e 1227.80 ms 1240.52 ms 12.72 ms

App size

Revision Plain With Sentry Diff
ca3699d 5.73 MiB 6.17 MiB 455.85 KiB
1f6d08f 5.73 MiB 6.17 MiB 455.50 KiB
79041c1 5.73 MiB 6.17 MiB 455.90 KiB
99a3f86 5.73 MiB 6.17 MiB 455.84 KiB
6d251b8 5.73 MiB 6.17 MiB 455.50 KiB
818b360 5.73 MiB 6.17 MiB 455.50 KiB
deaf764 5.73 MiB 6.17 MiB 455.91 KiB
afc86cf 5.73 MiB 6.17 MiB 453.68 KiB
9d57491 5.73 MiB 6.17 MiB 455.52 KiB
cf5c86e 5.73 MiB 6.17 MiB 455.50 KiB

buenaflor and others added 2 commits April 2, 2026 14:08
…ants

Move inline feature string literals to a dedicated SentryFeatures class
in constants.dart for reuse as more features are added.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@buenaflor buenaflor changed the title feat(dart): Add SDK features for beforeSend callbacks chore: Add SDK features for beforeSend callbacks Apr 2, 2026
buenaflor and others added 3 commits April 2, 2026 14:43
Already provided by the sentry.dart barrel export.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@github-actions

github-actions Bot commented Apr 14, 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).


Internal Changes

  • (flutter-example) Fix macOS SPM build and bump AGP to 8.6.0 by buenaflor in #3644
  • (supabase) Fix flaky error client test for postgrest retry by buenaflor in #3643
  • Add SDK features for beforeSend callbacks by buenaflor in #3608
  • Add dep update pattern to Dependencies changelog category by buenaflor in #3642
  • Replace Danger with release.yml changelog policy by buenaflor in #3641

🤖 This preview updates automatically when you update the PR.

Add documentation for SentryFeatures class.
@buenaflor
buenaflor marked this pull request as ready for review April 14, 2026 12:41
@buenaflor
buenaflor requested a review from denrase as a code owner April 14, 2026 12:41
Copilot AI review requested due to automatic review settings April 14, 2026 12:41

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

This PR adds SDK feature metadata for configured beforeSend* callbacks at SentryClient construction time, enabling internal analytics on which callback APIs are configured by users.

Changes:

  • Add SentryFeatures string constants for each beforeSend* callback type.
  • Register the corresponding feature via options.sdk.addFeature(...) when each callback is configured.
  • Add unit tests verifying feature registration (and absence when not configured).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
packages/dart/lib/src/sentry_client.dart Adds feature registration during SentryClient construction based on configured beforeSend* callbacks.
packages/dart/lib/src/constants.dart Introduces SentryFeatures constants used to label configured callback features.
packages/dart/test/sentry_client_test.dart Adds tests covering feature registration for each callback type and the no-callbacks case.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/dart/lib/src/constants.dart Outdated
if (enableFlutterSpotlight) {
options.transport = SpotlightHttpTransport(options, options.transport);
}
if (options.beforeSend != null) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Any particular reason we do this in the client and not somewhere else?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah thinking about it I think it could be a TrackFeaturesIntegration since we should opt for integrations when possible

buenaflor and others added 2 commits April 16, 2026 14:51
Extract beforeSend* feature registration from SentryClient factory
into TrackBeforeSendUsageIntegration. This follows the integration
pattern used by other SDK setup concerns and keeps client construction
focused on transport wiring.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit afc86cf. Configure here.

Comment thread packages/dart/lib/src/track_before_send_usage_integration.dart
@buenaflor
buenaflor merged commit 87c9451 into main Apr 16, 2026
148 of 149 checks passed
@buenaflor
buenaflor deleted the chore/add-sdk-to-feature-for-beforesend branch April 16, 2026 14:05
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