X Tutup
Skip to content

feat: Sync file attachments to native#5211

Open
bitsandfoxes wants to merge 11 commits intomainfrom
feat/sync-file-attachment
Open

feat: Sync file attachments to native#5211
bitsandfoxes wants to merge 11 commits intomainfrom
feat/sync-file-attachment

Conversation

@bitsandfoxes
Copy link
Contributor

📜 Description

Relies on getsentry/sentry-native#1584

Attachments added to the scope should get synced to sentry-native. I.e. a Unity games has

SentrySdk.ConfigureScope(scope => scope.AddAttachment("special-logfile.log");

and the game crashes, that attachment should be available in the resulting sentry event.

💡 Motivation and Context

Resolves #4758

💚 How did you test it?

Unit tests. Unity SDK will have e2e tests.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the 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.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

This needs to be used and implemented in the hybrid SDKs.
Adding support to sync bytes as attachments.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 18, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • Sync file attachments to native by bitsandfoxes in #5211

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 18, 2026

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 46718e3

@sentry
Copy link

sentry bot commented Mar 20, 2026

Sentry Build Distribution

App Name App ID Version Configuration Install Page
SDK Size io.sentry.tests.size 8.37.1 (1) release Install Build

return;
}

final byte[] bytes = attachment.getBytes();
Copy link
Member

Choose a reason for hiding this comment

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

there's also attachment.getByteProvider() which lazily evaluates and retrieves the bytes -- not sure if you want to support that from the gaming SDKs, but we use it when getting the bytes is heavy for the main thread, so it gets offloaded to the envelope serialization time on a bg thread, e.g.

Attachment.fromByteProvider(
() -> ScreenshotUtils.compressBitmapToPng(finalScreenshot, options.getLogger()),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think invoking the ByteProvider from inside the signal handler is going to be extremely risky. But I'll keep that in mind.

Copy link
Member

@romtsn romtsn left a comment

Choose a reason for hiding this comment

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

LGTM!

@bitsandfoxes bitsandfoxes marked this pull request as ready for review March 20, 2026 11:41
@github-actions
Copy link
Contributor

github-actions bot commented Mar 20, 2026

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 352.81 ms 421.24 ms 68.43 ms
Size 0 B 0 B 0 B

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
6405ec5 310.88 ms 354.56 ms 43.69 ms
d5a29b6 298.62 ms 391.78 ms 93.16 ms
f064536 329.00 ms 395.62 ms 66.62 ms
fcec2f2 357.47 ms 447.32 ms 89.85 ms
bbc35bb 324.88 ms 425.73 ms 100.85 ms
694d587 312.37 ms 402.77 ms 90.41 ms
b8bd880 314.56 ms 336.50 ms 21.94 ms
889ecea 367.58 ms 437.52 ms 69.94 ms
e2dce0b 308.96 ms 360.10 ms 51.14 ms
83884a0 334.46 ms 400.92 ms 66.46 ms

App size

Revision Plain With Sentry Diff
6405ec5 1.58 MiB 2.12 MiB 552.23 KiB
d5a29b6 1.58 MiB 2.12 MiB 549.37 KiB
f064536 1.58 MiB 2.20 MiB 633.90 KiB
fcec2f2 1.58 MiB 2.12 MiB 551.50 KiB
bbc35bb 1.58 MiB 2.12 MiB 553.01 KiB
694d587 1.58 MiB 2.19 MiB 620.06 KiB
b8bd880 1.58 MiB 2.29 MiB 722.92 KiB
889ecea 1.58 MiB 2.11 MiB 539.75 KiB
e2dce0b 0 B 0 B 0 B
83884a0 1.58 MiB 2.29 MiB 722.97 KiB


### Features

- Android: Attachments on the scope will now be synced to native ([#5211](https://github.com/getsentry/sentry-java/pull/5211))
Copy link
Contributor

Choose a reason for hiding this comment

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

  • 🚫 The changelog entry seems to be part of an already released section ## 8.37.1.
    Consider moving the entry to the ## Unreleased section, please.

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.

Attachments set in Java do not end up in NDK crashes

3 participants

X Tutup