Skip to content

Commit

Permalink
android: Report all other logged warnings and errors to Sentry.
Browse files Browse the repository at this point in the history
This covers all of our call sites to `Log.w` and above.  We should do
the same with any future such call sites, too -- the `Log` call gets
it to the device log, and that could be quite handy for development,
but for issues encountered in a published build the Sentry call will
get it to our Sentry dashboard, which is much more likely to be helpful.
  • Loading branch information
gnprice committed Sep 8, 2021
1 parent b0eec6c commit eb20490
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import me.leolin.shortcutbadger.ShortcutBadger
import com.zulipmobile.BuildConfig
import com.zulipmobile.R
import com.zulipmobile.SentryX
import io.sentry.Sentry

private val CHANNEL_ID = "default"
private val NOTIFICATION_ID = 435
Expand Down Expand Up @@ -152,6 +153,7 @@ private fun getNotificationBuilder(
ShortcutBadger.applyCount(context, totalMessagesCount)
} catch (e: Exception) {
Log.e(TAG, "BADGE ERROR: $e")
Sentry.captureException(e)
}

builder.setWhen(fcmMessage.timeMs)
Expand Down Expand Up @@ -184,6 +186,7 @@ internal fun onOpened(application: ReactApplication, conversations: Conversation
ShortcutBadger.removeCount(application as Context)
} catch (e: Exception) {
Log.e(TAG, "BADGE ERROR: $e")
Sentry.captureException(e)
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import android.text.style.StyleSpan
import android.util.Log
import android.util.TypedValue
import androidx.core.app.NotificationCompat
import io.sentry.Sentry
import java.io.IOException
import java.io.InputStream
import java.net.URL
Expand All @@ -38,6 +39,7 @@ fun fetchBitmap(url: URL): Bitmap? {
?.let { BitmapFactory.decodeStream(it) }
} catch (e: IOException) {
Log.e(TAG, "ERROR: $e")
Sentry.captureException(e)
null
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import android.util.Log
import com.facebook.react.ReactApplication
import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.WritableMap
import com.zulipmobile.SentryX
import com.zulipmobile.notifications.ReactAppStatus
import com.zulipmobile.notifications.appStatus
import com.zulipmobile.notifications.emit
Expand Down Expand Up @@ -41,6 +42,7 @@ private fun handleSend(intent: Intent, application: ReactApplication, contentRes
getParamsFromIntent(intent, contentResolver)
} catch (e: ShareParamsParseException) {
Log.w(TAG, "Ignoring malformed share Intent: ${e.message}")
SentryX.warnException(e)
return
}

Expand Down

0 comments on commit eb20490

Please sign in to comment.