Skip to content

fix(core): Deduplicate native HTTP breadcrumbs#6132

Open
antonis wants to merge 4 commits into
mainfrom
antonis/fix-duplicate-http-breadcrumbs
Open

fix(core): Deduplicate native HTTP breadcrumbs#6132
antonis wants to merge 4 commits into
mainfrom
antonis/fix-duplicate-http-breadcrumbs

Conversation

@antonis
Copy link
Copy Markdown
Contributor

@antonis antonis commented May 11, 2026

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

When JS makes an HTTP request in React Native, breadcrumbs are created independently by both the JS SDK (xhr category) and the native SDK (http category), because RN's networking layer (fetch/XHR) is implemented via native APIs (NSURLSession on iOS, OkHttp on Android). This results in duplicate breadcrumbs for every HTTP request.

This PR adds deduplication logic in deviceContextIntegration.processEvent that filters out native http breadcrumbs when a matching JS xhr/fetch breadcrumb exists (same method, URL, status code, and timestamp within 2s tolerance).

Key design choices:

  • Keeps the JS breadcrumb, drops the native one — the JS breadcrumb goes through beforeBreadcrumb, giving users filtering control
  • Consumed-match tracking — each JS breadcrumb can only absorb one native duplicate, preventing false positives with consecutive identical requests
  • Only targets native HTTP breadcrumbs — non-HTTP native breadcrumbs (ui.click, etc.) are untouched
  • Native-only HTTP requests preserved — requests from native code (ObjC/Swift/Java) with no JS counterpart are kept
  • Handles string/number status_code mismatch — uses Number() coercion for comparison

Also updates the FIXME comment in breadcrumbs.ts to reflect that deduplication now happens in deviceContextIntegration.

💡 Motivation and Context

Closes #3045

Users see duplicate HTTP breadcrumbs (2x per request) which crowd out meaningful breadcrumbs and cannot be filtered via beforeBreadcrumb since native breadcrumbs bypass that callback.

The sentry-cocoa side of this (cocoa producing its own internal duplicates, #2971) was fixed in sentry-cocoa 8.8.0. The remaining duplication is the JS vs native layer, which this PR addresses.

💚 How did you test it?

  • Added 8 unit tests covering: basic dedup, no-match preservation, non-HTTP breadcrumb preservation, timestamp tolerance boundary, multiple identical requests, string/number status_code coercion, empty JS breadcrumbs, and fetch category support
  • All existing tests pass unmodified
  • Build passes (yarn build)
  • Lint passes (yarn lint)

📝 Checklist

  • 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.
  • I updated the wizard if needed.
  • All tests passing
  • No breaking changes

🔮 Next steps

…fetch breadcrumbs

Closes #3045

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 11, 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).


  • fix(core): Deduplicate native HTTP breadcrumbs by antonis in #6132
  • chore(deps): update CLI to v3.4.2 by github-actions in #6129
  • chore(deps): bump getsentry/craft/.github/workflows/changelog-preview.yml from 2.26.2 to 2.26.3 by dependabot in #6126
  • chore(deps): bump getsentry/craft from 2.26.2 to 2.26.3 by dependabot in #6127
  • chore(deps): bump github/codeql-action from 4.35.3 to 4.35.4 by dependabot in #6128
  • feat(core): Extract text from children of touched components for breadcrumb labels by antonis in #6106
  • chore(deps): bump @babel/plugin-transform-modules-systemjs from 7.25.0 to 7.29.4 by dependabot in #6124
  • chore(deps): bump fast-uri from 3.0.1 to 3.1.2 by dependabot in #6121
  • chore(deps): bump fast-xml-builder from 1.1.5 to 1.2.0 by dependabot in #6120
  • chore(deps): bump socks to ^2.8.8 to fix ip-address vulnerability by antonis in #6117
  • chore(deps): bump uuid to ^13.0.1 to fix buffer bounds check vulnerability by antonis in #6118
  • test(replay): Add passthrough tests for device-state replay breadcrumbs by antonis in #6115
  • chore(deps): update JavaScript SDK to v10.52.0 by github-actions in #6108
  • chore(deps): bump basic-ftp from 5.3.0 to 5.3.1 by dependabot in #6111

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 11, 2026

Fails
🚫 Pull request is not ready for merge, please add the "ready-to-merge" label to the pull request

Generated by 🚫 dangerJS against b8adccf

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit d52d0ef. Configure here.

@antonis antonis marked this pull request as ready for review May 11, 2026 13:31
Comment thread packages/core/src/js/integrations/devicecontext.ts Outdated
Network errors, aborted requests, and CORS failures produce breadcrumbs
without a status_code. Treat both sides being null/undefined as a match.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Comment thread packages/core/src/js/integrations/devicecontext.ts
Previously only string timestamps were parsed; numeric timestamps
(seconds since epoch) were silently dropped.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.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.

Duplicate http / xhr breadcrumbs

1 participant