airbox
ActiveResource extension to easily access and manipulate objects from Airbrake's reporting API.
Usage
In your app, define Airbox.site & Airbox.auth_token to initialize the extension:
Airbox.site = "site_url"
Airbox.auth_token = "token"
(Airbox will automatically scan for airbox.rb in the project's root directory; feel free to stash an initializer anywhere else).
Most of the time, you'll want to start with a collection of resources:
@resources = Airbox::Group.find :all
@resources = @resources.first.notices(:page => 2)
@resources = Airbox::Error.all(show_resolved: true)
Collections are paginated, with 30 objects per page. Airbox offers convenient ways to access other pages:
@p1 = @resources
@p2 = @p1.next_page
prest = @p2.next_pages
While collecting all pages can be done from any page, it's most efficient from the first:
p1all = @p1.all_pages
p2all = @p2.all_pages
p1all == p2all
You can access most related resources through simple object methods:
project = Airbox::Project.first
errors = project.errors #Will return all errors associated to the project
group = errors.first.group #Will return the group object associated to the first error
notices = group.notices #Will return the notices associated to the group object
Finally, some objects (looking at you, Error and Group::Notice) don't return with full information on collection calls. So sometimes, you need to request the full object:
project = Airbox::Project.first
errors = project.errors(show_resolved: true)
error = errors.first
error.request.url #Will error out, since the request object is not
available here
full_error = error.full_obj
full_error.request.url #Will return the URL for the requested error
Resources
Resources are defined by Airbrake's API. Collections are paginated, with 30 objects per page.
Valid resources are Project, Error, Group, and Group::Notice.
To Do
This gem is brand new, so there's still work to be done. The current list includes:
- Write test suite
- Move nested resources (e.g. Group::Notice) to use prefix options vs. hard-coded from
- Split resource types into their own files
- Look for and patch holes in functionality between Airbrake's reporting API and Airbox
- Remove ActiveRecord dependency
All contributions appreciated; just issue a pull request!
License
This gem is distributed as Beerware. Full text in the LICENSE file, but it's yours to do with as you wish (so long as you keep the LICENSE file around). If you like it, and we meet one day, consider buying me a drink.