1.0.1 • Published 6 years ago

jerrbit v1.0.1

Weekly downloads
1
License
ISC
Repository
github
Last release
6 years ago

Jerrbit

npm GitHub license

Report client-side, browser events and exceptions to an Errbit or Airbrake service

Usage

var Client = require('jerrbit').Client;

var errbitClient = new Client({
  host: 'http://errbit.your-service.com',
  projectKey: 'ProjectAPIKey',
  context: {
    environment: 'production'
  }
});

try {
  // Your application code here

} catch(error){
  errbitClient.notify(error, {
    context: {
      version: '1.1.1'
    }
  });

  throw(error);
}

Options

Jerrbit.Client requires the following options to configure which Errbit server to use.

  • host: The URL of the Errbit server
  • projectKey: The API key for the project you wish log the errors against

Airbrake Options

Jerrbit supports all of the Airbrake V3 API properties and sets a lot of them for you, but all values can be overwritten if you need.

FieldRequiredSupplied by ErrbitDefault value is set inDescription
errorsYesYesnotifyAn array of objects describing the error that occurred.
errors/{i}/typeYesYesnotifyThe class name or type of error that occurred.
errors/{i}/messageNoYesnotifyA short message describing the error that occurred.
errors/{i}/backtraceYesYesnotifyAn array of objects describing each line of the error’s backtrace.
errors/{i}/backtrace/{i}/fileYesYesnotifyThe full path of the file in this entry of the backtrace.
errors/{i}/backtrace/{i}/lineNoYesnotifyThe file’s line number in this entry of the backtrace.
errors/{i}/backtrace/{i}/columnNoYesnotifyThe line’s column number in this entry of the backtrace.
errors/{i}/backtrace/{i}/functionNoYesnotifyWhen available, the function or method name in this entry of the backtrace.
contextNoNoNAAn object describing additional context for this error.
context/notifierYesYesN/AAn object describing the notifier client library.
context/notifier/nameYesYesnewThe name of the notifier client submitting the request, e.g. “airbrake-js”.
context/notifier/versionYesYesnewThe version number of the notifier client submitting the request, e.g. “1.2.3”.
context/notifier/urlYesYesnewA URL at which more information can be obtained concerning the notifier client.
context/environmentNo'development'newThe name of the server environment in which the error occurred, e.g. “staging”, “production”, etc.
context/componentNoNoN/AThe component or module in which the error occurred. In MVC frameworks like Rails, this should be set to the controller. Otherwise, this can be set to a route or other request category.
context/actionNoNoN/AThe action in which the error occurred. If each request is routed to a controller action, this should be set here. Otherwise, this can be set to a method or other request subcategory.
context/osNoYesnewDetails of the operating system on which the error occurred.
context/languageNo'JavaScript'newDescribe the language on which the error occurred, e.g. “Ruby 2.1.1”.
context/versionNoNoDescribe the application version, e.g. “v1.2.3”.
context/urlNoYesnotifyThe application’s URL.
context/userAgentNoYesnewThe requesting browser’s full user-agent string.
context/rootDirectoryNoNoN/AThe application’s root directory path.
context/user/idNoNoN/AIf applicable, the current user’s ID.
context/user/nameNoNoN/AIf applicable, the current user’s username.
context/user/emailNoNoN/AIf applicable, the current user’s email address.
environmentNoNoN/AAn object containing the current environment variables. Where the key is the variable name, e.g. { "PORT": "443", "CODE_NAME": "gorilla" }.
sessionNoYesnotifyAn object containing the current session variables. Where the key is the variable name, e.g. { "basket_total": "1234", "user_id": "123" }.
paramsNoYesnotifyAn object containing the request parameters. Where the key is the parameter name, e.g. { "page": "3", "sort": "desc" }.

Overwriting the default context values

You can overwrite the default values by either specifying them when instantiating Client or when calling notify. Values that are not expected to change over the course of your application should be specified when instantiating Client.

var errbitClient = new Client({
  host: 'http://errbit.your-service.com',
  projectKey: 'ProjectAPIKey',
  context: {
    environment: 'production',
    language: 'JavaScript & XML'
  }
});

Those values that can change should be set using notify. These values must be specified each time notify is called or they may be overwritten with the default values.

errbitClient.notify(error, {
  context: {
    user: window.user
  }
});