Skip to content

webcrofting/bugsnag-j2ee

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bugsnag Notifier for J2EE (Based on Bugsnag Notifier for Android)

For the Bugsnag Notifier for Android see https://github.com/bugsnag/bugsnag-android

The Bugsnag Notifier for J2EE gives you instant notification of exceptions thrown from your Android applications. The notifier hooks into Thread.UncaughtExceptionHandler, which means any uncaught exceptions will trigger a notification to be sent to your Bugsnag project.

Bugsnag captures errors in real-time from your web, mobile and desktop applications, helping you to understand and resolve them as fast as possible. Create a free account to start capturing exceptions from your applications.

Installation & Setup

Download the latest bugsnag.jar file and place it in your J2EE app's libs/ folder.

Import the Bugsnag package in your Activity.

The project contains a ServletContextListener that registers with bugsnag.

You only have to provide a properties file in the class path called bugsnag.properties that contains

apikey=[your-api-key]

Send Non-Fatal Exceptions to Bugsnag

If you would like to send non-fatal exceptions to Bugsnag, you can pass any Throwable object to the notify method:

Bugsnag.notify(new RuntimeException("Non-fatal"), servletRequest);

You can also send additional meta-data with your exception:

Map<String,String> extraData = new HashMap<String,String>();
extraData.put("username", "bob-hoskins");
extraData.put("registered_user", "yes");

Bugsnag.notify(new RuntimeException("Non-fatal"), servletRequest, extraData);

Configuration

###setContext

Bugsnag uses the concept of "contexts" to help display and group your errors. Contexts represent what was happening in your application at the time an error occurs. In an android app, it is useful to set this to be your currently active Activity.

If you are using BugsnagActivity then this is set automatically for you. If you would like to set the bugsnag context manually, you can call setContext:

Bugsnag.setContext("MyActivity");

###setUserId

Bugsnag helps you understand how many of your users are affected by each error. In order to do this, we send along a userId with every exception. By default we will generate a unique ID and send this ID along with every exception from an individual device.

If you would like to override this userId, for example to set it to be a username of your currently logged in user, you can call setUserId:

Bugsnag.setUserId("leeroy-jenkins");

###setReleaseStage

If you would like to distinguish between errors that happen in different stages of the application release process (development, production, etc) you can set the releaseStage that is reported to Bugsnag.

Bugsnag.setReleaseStage("development");

By default this is set to be "production".

###setNotifyReleaseStages

By default, we will only notify Bugsnag of exceptions that happen when your releaseStage is set to be "production". If you would like to change which release stages notify Bugsnag of exceptions you can call setNotifyReleaseStages:

Bugsnag.setNotifyReleaseStages(new String[]{"production", "development"});

###setAutoNotify

By default, we will automatically notify Bugsnag of any fatal exceptions in your application. If you want to stop this from happening, you can call setAutoNotify:

Bugsnag.setAutoNotify(false);

###setExtraData

It if often very useful to send some extra application or user specific data along with every exception. To do this, you can call the setExtraData method:

Map<String,String> extraData = new HashMap<String,String>();
extraData.put("username", "bob-hoskins");
extraData.put("registered_user", "yes");

Bugsnag.setExtraData(extraData);

###setFilters

Sets the strings to filter out from the extraData maps before sending them to Bugsnag. Use this if you want to ensure you don't send sensitive data such as passwords, and credit card numbers to our servers. Any keys which contain these strings will be filtered.

Bugsnag.setFilters(new String[]{"password", "credit_card_number"});

By default, filters is set to new String[] {"password"};

Building from Source

###Dependecies:

Java Servlet (eg. from Tomcat) JSON Java ( https://github.com/douglascrockford/JSON-java )

To build a .jar file from source, clone the bugsnag-android repository and run:

ant package

This will generate a file named bugsnag.jar.

Reporting Bugs or Feature Requests

Please report any bugs or feature requests on the github issues page for this project here:

https://github.com/bugsnag/bugsnag-j2ee/issues

Contributing

License

The Bugsnag J2EE notifier is free software released under the MIT License. See LICENSE.txt for details.

About

The bugsnag notifier for android clients.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%