• Stars
    star
    81
  • Rank 400,299 (Top 8 %)
  • Language
    Ruby
  • License
    MIT License
  • Created over 4 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Crash reporting engine to hunt down bugs 🐞

ExceptionHunter

CI Maintainability Test Coverage

Index screenshot

Exception Hunter is a Rails engine meant to track errors in your Rails project. It works by using your Postgres database to save errors with their corresponding metadata (like backtrace or environment data at the time of failure).

To do so we hook to various points of your application where we can rescue from errors, track and then re-raise those errors so they are handled normally. As such, the gem does not conflict with any other service so you can have your favorite error tracking service running in parallel with Exception Hunter while you decide which you like best.

Motivation

Error tracking is one of the most important tools a developer can have in their toolset. As such we think it'd be nice to provide a way for everyone to have it in their project, be it a personal project, and MVP or something else.

Docs

You can check the full documentation at https://rootstrap.github.io/exception_hunter.

Installation

Add Exception Hunter to your application's Gemfile:

gem 'exception_hunter', '~> 1.0'

You may also need to add Devise to your Gemfile if you haven't already done so and plan to use the gem's built in authentication:

gem 'devise'

After installing the dependencies you'll want to run:

$ rails generate exception_hunter:install

This will create an initializer and invoke Devise to create an AdminUser which will be used for authentication to access the dashboard. If you already have this user created (ActiveAdmin uses the same model) you can run the command with the --skip-users flag.

Additionally it should add the 'ExceptionHunter.routes(self)' line to your routes, which means you can go to /exception_hunter/errors in your browser and start enjoying some good old fashioned exception tracking!

Testing it on dev:

ExceptionHunter is disabled on dev by default so if you want to test it before shipping it to another environment, which we highly recommend, you should enable it by going to the initializer and changing the line that says config.enabled = !(Rails.env.development? || Rails.env.test?) with something like config.enabled = !(Rails.env.test?) while you test. Don't forget to change it back if you don't want a bunch of errors in your local DB!

You can then open a rails console and manually track an exception to check that it works ExceptionHunter.track(StandardError.new("It works!")). You should now see the exception on http://localhost:3000/exception_hunter.

Stale data

You can get rid of stale errors by running the rake task to purge them:

$ rake exception_hunter:purge_errors

We recommend you run this task once in a while to de-clutter your DB, using a recurring tasks once a week would be ideal. You can also purge errors by running ExceptionHunter::ErrorReaper.purge.

The time it takes for an error to go stale defaults to 45 days but it's configurable via the initializer.

Manual tracking

ExceptionHunter also includes a facility to manually log from anywhere in the code. Imagine the following case:

case current_user.status
when :inactive then do_something
when :active then do_something_else
when :banned then do_something_else_else
else
  ExceptionHunter.track(ArgumentError.new('This should never happen'), custom_data: { status: current_user.status }, user: current_user)
end

In this scenario we don't really want to raise an exception but we might want to be alerted if by any chance a user has an invalid status.

Slack notifications

You can configure ExceptionHunter to send a message to slack every time an error occurs. You have to do the following:

  1. Create a Slack app.
  2. Add it to your workspace.
  3. Add one or more webhooks linked to the channels you want to receive the notifications.
  4. Set the webhook urls in the exception_hunter initializer.
config.notifiers << {
  name: :slack,
  options: {
    webhook: 'SLACK_WEBHOOK_URL_1'
  }
}

config.notifiers << {
  name: :slack,
  options: {
    webhook: 'SLACK_WEBHOOK_URL_2'
  }
}
  1. Add the code below to the environment config file where you are using ExceptionHunter with the correct server url.
ExceptionHunter::Engine.configure do |config|
  config.routes.default_url_options = { host: "your_server_url" }
end

This uses ActiveJob to send notification in the background, so make sure you configure it with the adapter you are using, if not notifications will be sent synchronously.

Async Logging

You can configure ExceptionHunter to log async when an error occurs. You have to do the following:

config.async_logging = true;

This uses ActiveJob to log the error in the background, so make sure you configure it with the adapter you are using, if not the error will be logged synchronously.

Note: Errors from jobs will still be logged synchronously to not queue a job from a job (which sound like a bad idea)

License

The gem is available as open source under the terms of the MIT License.

Credits

Exception Hunter is maintained by Rootstrap with the help of our contributors.

More Repositories

1

yaaf

Easing the form object pattern in Rails applications
Ruby
352
star
2

rails_api_base

API boilerplate project for Ruby on Rails 7
Ruby
346
star
3

ios-base

Boilerplate for new iOS projects using Swift 5. Provides a handful of functionalities.
Swift
263
star
4

active-storage-base64

Base64 support for ActiveStorage
Ruby
148
star
5

htmx-rails

The easiest way to work with HTMX in your Rails app
Ruby
112
star
6

node-ts-api-base

REST API boilerplate made with Express + NodeJS
TypeScript
106
star
7

rails-modular-monolith-with-ddd

Full Modular Monolith Rails application with Domain-Driven Design approach. Inspired by https://github.com/kgrzybek/modular-monolith-with-ddd
96
star
8

activeadmin-chat

ActiveAdmin chat plugin
Ruby
89
star
9

apple_auth

Complete Ruby gem for Sign in with Apple. Actively maintained by rootstrap.com
Ruby
88
star
10

swift-ui-base

SwiftUI base is a boilerplate project created by Rootstrap for new projects using SwiftUI. The main objective is helping any new projects jump start into feature development by providing a handful of functionalities.
Swift
86
star
11

RSFormView

A Cocoapods library designed to easily create forms with multiple data entry fields
Swift
86
star
12

rails_hotwire_base

Rails + Hotwire base app
Ruby
76
star
13

PagedLists

Paginated UITableView and UICollectionViews for iOS.
Swift
71
star
14

react-native-use-styles

A classy approach to manage your react native styles.
JavaScript
65
star
15

tech-guides

Guidelines that document processes and standards followed by our entire organization
64
star
16

react-native-base

React Native-Redux Boilerplate
TypeScript
53
star
17

django-drip-campaigns

💧 Use Django admin to manage drip campaign emails using querysets on Django's User model.
Python
51
star
18

arqo

Easing the query object pattern in Rails applications
Ruby
50
star
19

i18n_linter

Rails i18n Linter Gem
Ruby
44
star
20

NeatTipView

A swift library to easily create and present tips for you user in your iOS app
Swift
43
star
21

ai-job-title-area-classification

Classification of job titles into categories, using different ML techniques
Python
43
star
22

react-native-use-animate

Animations in React native made simple
JavaScript
41
star
23

android-base

Rootstrap Android Base project
Kotlin
39
star
24

validate

An extension to the popular library validate.js that adds some useful custom validations out of the box. Also, a hub for all custom validations, that we have created, so you can easily add them to your own project.
JavaScript
31
star
25

mobx-session

mobx react session managment using localforage
JavaScript
29
star
26

active_outbox

A Transactional Outbox implementation for Rails and ActiveRecord
Ruby
27
star
27

RSFontSizes

RSFontSizes pod repository. Allows you to customize fonts and sizes in different screen sizes.
Swift
27
star
28

ai-job-title-level-classification

Python
24
star
29

rsgem

Rootstrap way ® to generate gems
Ruby
24
star
30

best_buy_ruby

Ruby library for the BestBuy API. https://www.bestbuy.com
Ruby
22
star
31

pull_requests_to_slack

Send Github pull request notifications to Slack
Ruby
21
star
32

SwiftGradients

Useful extensions for UIViews and CALayer classes to add beautiful color gradients.
Swift
18
star
33

redux-tools

Redux tools to speed up development.
JavaScript
16
star
34

airflow-examples

Python
14
star
35

chat-gpt-nodejs

NodeJS REST-API to interact with OpenAI
TypeScript
14
star
36

dolphin-nft-marketplace-frontend

TypeScript
12
star
37

swift-lib-builder

Builder for Cocoapod, Carthage and Swift Package manager libraries in Swift.
Swift
11
star
38

FlowForms

Reactive and declarative Form management library for Kotlin projects
Kotlin
9
star
39

rs-code-review-metrics

Ruby
9
star
40

slack-gpt-base-bot-node

JavaScript
8
star
41

rails_hotwire_playground

Ruby
7
star
42

compress-s3-tinypng

Losslessly compresses and Optimizes PNG and JPG files. Uses TinyPNG API.
Python
6
star
43

gemini-nodejs

NodeJS REST-API to interact with Google Gemini
TypeScript
6
star
44

activeadmin-async_exporter

Async exporter for Active Admin using ActiveJob
Ruby
5
star
45

livy-base

Apache Livy is a service that enables easy interaction with a Spark cluster over a REST interface
Shell
5
star
46

rails_base

Configurable Rails backend generator
Ruby
5
star
47

flutter-base

Dart
5
star
48

web-a11y-demos

JavaScript
5
star
49

apple-sign-in-rails

App for testing apple sign in gem
Ruby
5
star
50

MRI-classifier

Jupyter Notebook
5
star
51

ctakes

cTAKES - instructions and example
Dockerfile
5
star
52

rs-gpt-review

TypeScript
5
star
53

blog

Repository for submitting and reviewing posts for Rootstrap blog
4
star
54

UnicodeEmoji

iOS Library that loads official Unicode Emoji repositories and make them accessible to your app.
Swift
3
star
55

ml-training

Machine Learning tutorials and examples
Jupyter Notebook
3
star
56

swift-unity-integration

Integration of Unity build into an iOS(Swift) project.
C#
3
star
57

biobert-test

Python
3
star
58

hotwire-workshop

Ruby
3
star
59

rubocop-rootstrap

To provide default configuration files for Rubocop and the ability to create custom cops
Ruby
3
star
60

node-ts-api-base-legacy

Base Project for NodeJs + TypeScript Backends
TypeScript
3
star
61

fastai-waste-classifier

Jupyter Notebook
3
star
62

htmx-rails_examples

Ruby
2
star
63

phoenix-target-api

Elixir
2
star
64

nest-target-api

Proof of concept of a nest api project. Trello: https://trello.com/b/4ZrvgNnq/nest-target-api
TypeScript
2
star
65

react-native-peeking-header

React native header that hides when scrolling down and shows when scrolling up.
JavaScript
2
star
66

react-ts-base

react-ts-base
TypeScript
2
star
67

create-rootstrap-react-native-app

TypeScript
2
star
68

yaaf-examples

Rails app with YAAF usage examples
Ruby
2
star
69

courier

A middleware gem for deep links that survive the install process
Ruby
2
star
70

typescript-workshop

2
star
71

django-base

Django boilerplate for rest-api backends
Python
2
star
72

rs-wordle

JavaScript
2
star
73

datasciene-ecommerce

A list of examples/experiments machine learning are provided
Jupyter Notebook
2
star
74

docker-workshop

Materials for internal Docker for Devs workshop
Shell
2
star
75

rails_base_extensions

Add features to your rails project in a simple way!
Ruby
2
star
76

android-base-compose

Kotlin
2
star
77

gangogh

Python
1
star
78

ios-bases-api

API for demo iOS projects.
Ruby
1
star
79

RSRoutingSwift

iOS Routing
Swift
1
star
80

medical-pipeline

Data pipeline for processing medical text records
Python
1
star
81

RSFormViewExample

A RSFormView example showcasing dark mode
Swift
1
star
82

blackmarket-remix-research

TypeScript
1
star
83

react-native-use-toast

React native hook for integrating an extensible/ultra-customizable toast 📬
1
star
84

vue-vs-react

Todo app example made in vuejs and in react
Vue
1
star
85

django-feature-flip

Minimal Django app for feature flipping
Python
1
star
86

coronavirus-analysis

HTML
1
star
87

RSSwiftNetworking

A Swift framework that provides a network communication layer API
Swift
1
star
88

sprinkler-iot

Elixir
1
star
89

rails_admin_s3_file

A rails admin plugin to direct upload assets to s3.
HTML
1
star
90

spinner-playground

Swift
1
star
91

neuro-backyardbrains

train a ML model using data from backyard brains device
Jupyter Notebook
1
star
92

openform-rbac-api

Ruby
1
star
93

rootstrap-ui

Rootstrap's UI Components & Styles
CSS
1
star
94

mmhuman3d-docker

Docker for mmhuman3d - open-mmlab exposing streamlit app
Python
1
star
95

cra-template-base

A template created to generate a new CRA based code base for React projects.
JavaScript
1
star