Skip to content

fix(cocoa): native events dropped by managed callbacks are no longer counted twice in client reports - #6055

Merged
jamescrosswell merged 1 commit into
mainfrom
ai/triagent-5681
Dec 3, 2026
Merged

jamescrosswell merged 1 commit into
mainfrom
ai/triagent-5681

Conversation

@jamescrosswell

@jamescrosswell jamescrosswell commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

On iOS, ProcessOnBeforeSend runs the managed event processors and BeforeSend on native events. When one of them drops the event, .NET recorded a client report discard and returned nil. sentry-cocoa then recorded before_send for the same event, so each drop was counted twice.

SentryEventHelper.ProcessEvent and DoBeforeSend now take a recordDiscards flag. The Cocoa bridge passes false, which leaves the counting to sentry-cocoa, as decided in #5634. Managed events are unchanged.

Until sentry-cocoa can record callback_error (getsentry/sentry-cocoa#8993), a callback that throws on a native iOS event shows up only as before_send. An event processor that returns null on a native event is also now counted as before_send rather than event_processor.

The new iOS test passed on the simulator via scripts/device-test.ps1 ios.

Closes #5681

🤖 Generated with Claude Code

…ient reports

sentry-cocoa already records a before_send discard when the managed
BeforeSend bridge returns nil, so skip the .NET record for native events.

Closes #5681

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR risk: medium

For commit 467969b.

Main concerns: reach, public contract, data sent to Sentry.

This label is a hint for reviewers, not an approval.

@sentry-junior sentry-junior Bot 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.

Good to approve and merge

Fixes the cause of #5681: the Cocoa bridge stops recording client reports for native events that managed processors or BeforeSend drop, and leaves counting to sentry-cocoa, which records before_send when the callback returns nil. Managed capture paths keep the default recordDiscards: true, the change is internal-only, and the new iOS test covers null and throwing callbacks for both processors and BeforeSend. This matches the Android bridge, which already leaves counting to sentry-java.

This is an automated preliminary review.

@codecov

codecov Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.33%. Comparing base (2316b7c) to head (467969b).
⚠️ Report is 11 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6055   +/-   ##
=======================================
  Coverage   78.33%   78.33%           
=======================================
  Files         537      537           
  Lines       20134    20138    +4     
  Branches     4055     4059    +4     
=======================================
+ Hits        15771    15776    +5     
+ Misses       3516     3514    -2     
- Partials      847      848    +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jamescrosswell
jamescrosswell marked this pull request as ready for review December 1, 2026 00:14
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Dec 1, 2026

@ric-oliv ric-oliv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What do you think about fix(cocoa): for the title? The bridge also compiles for Mac Catalyst, and #5943 used cocoa for the same function, so Catalyst users would see the fix in the changelog too.

The description mentions that a throwing callback now shows up only as before_send. A processor that returns null on a native event changes reason too, from event_processor to before_send. Maybe add a sentence? The #5681 table already covers it, so I'm fine either way.

@jamescrosswell jamescrosswell changed the title fix(ios): native events dropped by managed callbacks are no longer counted twice in client reports fix(cocoa): native events dropped by managed callbacks are no longer counted twice in client reports Dec 3, 2026
@jamescrosswell
jamescrosswell merged commit 5cf7c85 into main Dec 3, 2026
66 checks passed
@jamescrosswell
jamescrosswell deleted the ai/triagent-5681 branch December 3, 2026 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

iOS native events dropped by managed callbacks are counted twice in client reports

2 participants