Skip to content

i8labs/BugReport

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

report-bug

Installation

npm install --save report-bug

Import the report-bug Library.

import BugReport from 'report-bug';

Usage

 <BugReport user = {current_username} app_id = {current_appname} color = {bug_icon_color} />

Props

user : string (current logged in user) app_id : string (client app name) color : string (bug icon color)

Working

  • Users can report a bug anywhere in our app by clicking on the Bug Icon. As soon as the user clicks the bug icon , captureScreenhot() method is called and a screenshot of the current screen is taken by using the html2canvas method. This method takes a DOM element as input and returns it's image i.e. body in our case. The image is then converted to base64 encoded URL using  image_name.toDataURL() method and stored in the this.state.
     captureScreenShot = async () => {
       const canvas = await html2canvas(document.querySelector("body"));
       const base64 = canvas.toDataURL("image/jpeg");
       this.setState({ screenshot: base64, modal: true });
     };
  • The page_id of the page on which the bug icon is clicked is fetched by using  window.location.pathname which returns the filename of the current page. The description given by the user in text area is also stored in this.state .
   this.state = {
     page_id : window.location.pathname.slice(1)
   }
  • when user clicks the submit submitHandler() is called which makes a post request to adminbugreport Api and Page id , user id, description, app_id and base64 encoded screenshot are sent to the backend and stored in customer_error_report table. If successful the Api returns a BugID which is displayed to the user on screen.
   const body = { page_id, user_id, desc,app_id, screenshot };
   const res = await Axios.post(Endpoints.adminbugreport, body);
   const bugId = res.data.body

Demo of Report Bug interface. Demo of bug submitted interface.

MIT © anuj@i8labs.io

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published