Attachement added in `setBeforeSend` are not visible in Sentry.
Integration
sentry-android
Build System
Gradle
AGP Version
4.11.0
Proguard
Disabled
Version
7.12.1 and 7.15.0
Steps to Reproduce
App is written in Kotlin, here is the code snippets used:
options.beforeSend =
BeforeSendCallback { event: SentryEvent, hint: Hint ->
try {
val data = ByteArrayOutputStream()
val zipOutputStream = ZipOutputStream(data)
val file = ZipEntry("test.txt")
zipOutputStream.putNextEntry(file)
zipOutputStream.write("hello world".toByteArray(Charsets.UTF_8))
zipOutputStream.closeEntry()
zipOutputStream.close()
hint.addAttachment(Attachment(data.toByteArray(), "test.zip"))
} catch (e: Exception) {
logger.error("error when attaching logs to the event", e)
throw RuntimeException(e)
}
}
and
options.beforeSend =
BeforeSendCallback { event: SentryEvent, hint: Hint ->
try {
hint.addAttachment(
Attachment("test attachment string".toByteArray(), "test.zip")
)
} catch (e: Exception) {
logger.error("error when attaching logs to the event", e)
throw RuntimeException(e)
}
}
A minimal reproduction app is currently not available. When creating a simple app with the suggested snippet the attachments are correctly added to events, but when adding it to the production app, no attachments are sent to Sentry.
More information is available in the internal ticket on this link (comment from 14.10).
Expected Result
The events in Sentry have attachment added to the hint in the beforeSend callback, as in the test app:
- https://dev-curumas.sentry.io/issues/5990004349/events/21a5fa27209d4151bdc0b7aabdde4107/
Actual Result
No attachment on events. ~~Logs~~ The Stats page shows only attachments dropped due to size, but it has been tested with files a few KB large and the test event is correctly accepted.
Thanks for reporting, we'll have a look into this. Since this is only happening in production builds: Do you apply any code obfuscation / minification tools like ProGuard / DexGuard / R8?
hey @rodolfoBee The snippet seems to work fine. Can you give us some more information on how it is executed in the production app? Also, is there any custom event processor?
@rodolfoBee any updates on this one? Otherwise we'll close this issue next week 😄
no updates from the affected user. We can close it.