Skip to content

Feat: allow logcat attachment to be previewed in Sentry - #3711

Merged
jamescrosswell merged 6 commits into
mainfrom
feat/#3703_logcat_preview
Oct 31, 2024
Merged

jamescrosswell merged 6 commits into
mainfrom
feat/#3703_logcat_preview

Conversation

@bricefriha

@bricefriha bricefriha commented Oct 25, 2024 •

Copy link
Copy Markdown
Contributor

Context

As issue #3703 reports, Logcats files currently attached to Sentry issues are not previewable.

image

This issue is due to the mime-type sent with the file, as it currently has its own type, text/logcat. However, Sentry's preview component does not support this type.
This PR aims to tackle just that by changing the mime-type we send from text/logcat to text/plain.

image

Caviat

I personally believe that the user should have a more console-like experience when looking at the preview on Sentry. To tackle this, an issue in Sentry's repo is currently open. So, the PR would offer more of a temporary fix than a complete solution.
Therefore, when/if text/logcat gets support, we could change the mime-type back on our end

@github-actions

github-actions Bot commented Oct 25, 2024 •

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

Generated by 🚫 dangerJS against 978e231

bricefriha added a commit that referenced this pull request Oct 25, 2024
@bricefriha
bricefriha force-pushed the feat/#3703_logcat_preview branch from eb64624 to 3106b92 Compare October 29, 2024 05:57
@bricefriha

Copy link
Copy Markdown
Contributor Author

I can't find a way to get mime-type during device tests.

But it's not like we need to test this since the mime-type been hardcoded anyways

@bricefriha
bricefriha marked this pull request as ready for review October 29, 2024 08:01
@jamescrosswell

jamescrosswell commented Oct 30, 2024 •

Copy link
Copy Markdown
Collaborator

I can't find a way to get mime-type during device tests.

But it's not like we need to test this since the mime-type been hardcoded anyways

@bricefriha the device tests are just unit tests that get run on Android or iOS by our device runner here:

conf.AddTestAssemblies([
typeof(Sentry.Tests.SentrySdkTests).Assembly,
typeof(Sentry.Extensions.Logging.Tests.LogLevelExtensionsTests).Assembly,
typeof(Sentry.Maui.Tests.SentryMauiOptionsTests).Assembly,
#if ANDROID
typeof(Sentry.Android.AssemblyReader.Tests.AndroidAssemblyReaderTests).Assembly,
#endif
]);

So you don't need to do anything special... just write some unit tests for LogCatAttachmentEventProcessor.Process.

Note: I see that method isn't very testable... it references static methods like OperatingSystem.IsAndroidVersionAtLeast so it might need to be refactored a bit.

@bricefriha
bricefriha marked this pull request as draft October 30, 2024 08:50
@bricefriha
bricefriha force-pushed the feat/#3703_logcat_preview branch from 67cdfc8 to defbf1a Compare October 30, 2024 12:18
@bricefriha
bricefriha marked this pull request as ready for review October 30, 2024 12:51

@jamescrosswell jamescrosswell left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good - thanks @bricefriha !

Just one question - have you actually tested this in an android app to make sure the logs come through OK and can be previewed in Sentry?

@bricefriha

bricefriha commented Oct 31, 2024 •

Copy link
Copy Markdown
Contributor Author

have you actually tested this in an android app to make sure the logs come through OK and can be previewed in Sentry?

@jamescrosswell I have tested with the sample we have and it can be previewed in Sentry (as you can see on the screenshot in the description)

@jamescrosswell
jamescrosswell merged commit 44d0c69 into main Oct 31, 2024
@jamescrosswell
jamescrosswell deleted the feat/#3703_logcat_preview branch October 31, 2024 23:41
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.

3 participants