How to use the @bugsnag/js.notify function in @bugsnag/js

To help you get started, we’ve selected a few @bugsnag/js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bugsnag / bugsnag-js / examples / typescript / src / app.ts View on Github external
function onError () {
  console.log('calling notify() with an onError callback…')
  // onError can be used to modify a report or prevent it from being sent at all
  // this example pseudo-randomly filters out approximately half of the reports
  Bugsnag.notify(new Error('sometimes will send'), (event) => {
    const n = Math.random()
    if (n <= 0.5) return false
  })
}
github bugsnag / bugsnag-js / examples / typescript / src / app.ts View on Github external
function handledError () {
  console.log('notifying of a handled error…')
  // you can notify Bugsnag of errors you handled or created yourself
  Bugsnag.notify(new Error('scheduling clash'))
}
github bugsnag / bugsnag-js / examples / plain-node / app.js View on Github external
function onError () {
  console.log('calling notify() with a onError callback…')
  // onError can be used to modify a report or prevent it from being sent at all
  // this example pseudo-randomly filters out approximately half of the reports
  Bugsnag.notify(new Error('sometimes will send'), (event) => {
    const n = Math.random()
    if (n <= 0.5) return false
  })
}
github bugsnag / bugsnag-js / examples / angular / src / app / app.component.ts View on Github external
triggerHandledError() {
    this.doAHandledError = true;

    try {
      // potentially buggy code goes here
      var niceCode = "Everything is fine here.";
      throw("Bad thing!");
    } catch (e) {
      // below modifies the handled error, and then sends it to your dashboard.
      Bugsnag.notify(e, event => {
          event.context = 'Don\'t worry - I handled it!'
      });
    }
    // resets the button
    setTimeout(function () {
    this.doAHandledError = false;
    }.bind(this), 1000);
  }
github bugsnag / bugsnag-js / examples / nuxtjs / modules / bugsnag / index.js View on Github external
    errors.forEach(({ error }) => Bugsnag.notify(error, event => event.addMetadata('route', route)))
  })
github exercism / website / app / javascript / components / ErrorBoundary.tsx View on Github external
.catch((e) => {
          Bugsnag.notify(e)

          handler(new HandledError(defaultError.message))
        })
    }
github exercism / website / app / javascript / components / ErrorBoundary.tsx View on Github external
useEffect(() => {
    if (!error) {
      return
    }

    if (error instanceof Error) {
      Bugsnag.notify(error)

      handler(new HandledError(defaultError.message))
    } else if (error instanceof Response) {
      error
        .clone()
        .json()
        .then((res: { error: APIError }) => {
          handler(new HandledError(res.error.message))
        })
        .catch((e) => {
          Bugsnag.notify(e)

          handler(new HandledError(defaultError.message))
        })
    }
  }, [defaultError, error, handler])
github exercism / website / app / javascript / components / ErrorBoundary.tsx View on Github external
const handleError = (error: Error) => {
  if (error.name === 'HandledError') {
    return
  }

  Bugsnag.notify(error)
}

@bugsnag/js

Universal Javascript error reporting. Automatically detect JavaScript errors in the browser and Node.js, with plugins for React, Vue, Angular, Express, Restify and Koa.

MIT
Latest version published 11 days ago

Package Health Score

89 / 100
Full package analysis