chore: Add SDK features for beforeSend callbacks#3608
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) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3608 +/- ##
==========================================
+ Coverage 86.61% 86.96% +0.35%
==========================================
Files 311 320 +9
Lines 10568 10799 +231
==========================================
+ Hits 9153 9391 +238
+ Misses 1415 1408 -7
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 |
|---|---|---|---|
| 4298701 | 524.40 ms | 633.30 ms | 108.90 ms |
| e200a70 | 433.06 ms | 437.00 ms | 3.94 ms |
| ec78888 | 457.94 ms | 519.96 ms | 62.02 ms |
| af96ef2 | 375.84 ms | 382.02 ms | 6.18 ms |
| 79f6b41 | 469.66 ms | 525.90 ms | 56.24 ms |
| 3615e19 | 468.38 ms | 504.71 ms | 36.33 ms |
| 0265ce5 | 406.39 ms | 418.48 ms | 12.09 ms |
| 9b99523 | 456.91 ms | 490.55 ms | 33.64 ms |
| c97f488 | 502.43 ms | 492.47 ms | -9.97 ms |
| 67de70c | 375.88 ms | 356.11 ms | -19.77 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 4298701 | 6.54 MiB | 7.71 MiB | 1.17 MiB |
| e200a70 | 13.93 MiB | 15.18 MiB | 1.25 MiB |
| ec78888 | 6.54 MiB | 7.69 MiB | 1.15 MiB |
| af96ef2 | 13.93 MiB | 15.18 MiB | 1.25 MiB |
| 79f6b41 | 6.54 MiB | 7.69 MiB | 1.15 MiB |
| 3615e19 | 6.54 MiB | 7.70 MiB | 1.16 MiB |
| 0265ce5 | 14.09 MiB | 15.28 MiB | 1.19 MiB |
| 9b99523 | 6.54 MiB | 7.69 MiB | 1.15 MiB |
| c97f488 | 14.31 MiB | 15.49 MiB | 1.19 MiB |
| 67de70c | 14.31 MiB | 15.49 MiB | 1.19 MiB |
Previous results on branch: chore/add-sdk-to-feature-for-beforesend
Startup times
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 818b360 | 436.56 ms | 436.38 ms | -0.18 ms |
| 81a66ec | 369.79 ms | 387.10 ms | 17.31 ms |
| 6d251b8 | 393.08 ms | 388.85 ms | -4.23 ms |
| 79041c1 | 376.42 ms | 379.20 ms | 2.79 ms |
| 9d57491 | 381.10 ms | 403.27 ms | 22.17 ms |
| 1f6d08f | 402.14 ms | 408.65 ms | 6.50 ms |
| cf5c86e | 431.48 ms | 436.42 ms | 4.94 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 818b360 | 14.31 MiB | 15.49 MiB | 1.19 MiB |
| 81a66ec | 14.31 MiB | 15.49 MiB | 1.19 MiB |
| 6d251b8 | 14.31 MiB | 15.49 MiB | 1.19 MiB |
| 79041c1 | 14.31 MiB | 15.49 MiB | 1.19 MiB |
| 9d57491 | 14.31 MiB | 15.49 MiB | 1.19 MiB |
| 1f6d08f | 14.31 MiB | 15.49 MiB | 1.19 MiB |
| cf5c86e | 14.31 MiB | 15.49 MiB | 1.19 MiB |
iOS Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 55b7a00 | 1279.45 ms | 1274.58 ms | -4.87 ms |
| 0fb45d0 | 1273.24 ms | 1286.44 ms | 13.19 ms |
| e0c8591 | 1259.85 ms | 1257.31 ms | -2.54 ms |
| f3771ea | 1258.53 ms | 1255.22 ms | -3.32 ms |
| f761369 | 1261.69 ms | 1277.82 ms | 16.12 ms |
| fec56a1 | 1251.71 ms | 1241.31 ms | -10.40 ms |
| af96ef2 | 1260.79 ms | 1259.61 ms | -1.17 ms |
| b4b7781 | 1239.98 ms | 1245.67 ms | 5.69 ms |
| c26ed0a | 1244.11 ms | 1263.85 ms | 19.75 ms |
| c8596a6 | 1234.11 ms | 1241.19 ms | 7.08 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 55b7a00 | 5.73 MiB | 6.17 MiB | 453.79 KiB |
| 0fb45d0 | 7.86 MiB | 9.44 MiB | 1.58 MiB |
| e0c8591 | 5.53 MiB | 5.96 MiB | 444.86 KiB |
| f3771ea | 5.73 MiB | 6.17 MiB | 455.44 KiB |
| f761369 | 7.86 MiB | 9.44 MiB | 1.58 MiB |
| fec56a1 | 5.73 MiB | 6.17 MiB | 455.53 KiB |
| af96ef2 | 5.53 MiB | 6.02 MiB | 501.31 KiB |
| b4b7781 | 5.73 MiB | 6.17 MiB | 455.48 KiB |
| c26ed0a | 5.53 MiB | 5.97 MiB | 453.76 KiB |
| c8596a6 | 7.86 MiB | 9.44 MiB | 1.58 MiB |
Previous results on branch: chore/add-sdk-to-feature-for-beforesend
Startup times
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 6d251b8 | 1245.80 ms | 1250.63 ms | 4.83 ms |
| 79041c1 | 1241.49 ms | 1246.77 ms | 5.28 ms |
| cf5c86e | 1227.80 ms | 1240.52 ms | 12.72 ms |
| 81a66ec | 1249.93 ms | 1253.50 ms | 3.57 ms |
| 818b360 | 1237.47 ms | 1245.49 ms | 8.02 ms |
| 1f6d08f | 1257.94 ms | 1263.27 ms | 5.33 ms |
| 9d57491 | 1248.14 ms | 1257.52 ms | 9.38 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 6d251b8 | 5.73 MiB | 6.17 MiB | 455.50 KiB |
| 79041c1 | 5.73 MiB | 6.17 MiB | 455.90 KiB |
| cf5c86e | 5.73 MiB | 6.17 MiB | 455.50 KiB |
| 81a66ec | 5.73 MiB | 6.17 MiB | 455.90 KiB |
| 818b360 | 5.73 MiB | 6.17 MiB | 455.50 KiB |
| 1f6d08f | 5.73 MiB | 6.17 MiB | 455.50 KiB |
| 9d57491 | 5.73 MiB | 6.17 MiB | 455.52 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) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Already provided by the sentry.dart barrel export. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Semver Impact of This PR⚪ None (no version bump detected) 📋 Changelog PreviewThis is how your changes will appear in the changelog. This PR will not appear in the changelog. 🤖 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.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
📜 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
#skip-changelog