From c054c20fe7f012d7398b663f8c43bb86681edf20 Mon Sep 17 00:00:00 2001 From: pushrbx Date: Mon, 30 Jan 2023 20:36:46 +0000 Subject: [PATCH] updated github error reporting with the new issue form --- .github/ISSUE_TEMPLATE/bug.yml | 10 +++++++++- app/Exceptions/GithubReport.php | 19 ++++++++++++++----- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml index 79fd86a..91d97ae 100644 --- a/.github/ISSUE_TEMPLATE/bug.yml +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -15,18 +15,21 @@ body: - label: I have searched the existing issues required: true - type: textarea + id: current_behavior attributes: label: Current Behavior description: A concise description of what you're experiencing. validations: required: false - type: textarea + id: expected_behavior attributes: label: Expected Behavior description: A concise description of what you expected to happen. validations: required: false - type: textarea + id: repro_steps attributes: label: Steps To Reproduce description: Steps to reproduce the behaviour. If the error came in a response from the REST API, please specify the url here. @@ -39,6 +42,7 @@ body: required: false - type: textarea attributes: + id: system_env label: Environment description: | If you have used the public API, please just say "Used public API", and add your browser and its version. @@ -47,14 +51,18 @@ body: - **OS**: Ubuntu 20.04 - **Browser**: Firefox 104.1 - **Android Runtime**: 7.6.3 - value: | + placeholder: | - OS: - Browser: + - PHP Version on server side (if self-hosted): + - Is redis used (if self-hosted): + - Search engine used (if self-hosted): render: markdown validations: required: false - type: textarea attributes: + id: extra_info label: Anything else? description: | Other information / Contextual information. Links? References? Anything that will give us more context about the issue you are encountering! diff --git a/app/Exceptions/GithubReport.php b/app/Exceptions/GithubReport.php index e408058..415f247 100644 --- a/app/Exceptions/GithubReport.php +++ b/app/Exceptions/GithubReport.php @@ -110,13 +110,22 @@ class GithubReport */ public function __toString() : string { - $title = urlencode("[{$this->instanceType}] Generated Issue: {$this->getClassName()}"); - $body = urlencode( - "Please fill out the details below.\n\n**Summary:**\n\n**Steps to reproduce:**\n\n\n\n ### Additional Details \n **Jikan Parser Version**: ```{$this->jikanVersion}```\n**PHP:** ```{$this->phpVersion}```\n**Redis**: ```{$this->redisRunning}```\n**Exception:** ```{$this->name}```\n**Code:** ```{$this->code}```\n**Message:** ```{$this->error}```\n**Trace:** ```{$this->trace}```\n**Request:** `{$this->requestMethod} {$this->requestUri}`\n" + // 🐛 emoji v + $title = "%F0%9F%90%9B" . urlencode(" [{$this->instanceType}] Generated Issue: {$this->getClassName()}"); + + $currentBehavior = urlencode( + "The API has returned an error: \n```{$this->name}```\nStatus code: ```{$this->code}```\nMessage: ```{$this->error}```\nTrace: ```{$this->trace}```" ); - // https://github.com/jikan-me/jikan-rest/issues/new?assignees=&labels=i%3A+bug%2C+i%3A+needs+triage&template=bug.md&title= - return "https://github.com/{$this->repo}/issues/new?title={$title}&body={$body}"; + $expectedBehavior = urlencode("The API should have returned a successful response with data."); + $env = urlencode( + "Jikan Parser Version**: ```{$this->jikanVersion}```\nPHP: ```{$this->phpVersion}```\nIs redis used: ```{$this->redisRunning}```" + ); + $reproSteps = urlencode( + "Http Request: `{$this->requestMethod} {$this->requestUri}" + ); + + return "https://github.com/{$this->repo}/issues/new?template=bug.yml&title={$title}&system_env={$env}&repro_steps={$reproSteps}&expected_behavior={$expectedBehavior}¤t_behavior={$currentBehavior}"; } /**