Skip to content

chore: Add SDK features for beforeSend callbacks#3608

Open
buenaflor wants to merge 8 commits intomainfrom
chore/add-sdk-to-feature-for-beforesend
Open

chore: Add SDK features for beforeSend callbacks#3608
buenaflor wants to merge 8 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) <noreply@anthropic.com>
@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 (487cd2f) to head (deaf764).
✅ All tests successful. No failed tests found.

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     
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

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

github-actions bot commented Mar 30, 2026

Android Performance metrics 🚀

  Plain With Sentry Diff
Startup time 415.45 ms 406.02 ms -9.43 ms
Size 14.31 MiB 15.49 MiB 1.19 MiB

Baseline results on branch: main

Startup times

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 30, 2026

iOS Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1224.25 ms 1223.42 ms -0.83 ms
Size 5.73 MiB 6.17 MiB 455.91 KiB

Baseline results on branch: main

Startup times

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

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) <noreply@anthropic.com>
@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
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>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 14, 2026

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).


This PR will not appear in the changelog.


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

Copilot AI left a comment

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.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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