Skip to content

frinyvonnick/issue-reporter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Welcome to issue-reporter 👋

Version Documentation Maintenance License: Apache--2.0 Twitter: yvonnickfrin

A lib that generates issue reports for unexcepted errors.

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

option description type required
error An Error instance Error required
user You GitHub handle string required
repo The repository name of your project string required
envinfo A configuration object that is passed down to envinfo Object optional
sections Custom sections to add in the error report Array optional
formatReport A function that allows to write your own error report template function optional

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