@jmshal/bugsnag-js-plugin-azure-functions

0.1.1 • Public • Published

@jmshal/bugsnag-js-plugin-azure-functions

@bugsnag/js plugin for Azure Function apps.

Installation

$ npm i --save @bugsnag/js @jmshal/bugsnag-js-plugin-azure-functions

Basic usage

const bugsnag = require('@bugsnag/js'); // or "@bugsnag/node"
const azureFunctionsPlugin = require('@jmshal/bugsnag-js-plugin-azure-functions');
const { validateJWT, doSomethingBuggy } = require('./my-function-utilities');

const bugsnagClient = bugsnag('API-KEY');
bugsnagClient.use(azureFunctionsPlugin);

const { wrapFunction } = bugsnagClient.getPlugin('azure-functions');

module.exports = wrapFunction(async (context, req) => {
  // The validateJWT function can also leave breadcrumbs because it has access to
  // the underlying Bugsnag client (eg. context.bugsnag.leaveBreadcrumb).
  const claims = await validateJWT(context);

  context.bugsnag.user = {
    id: claims.sub,
    email: claims.email,
  };

  await doSomethingBuggy(); // Throws and automatically gets reported
});

License

MIT ❤️

Readme

Keywords

none

Package Sidebar

Install

npm i @jmshal/bugsnag-js-plugin-azure-functions

Weekly Downloads

12

Version

0.1.1

License

MIT

Unpacked Size

4.85 kB

Total Files

4

Last publish

Collaborators

  • jacobmarshall