Merge pull request #5019 from vector-im/feature/bca/auto_uisi_update

Quick fixes on auto uisi RS
This commit is contained in:
Benoit Marty 2022-01-25 16:41:01 +01:00 committed by GitHub
commit 871b05b641
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 49 additions and 20 deletions

1
changelog.d/5021.bugfix Normal file
View File

@ -0,0 +1 @@
Improve auto rageshake lab feature

View File

@ -67,6 +67,7 @@ class AutoRageShaker @Inject constructor(
fun initialize() {
observeActiveSession()
enable(vectorPreferences.labsAutoReportUISI())
// It's a singleton...
vectorPreferences.subscribeToChanges(this)
@ -141,17 +142,19 @@ class AutoRageShaker @Inject constructor(
withCrashLogs = true,
withKeyRequestHistory = true,
withScreenshot = false,
theBugDescription = "UISI detected",
theBugDescription = "Auto-reporting decryption error",
serverVersion = "",
canContact = false,
customFields = mapOf("auto-uisi" to buildString {
append("\neventId: ${target.eventId}")
append("\nroomId: ${target.roomId}")
append("\nsenderKey: ${target.senderKey}")
append("\nsource: ${target.source}")
append("\ndeviceId: ${target.senderDeviceId}")
append("\nuserId: ${target.senderUserId}")
append("\nsessionId: ${target.sessionId}")
customFields = mapOf("auto_uisi" to buildString {
append("{")
append("\"event_id\": \"${target.eventId}\",")
append("\"room_id\": \"${target.roomId}\",")
append("\"sender_key\": \"${target.senderKey}\",")
append("\"device_id\": \"${target.senderDeviceId}\",")
append("\"source\": \"${target.source}\",")
append("\"user_id\": \"${target.senderUserId}\",")
append("\"session_id\": \"${target.sessionId}\"")
append("}")
}),
listener = object : BugReporter.IMXBugReportListener {
override fun onUploadCancelled() {
@ -221,17 +224,19 @@ class AutoRageShaker @Inject constructor(
withCrashLogs = true,
withKeyRequestHistory = true,
withScreenshot = false,
theBugDescription = "UISI detected $matchingIssue",
theBugDescription = "Auto-reporting decryption error \nRecipient rageshake: $matchingIssue",
serverVersion = "",
canContact = false,
customFields = mapOf(
"auto-uisi" to buildString {
append("\neventId: $eventId")
append("\nroomId: $roomId")
append("\nsenderKey: $senderKey")
append("\ndeviceId: $deviceId")
append("\nuserId: $userId")
append("\nsessionId: $sessionId")
"auto_uisi" to buildString {
append("{")
append("\"event_id\": \"$eventId\",")
append("\"room_id\": \"$roomId\",")
append("\"sender_key\": \"$senderKey\",")
append("\"device_id\": \"$deviceId\",")
append("\"user_id\": \"$userId\",")
append("\"session_id\": \"$sessionId\"")
append("}")
},
"recipient_rageshake" to matchingIssue
),

View File

@ -259,13 +259,13 @@ class BugReporter @Inject constructor(
ReportType.SUGGESTION -> "[Element] [Suggestion] $bugDescription"
ReportType.SPACE_BETA_FEEDBACK -> "[Element] [spaces-feedback] $bugDescription"
ReportType.AUTO_UISI_SENDER,
ReportType.AUTO_UISI -> "[AutoUISI] $bugDescription"
ReportType.AUTO_UISI -> bugDescription
}
// build the multi part request
val builder = BugReporterMultipartBody.Builder()
.addFormDataPart("text", text)
.addFormDataPart("app", "riot-android")
.addFormDataPart("app", rageShakeAppNameForReport(context, reportType))
.addFormDataPart("user_agent", Matrix.getInstance(context).getUserAgent())
.addFormDataPart("user_id", userId)
.addFormDataPart("can_contact", canContact.toString())
@ -340,9 +340,15 @@ class BugReporter @Inject constructor(
}
ReportType.SUGGESTION -> builder.addFormDataPart("label", "[Suggestion]")
ReportType.SPACE_BETA_FEEDBACK -> builder.addFormDataPart("label", "spaces-feedback")
ReportType.AUTO_UISI,
ReportType.AUTO_UISI -> {
builder.addFormDataPart("label", "Z-UISI")
builder.addFormDataPart("label", "android")
builder.addFormDataPart("label", "uisi-recipient")
}
ReportType.AUTO_UISI_SENDER -> {
builder.addFormDataPart("label", "Z-UISI")
builder.addFormDataPart("label", "android")
builder.addFormDataPart("label", "uisi-sender")
}
}
@ -481,6 +487,21 @@ class BugReporter @Inject constructor(
activity.startActivity(BugReportActivity.intent(activity, reportType))
}
private fun rageShakeAppNameForReport(context: Context, reportType: ReportType): String {
// As per https://github.com/matrix-org/rageshake
// app: Identifier for the application (eg 'riot-web').
// Should correspond to a mapping configured in the configuration file for github issue reporting to work.
// (see R.string.bug_report_url for configured RS server)
return when (reportType) {
ReportType.AUTO_UISI_SENDER,
ReportType.AUTO_UISI -> {
context.getString(R.string.bug_report_auto_uisi_app_name)
}
else -> {
context.getString(R.string.bug_report_app_name)
}
}
}
// ==============================================================================================================
// crash report management
// ==============================================================================================================

View File

@ -7,6 +7,8 @@
<string name="matrix_org_server_url" translatable="false">https://matrix.org</string>
<string name="piwik_server_url" translatable="false">https://piwik.riot.im</string>
<string name="bug_report_url" translatable="false">https://riot.im/bugreports/submit</string>
<string name="bug_report_app_name" translatable="false">riot-android</string>
<string name="bug_report_auto_uisi_app_name" translatable="false">element-auto-uisi</string>
<!--
Pusher config for the application