diff --git a/app/src/main/java/io/xpipe/app/issue/SentryErrorHandler.java b/app/src/main/java/io/xpipe/app/issue/SentryErrorHandler.java index 425e2b2cb..4b16318ff 100644 --- a/app/src/main/java/io/xpipe/app/issue/SentryErrorHandler.java +++ b/app/src/main/java/io/xpipe/app/issue/SentryErrorHandler.java @@ -39,6 +39,14 @@ public class SentryErrorHandler implements ErrorHandler { return hasEmail || hasText; } + private static boolean doesExceedCommentSize(String text) { + if (text == null || text.isEmpty()) { + return false; + } + + return text.length() > 5000; + } + private static Throwable adjustCopy(Throwable throwable, boolean clear) { if (throwable == null) { return null; @@ -139,6 +147,16 @@ public class SentryErrorHandler implements ErrorHandler { atts.forEach(attachment -> s.addAttachment(attachment)); } + if (doesExceedCommentSize(ee.getUserReport())) { + try { + var report = Files.createTempFile("report", ".txt"); + Files.writeString(report, ee.getUserReport()); + s.addAttachment(new Attachment(report.toString())); + } catch (Exception ex) { + AppLogs.get().logException("Unable to create report file", ex); + } + } + s.setTag( "hasLicense", String.valueOf( @@ -231,7 +249,11 @@ public class SentryErrorHandler implements ErrorHandler { if (hasEmail) { fb.setEmail(email); } - fb.setComments(text); + if (doesExceedCommentSize(text)) { + fb.setComments(""); + } else { + fb.setComments(text); + } Sentry.captureUserFeedback(fb); } Sentry.flush(3000);