1.29.0 • Published 7 months ago

@tuplo/unhandler v1.29.0

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

Why

Creates bug reports for uncaught exceptions and unhandled rejections. Works like a DYI Sentry client for NodeJS. Can publish bug reports on different trackers simultaneously. Not suited to be used on browsers as it would need to expose your APIs' access secrets to the public.

Install

$ npm install @tuplo/unhandler

# or with yarn
$ yarn add @tuplo/unhandler

Usage

import { unhandler } from '@tuplo/unhandler';

Registers event handlers for uncaughtException and unhandledRejection

unhandler({
  appName: 'my-app-1',
  providers: {
    github: {
      user: 'tuplo',
      repo: 'unhandler',
      token: 'secret-token-xxxxxxx',
    },
  },
});

throw new Error('buggy bug');

// will create a GitHub issue with title "[my-app-1] buggy bug"

Creates bug reports directly with submitError

import { submitError } from '@tuplo/unhandler';

const error = new Error('buggy bug');

await submitError(error, {
  appName: 'my-app-1',
  providers: {
    github: {
      user: 'tuplo',
      repo: 'unhandler',
      token: 'secret-token-xxxxxxx',
    },
  },
});

// will create a GitHub issue with title "[my-app-1] buggy bug"

Registers an event handler onBeforeSubmitError or onAfterSubmitError

import { submitError } from '@tuplo/unhandler';

const error = new Error('buggy bug');

await submitError(error, {
  appName: 'my-app-1',
  onBeforeSubmitError: (error) => console.error(error),
  onAfterSubmitError: (error) => console.error(error),
  providers: {
    github: {
      user: 'tuplo',
      repo: 'unhandler',
     token: 'secret-token-xxxxxxx',
   },
  },
});

// will output the error before and after submitting

Error tracking providers

  • GitHub Issues
  • Trello
  • JIRA

Options

appName

string

The name of the application triggering the error.

onBeforeSubmitError

(error) => Promise<void> | optional

An optional function to be called just before submitting the error.

onAfterSubmitError

(error) => Promise<void> | optional

An optional function to be called just after submitting the error.

providers

Provider[]

shouldSubmitError

boolean | optional

Decides if the error should actually be submitted. Normally coupled with onBeforeSubmitError to do something else with the Error but not submit it. If false it doesn't submit the error and doesn't call onAfterSubmitError. Defaults to true.

GitHub
nametypedescription
userstringThe user or organization, owner of the repository where issues will be created.
repostringThe name of the repository where issues will be created.
tokenstringGitHub's personal access token with a repo scope.

License

MIT

1.29.0

7 months ago

1.27.3

1 year ago

1.28.0

1 year ago

1.27.2

1 year ago

1.27.1

1 year ago

1.26.0

2 years ago

1.27.0

2 years ago

1.26.1

2 years ago

1.25.0

2 years ago

1.25.1

2 years ago

1.24.0

2 years ago

1.23.1

2 years ago

1.25.2

2 years ago

1.23.0

2 years ago

1.22.0

2 years ago

1.21.0

2 years ago

1.20.0

2 years ago

1.19.0

3 years ago

1.18.0

3 years ago

1.17.0

3 years ago

1.16.0

3 years ago

1.15.0

3 years ago

1.14.1

3 years ago

1.15.1

3 years ago

1.14.2

3 years ago

1.14.0

3 years ago

1.13.0

3 years ago

1.12.0

3 years ago

1.11.0

3 years ago

1.9.0

3 years ago

1.8.0

3 years ago

1.7.0

3 years ago

1.6.0

3 years ago

1.10.0

3 years ago

1.5.0

3 years ago

1.4.0

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago