1.0.13 • Published 3 years ago

report-bug v1.0.13

Weekly downloads
15
License
MIT
Repository
github
Last release
3 years ago

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} reportLink={destination_link}/>

Props

user : string (current logged in user) appid : _string (client app name) color : string (bug icon color) reportLink : Link (API Endpoint)

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

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago