chore: Add SDK features for beforeSend callbacks#3608
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
📲 Install BuildsAndroid
|
Android Performance metrics 🚀
|
| 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 |
iOS Performance metrics 🚀
|
| 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 |
…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]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Already provided by the sentry.dart barrel export. Co-Authored-By: Claude Opus 4.6 (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. Internal Changes
🤖 This preview updates automatically when you update the PR. |
Add documentation for SentryFeatures class.
There was a problem hiding this comment.
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
SentryFeaturesstring constants for eachbeforeSend*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.
| if (enableFlutterSpotlight) { | ||
| options.transport = SpotlightHttpTransport(options, options.transport); | ||
| } | ||
| if (options.beforeSend != null) { |
There was a problem hiding this comment.
Any particular reason we do this in the client and not somewhere else?
There was a problem hiding this comment.
yeah thinking about it I think it could be a TrackFeaturesIntegration since we should opt for integrations when possible
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]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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.
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

📜 Description
Register configured
beforeSendcallbacks as SDK features atSentryClientconstruction time. When a user configures any of the beforeSend callbacks, the corresponding feature string is added viasdk.addFeature():beforeSend→beforeSendEventbeforeSendTransaction→beforeSendTransactionbeforeSendFeedback→beforeSendFeedbackbeforeSendLog→beforeSendLogbeforeSendMetric→beforeSendMetricSince
addFeaturededuplicates, 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.dartcovering:📝 Checklist
sendDefaultPiiis enabled🔮 Next steps