/** * Quick and dirty Android Crash Dump analyzer * * https://gitpull.it/P15 */ // This should be less than 50 to avoid "Request-URI Too Long" when creating the task using // a super-long GET URL... //$logcat_max_lines = 20; $logcat_max_lines = 30; // base of your Phabricator define( 'BASE_URI', 'https://gitpull.it/maniphest/task/edit/form/3/?' ); // received data from textarea $data_raw = $_POST['data'] ?? null; // or, receive data from file if (!$data_raw && isset($_FILES['data_file']['tmp_name'])) { $data_raw = file_get_contents($_FILES['data_file']['tmp_name']); } $data_clean_text = null; $task_args = null; if( $data_raw ) { $data = @json_decode( $data_raw ); if( $data ) { $data_raw = json_encode( $data, JSON_PRETTY_PRINT ); $app_version_name = $data->APP_VERSION_NAME ?? null; // Take only some lines of logcat. $logcat_reduced = null; $logcat = $data->LOGCAT ?? null; if ($logcat) { $lines = explode("\n", $logcat); // Pop last lines, until limit is reached. $last_lines = []; do { $last_line = null; if ($lines) { $last_line = array_pop($lines); } if ($last_line !== null) { // Check if the line is in scope. The 'ACRA' is shit. if (mb_strpos($last_line, ' E/ACRA ') === false) { $last_lines[] = $last_line; } } } while($last_line !== null && count($last_lines) < $logcat_max_lines); $last_lines = array_reverse($last_lines); $logcat_reduced = implode("\n", $last_lines); } // some useful informations $data_clean = [ 'Version code' => $data->APP_VERSION_CODE ?? null, 'Version name' => $app_version_name, 'Android version' => $data->ANDROID_VERSION ?? null, 'Phone' => $data->PHONE_MODEL ?? null, 'Brand' => $data->BRAND ?? null, 'Stack' => $data->STACK_TRACE ?? null, "logcat (last $logcat_max_lines lines)" => $logcat_reduced, ]; // build an human phrase $data_clean_parts = []; foreach( $data_clean as $k => $v ) { $data_clean_parts[] = "$k:\n$v"; } $data_clean_text = implode( "\n\n", $data_clean_parts ); $data_clean_text = trim($data_clean_text); // build query string $task_args = [ 'title' => "Fix crash caused by ... on version $app_version_name", 'description' => implode( "\n", [ "Dear Developers of the amazing Free/Libre and Open Source app #libre_busto,", "Please triage my crash:", '', '```', $data_clean_text, '```', '', '', "Thank you! :)", '', '', "> Generated with https://lab.reyboz.it/libre-busto/crash-report/ (P15)", ] ), ]; } else { $data_raw = 'invalid'; } } ?>