Skip to content

chore: Add SDK features for beforeSend callbacks#3608

Draft
buenaflor wants to merge 5 commits intomainfrom
chore/add-sdk-to-feature-for-beforesend
Draft

chore: Add SDK features for beforeSend callbacks#3608
buenaflor wants to merge 5 commits intomainfrom
chore/add-sdk-to-feature-for-beforesend

Conversation

@buenaflor
Copy link
Copy Markdown
Contributor

@buenaflor buenaflor commented Mar 30, 2026

📜 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

#skip-changelog

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
Copy link
Copy Markdown

codecov bot commented Mar 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.96%. Comparing base (5b3a9e9) to head (9d57491).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3608      +/-   ##
==========================================
+ Coverage   86.83%   86.96%   +0.12%     
==========================================
  Files         320      320              
  Lines       10789    10799      +10     
==========================================
+ Hits         9369     9391      +22     
+ Misses       1420     1408      -12     
Flag Coverage Δ
sentry 87.83% <100.00%> (+0.02%) ⬆️
sentry_dio 97.73% <ø> (ø)
sentry_drift 93.57% <ø> (ø)
sentry_file 63.52% <ø> (ø)
sentry_firebase_remote_config 100.00% <ø> (ø)
sentry_flutter 91.38% <ø> (+0.37%) ⬆️
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
Copy link
Copy Markdown

sentry bot commented Mar 30, 2026

Sentry Build Distribution

App Name App ID Version Configuration Install Page
sentry_flutter_example io.sentry.flutter.sample 9.16.0 (1) Release Install Build

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 30, 2026

Android Performance metrics 🚀

  Plain With Sentry Diff
Startup time 381.10 ms 403.27 ms 22.17 ms
Size 14.31 MiB 15.49 MiB 1.19 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
f3771ea 379.02 ms 363.91 ms -15.11 ms
101a9c7 375.81 ms 363.42 ms -12.39 ms
0fb3800 465.64 ms 536.77 ms 71.13 ms
393f8ec 360.07 ms 362.70 ms 2.64 ms
a10aff4 488.19 ms 515.02 ms 26.83 ms
fec56a1 370.66 ms 369.28 ms -1.38 ms
944b773 470.54 ms 480.18 ms 9.64 ms
53356d8 394.48 ms 400.70 ms 6.22 ms
1777727 438.67 ms 447.11 ms 8.44 ms
6e7d494 397.35 ms 378.91 ms -18.43 ms

App size

Revision Plain With Sentry Diff
f3771ea 14.31 MiB 15.49 MiB 1.19 MiB
101a9c7 14.31 MiB 15.49 MiB 1.19 MiB
0fb3800 6.54 MiB 7.69 MiB 1.15 MiB
393f8ec 13.93 MiB 15.06 MiB 1.13 MiB
a10aff4 13.93 MiB 15.06 MiB 1.13 MiB
fec56a1 14.31 MiB 15.49 MiB 1.19 MiB
944b773 13.93 MiB 15.00 MiB 1.06 MiB
53356d8 14.09 MiB 15.28 MiB 1.19 MiB
1777727 14.30 MiB 15.49 MiB 1.19 MiB
6e7d494 13.93 MiB 15.06 MiB 1.13 MiB

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

Startup times

Revision Plain With Sentry Diff
cf5c86e 431.48 ms 436.42 ms 4.94 ms
6d251b8 393.08 ms 388.85 ms -4.23 ms
818b360 436.56 ms 436.38 ms -0.18 ms
1f6d08f 402.14 ms 408.65 ms 6.50 ms

App size

Revision Plain With Sentry Diff
cf5c86e 14.31 MiB 15.49 MiB 1.19 MiB
6d251b8 14.31 MiB 15.49 MiB 1.19 MiB
818b360 14.31 MiB 15.49 MiB 1.19 MiB
1f6d08f 14.31 MiB 15.49 MiB 1.19 MiB

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 30, 2026

iOS Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1248.14 ms 1257.52 ms 9.38 ms
Size 5.73 MiB 6.17 MiB 455.52 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
7cfbbd6 1270.63 ms 1285.36 ms 14.72 ms
e2d675d 1238.48 ms 1242.76 ms 4.28 ms
e0c8591 1259.85 ms 1257.31 ms -2.54 ms
1ce780b 1252.49 ms 1256.17 ms 3.68 ms
d0aa4b6 1268.23 ms 1268.39 ms 0.15 ms
3801d52 1267.76 ms 1266.10 ms -1.65 ms
c97f488 1247.40 ms 1252.13 ms 4.73 ms
fd88186 1255.06 ms 1252.76 ms -2.30 ms
aeb02f2 1244.29 ms 1256.55 ms 12.26 ms
c26ed0a 1244.11 ms 1263.85 ms 19.75 ms

App size

Revision Plain With Sentry Diff
7cfbbd6 7.86 MiB 9.44 MiB 1.58 MiB
e2d675d 7.86 MiB 9.44 MiB 1.58 MiB
e0c8591 5.53 MiB 5.96 MiB 444.86 KiB
1ce780b 5.66 MiB 6.10 MiB 451.58 KiB
d0aa4b6 5.53 MiB 6.02 MiB 502.04 KiB
3801d52 5.73 MiB 6.17 MiB 455.54 KiB
c97f488 5.73 MiB 6.17 MiB 455.48 KiB
fd88186 5.53 MiB 6.00 MiB 479.94 KiB
aeb02f2 7.86 MiB 9.44 MiB 1.58 MiB
c26ed0a 5.53 MiB 5.97 MiB 453.76 KiB

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
818b360 1237.47 ms 1245.49 ms 8.02 ms
cf5c86e 1227.80 ms 1240.52 ms 12.72 ms
1f6d08f 1257.94 ms 1263.27 ms 5.33 ms

App size

Revision Plain With Sentry Diff
6d251b8 5.73 MiB 6.17 MiB 455.50 KiB
818b360 5.73 MiB 6.17 MiB 455.50 KiB
cf5c86e 5.73 MiB 6.17 MiB 455.50 KiB
1f6d08f 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 2 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]>
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.

1 participant