-
-
Notifications
You must be signed in to change notification settings - Fork 467
feat: Sync file attachments to native #5211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
a3da89d
af0502c
80f8875
944e481
6278324
170e77b
2e2d0ac
3597462
273a9ea
1ffacfc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,5 +1,6 @@ | ||||||
| package io.sentry.android.ndk; | ||||||
|
|
||||||
| import io.sentry.Attachment; | ||||||
| import io.sentry.Breadcrumb; | ||||||
| import io.sentry.DateUtils; | ||||||
| import io.sentry.IScope; | ||||||
|
|
@@ -145,4 +146,41 @@ public void setTrace(@Nullable SpanContext spanContext, @NotNull IScope scope) { | |||||
| options.getLogger().log(SentryLevel.ERROR, e, "Scope sync setTrace failed."); | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| @Override | ||||||
| public void addAttachment(final @NotNull Attachment attachment) { | ||||||
| final String pathname = attachment.getPathname(); | ||||||
| if (pathname != null) { | ||||||
| try { | ||||||
| options.getExecutorService().submit(() -> nativeScope.addAttachment(pathname)); | ||||||
| } catch (Throwable e) { | ||||||
| options.getLogger().log(SentryLevel.ERROR, e, "Scope sync addAttachment has an error."); | ||||||
| } | ||||||
| return; | ||||||
| } | ||||||
|
|
||||||
| final byte[] bytes = attachment.getBytes(); | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there's also sentry-java/sentry-android-core/src/main/java/io/sentry/android/core/ScreenshotEventProcessor.java Lines 144 to 145 in 55aaf9b
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||||||
| if (bytes != null) { | ||||||
| final String filename = attachment.getFilename(); | ||||||
| try { | ||||||
| options.getExecutorService().submit(() -> nativeScope.addAttachmentBytes(bytes, filename)); | ||||||
| } catch (Throwable e) { | ||||||
| options.getLogger().log(SentryLevel.ERROR, e, "Scope sync addAttachment has an error."); | ||||||
| } | ||||||
| return; | ||||||
| } | ||||||
|
|
||||||
| options | ||||||
| .getLogger() | ||||||
| .log(SentryLevel.DEBUG, "Scope sync addAttachment skips attachment without path or bytes."); | ||||||
| } | ||||||
|
|
||||||
| @Override | ||||||
| public void clearAttachments() { | ||||||
| try { | ||||||
| options.getExecutorService().submit(() -> nativeScope.clearAttachments()); | ||||||
| } catch (Throwable e) { | ||||||
| options.getLogger().log(SentryLevel.ERROR, e, "Scope sync clearAttachments has an error."); | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
Uh oh!
There was an error while loading. Please reload this page.