0.2.0 ā€¢ Published 4 years ago

issue-reporter v0.2.0

Weekly downloads
1,369
License
Apache-2.0
Repository
github
Last release
4 years ago

A lib that generates issue reports for unexcepted errors.

šŸ  Homepage

Prerequisites

  • npm >=5.5.0
  • node >=10.0.0

Install

yarn add issue-reporter

Usage

const issueReporter = require('issue-reporter')

async function main() {
  try {
    throw new Error('Some unexcepted error')
  } catch (e) {
    await issueReporter({
      error: e,
      user: 'frinyvonnick',
      repo: 'issue-reporter',
    })
  }
}

Output

issue-reporter's output depends on your environment:

If you terminal supports Hyperlinks it will print a friendly error message with a clickable link that opens a form to create a new issue with a prefilled error report on your project.

If your terminal doesn't support Hyperlinks, issue-reporter will copy the error report in your clipboard and print an url that opens a new issue on your project so you can directly paste the report on the issue template.

In case of a CI it will print an url that opens a new issue on your project followed by a full report error in markdown you can copy paste in the issue body.

Options

optiondescriptiontyperequired
errorAn Error instanceErrorrequired
userYou GitHub handlestringrequired
repoThe repository name of your projectstringrequired
envinfoA configuration object that is passed down to envinfoObjectoptional
sectionsCustom sections to add in the error reportArrayoptional
formatReportA function that allows to write your own error report templatefunctionoptional

Advanced examples

With sections

issue-reporter takes an extra option called sections that let you add information specific to your project. You can add as many sections as you want.

const issueReporter = require('issue-reporter')

async function main() {
  try {
    throw new Error('Some unexcepted error')
  } catch (e) {
    await issueReporter({
      error: e,
      user: 'frinyvonnick',
      repo: 'issue-reporter',
      sections: [
        {
          title: "My project specific information",
          content: {
            version: "1.0.1",
            release: "2.0.0",
            commit: "qwej79qwjeqw8euqo8wj8eq8"
          }
        }
      ]
    })
  }
}

With custom formatter

issue-reporter has a default markdown formatter. If you want a more flexible way to format your error reporter you can provide your own formatting function.

const issueReporter = require('issue-reporter')

async function main() {
  try {
    throw new Error('Some unexcepted error')
  } catch (e) {
    await issueReporter({
      error: e,
      user: 'frinyvonnick',
      repo: 'issue-reporter',
      formatReport: (errorReport) => {
        return `## ${errorReport.error.title}
        
        ${errorReport.error.stack}
        
        ## ${errorReport.environment.title}
        
        ${errorReport.environment.markdown}
        `
      },
    })
  }
}

Run tests

yarn run test

Author

šŸ‘¤ Yvonnick FRIN

šŸ‘¤ Franck ABGRALL

šŸ¤ Contributing

Contributions, issues and feature requests are welcome!Feel free to check issues page.

Show your support

Give a ā­ļø if this project helped you!

šŸ“ License

Copyright Ā© 2019 Yvonnick FRIN. This project is Apache--2.0 licensed.


This README was generated with ā¤ļø by readme-md-generator