Skip to content

Commit b660442

Browse files
refactor(crash): Improve crash report payload and reduce cooldown
This commit refactors the crash reporting mechanism with two key improvements: - The cooldown period for sending crash reports has been reduced from 4 hours to 2 hours, allowing for more timely feedback. This was achieved by replacing the hardcoded millisecond value with `TimeUnit.HOURS.toMillis(2)`. - The JSON payload for the crash report has been updated. The generic `"thread": "main"` and `"message": "App crashed"` fields have been replaced with a more specific `"namespace": packageName` field, providing better context for debugging.
1 parent 5885332 commit b660442

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

app/src/main/java/com/github/droidworksstudio/mlauncher/CrashReportActivity.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import kotlinx.coroutines.launch
2626
import org.json.JSONObject
2727
import java.net.HttpURLConnection
2828
import java.net.URL
29+
import java.util.concurrent.TimeUnit
2930

3031
class CrashReportActivity : AppCompatActivity() {
3132
private var pkgName: String = emptyString()
@@ -78,7 +79,7 @@ class CrashReportActivity : AppCompatActivity() {
7879

7980

8081
private fun sendCrashReportNative() {
81-
val cooldownMs = 14_400_000L // 4 hours
82+
val cooldownMs = TimeUnit.HOURS.toMillis(2)
8283
val now = System.currentTimeMillis()
8384
val lastSent = getLastSent()
8485
val canSend = now - lastSent >= cooldownMs
@@ -112,8 +113,7 @@ class CrashReportActivity : AppCompatActivity() {
112113

113114
// Build crash JSON
114115
val crashJson = JSONObject().apply {
115-
put("thread", "main")
116-
put("message", "App crashed")
116+
put("namespace", packageName)
117117
put("device", JSONObject(deviceMap))
118118
put("timestamp", System.currentTimeMillis())
119119
put("logFileBase64", logBase64)

0 commit comments

Comments
 (0)