-
-
Notifications
You must be signed in to change notification settings - Fork 655
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
Set up Sentry for Android-native code #4996
Changes from all commits
da4d32f
abce92b
da28998
ab3ab62
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.zulipmobile | ||
|
||
import io.sentry.Sentry | ||
import io.sentry.SentryLevel | ||
|
||
/** | ||
* A home for things that ought to be static extensions of `Sentry`. | ||
* | ||
* Extending Java classes with static members isn't currently a feature | ||
* available in Kotlin: | ||
* https://youtrack.jetbrains.com/issue/KT-11968 | ||
* so this is our substitute. | ||
*/ | ||
class SentryX { | ||
companion object { | ||
/** | ||
* Like `Sentry.captureException`, but at level `SentryLevel.WARNING`. | ||
*/ | ||
public fun warnException(e: Throwable) { | ||
Sentry.withScope { scope -> | ||
scope.level = SentryLevel.WARNING | ||
Sentry.captureException(e) | ||
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. Interesting, I think I'd expect that you'd have to pass the 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. Yeah. I think this API actually makes more sense than it would if you did have to pass it: basically the point is that there's always a current scope (there has to be, to handle uncaught exceptions where you don't explicitly invoke Sentry at all), and so The Sentry.pushScope {
Sentry.configureScope { scope -> scope.level = SentryLevel.WARNING }
Sentry.captureException(e)
} (Well, and I'd probably make Sentry.pushScope {
Sentry.currentScope.level = SentryLevel.WARNING
Sentry.captureException(e)
} ) |
||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.zulipmobile | ||
|
||
import android.util.Log | ||
import io.sentry.Sentry | ||
|
||
/** | ||
* Zulip-specific logging helpers. | ||
* | ||
* These mirror part of the interface of `android.util.Log`, but they log | ||
* to Sentry as well as to the device console. | ||
* | ||
* We basically always want to use these instead of plain `Log.e` or `Log.w`. | ||
*/ | ||
class ZLog { | ||
companion object { | ||
/** Log an error to both Sentry and the device log. */ | ||
public fun e(tag: String, e: Throwable) { | ||
// Oddly there is no `Log.e` taking just a throwable, like there is for `Log.w`. | ||
// Have a message that just repeats the first line of how the throwable prints. | ||
val msg = "${e.javaClass.name}: ${e.message}" | ||
Log.e(tag, msg, e) | ||
Sentry.captureException(e) | ||
} | ||
|
||
/** Log a warning to both Sentry and the device log. */ | ||
public fun w(tag: String, e: Throwable) { | ||
Log.w(tag, e) | ||
SentryX.warnException(e) | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(IIUC)
I think it makes sense that getsentry/sentry-react-native#1102 would be the issue with
TextCompressionModule#decompress
, and that that report would be accurate about the problem being debug-mode-only. But I don't think we're 100% sure, right?So I wonder if this deserves an asterisk on the word "should", just in case we find an uncaught exception not being reported to Sentry in the future? Maybe just a link to #4996 (comment).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure; added a note about that.