Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

airbrake-mini-client

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

airbrake-mini-client

A lightweight alternative to airbrake-js.

  • 0.0.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

airbrake-mini-client

This is a lightweight client for airbrake (airbrake.io). The goal of this implementation is to provide a simpler and less invasive logging feature.

Create an instance

var AirbrakeMini = require('airbrake-mini-client')

var airbrakeMini = AirbrakeMini({ projectId: 12345, projectKey: 'ABCDEFGHILMNO' }) // projectId and projectKey are provided by airbrake

Notify an error

try {
  // critical code
} catch (e) {
  airbrakeMini.notify(e)
}

or

Promise.resolve()
  .then(() => {
    // something might go wrong here
  })
  .catch(e => {
    airbrakeMini.notify(e)
  })

Notify additional parameters

  airbrakeMini.notify({
    error: new Error('BOOM'),
    context: { severity: 'warning' }
    params: {}, // put here any field you want
    environment: {}, // put here any field you want
    session: {} // put here any field you want
  })

Configuration

AirbrakeMini constructor takes the following mandatory parameter:

  • projectId
  • projectKey

I strongly suggest to provide this optional parameter:

  • environment: 'local', 'staging', 'development', 'live'

These other paramenters are mostly for testing:

  • timeout: timeout for XMLHttpRequest
  • host: it defaults to airbrake host
  • reporter: an object providing a "notify" method

Filters

You can use this feature to avoid sending an error to the server if it matches some criteria. You can also use this function to enrich the notice with specific informations. You can add as many filters you want. The method is chainable.

  airbrakeMini.addFilter((notice) => {
    // if I return null, the notice gets discarded
    // I can also mutate the notice to add some data
  })

Here's some example:

  airbrakeMini
  .addFilter((notice) => {
    const { context } = notice
    if (context.url && context.url.indexOf('file') === 0) {
      return null
    }
    return notice
  })

Airbrake notice example:

{
  "id": "",
  "errors": [
    {
      "type": "ReferenceError",
      "message": "testing airbrake, please ignore! Special edition",
      "backtrace": [...]
    }
  ],
  "context": {
    "severity": "error",
    "windowError": true,
    "history": [],
    "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36",
    "url": "https://www.tes.com/jobs/apply/test/airbrake",
    "rootDirectory": "https://www.tes.com",
    "environment": "production",
    "language": "JavaScript",
    "notifier": {
      "name": "airbrake-mini-client",
      "version": "0.0.3",
      "url": "https://github.com/tes/airbrake-mini-client"
    }
  },
  "params": {},
  "environment": {},
  "session": {}
}

FAQs

Package last updated on 08 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc