• Stars
    star
    174
  • Rank 211,653 (Top 5 %)
  • Language
    HTML
  • License
    MIT License
  • Created 4 months ago
  • Updated 2 months ago

Reviews

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

Repository Details

Solid Errors

GEM Version GEM Downloads Ruby Style Tests Sponsors Ruby.Social Follow Twitter Follow

Solid Errors is a DB-based, app-internal exception tracker for Rails applications, designed with simplicity and performance in mind. It uses the new Rails error reporting API to store uncaught exceptions in the database, and provides a simple UI for viewing and managing exceptions.

Installation

Install the gem and add to the application's Gemfile by executing:

$ bundle add solid_errors

If bundler is not being used to manage dependencies, install the gem by executing:

$ gem install solid_errors

After installing the gem, run the installer:

$ rails generate solid_errors:install

This will copy the required migration over to your app.

Then mount the engine in your config/routes.rb file:

authenticate :user, -> (user) { user.admin? } do
  mount SolidErrors::Engine, at: "/solid_errors"
end

Note

Be sure to secure the dashboard in production.

Usage

All exceptions are recorded automatically. No additional code required.

Please consult the official guides for an introduction to the error reporting API.

There are intentionally few features; you can view and resolve errors. That’s it. The goal is to provide a simple, lightweight, and performant solution for tracking exceptions in your Rails application. If you need more features, you should probably use a 3rd party service like Honeybadger, whose MIT-licensed Ruby agent gem provided a couple of critical pieces of code for this project.

Configuration

You can configure Solid Errors via the Rails configuration object, under the solid_errors key. Currently, 6 configuration options are available:

  • connects_to - The database configuration to use for the Solid Errors database. See Database Configuration for more information.
  • username - The username to use for HTTP authentication. See Authentication for more information.
  • password - The password to use for HTTP authentication. See Authentication for more information.
  • sends_email - Whether or not to send emails when an error occurs. See Email notifications for more information.
  • email_from - The email address to send a notification from. See Email notifications for more information.
  • email_to - The email address(es) to send a notification to. See Email notifications for more information.

Database Configuration

config.solid_errors.connects_to takes a custom database configuration hash that will be used in the abstract SolidErrors::Record Active Record model. This is required to use a different database than the main app. For example:

# Use a single separate DB for Solid Errors
config.solid_errors.connects_to = { database: { writing: :solid_errors, reading: :solid_errors } }

or

# Use a separate primary/replica pair for Solid Errors
config.solid_errors.connects_to = { database: { writing: :solid_errors_primary, reading: :solid_errors_replica } }

Authentication

Solid Errors does not restrict access out of the box. You must secure the dashboard yourself. However, it does provide basic HTTP authentication that can be used with basic authentication or Devise. All you need to do is setup a username and password.

There are two ways to setup a username and password. First, you can use the SOLIDERRORS_USERNAME and SOLIDERRORS_PASSWORD environment variables:

ENV["SOLIDERRORS_USERNAME"] = "frodo"
ENV["SOLIDERRORS_PASSWORD"] = "ikeptmysecrets"

Second, you can set the SolidErrors.username and SolidErrors.password variables in an initializer:

# Set authentication credentials for Solid Errors
config.solid_errors.username = Rails.application.credentials.solid_errors.username
config.solid_errors.password = Rails.application.credentials.solid_errors.password

Either way, if you have set a username and password, Solid Errors will use basic HTTP authentication. If you have not set a username and password, Solid Errors will not require any authentication to view the dashboard.

If you use Devise for authentication in your app, you can also restrict access to the dashboard by using their authenticate contraint in your routes file:

authenticate :user, -> (user) { user.admin? } do
  mount SolidErrors::Engine, at: "/solid_errors"
end

Email notifications

Solid Errors can send email notifications whenever an error occurs, if your application has ActionMailer already properly setup to send emails. However, in order to activate this feature you must define the email address(es) to send the notifications to. Optionally, you can also define the email address to send the notifications from (useful if your email provider only allows emails to be sent from a predefined list of addresses) or simply turn off this feature altogether.

There are two ways to configure email notifications. First, you can use environment variables:

ENV["SOLIDERRORS_SEND_EMAILS"] = true # defaults to true
ENV["SOLIDERRORS_EMAIL_FROM"] = "[email protected]" # defaults to "[email protected]"
ENV["SOLIDERRORS_EMAIL_TO"] = "[email protected]" # no default, must be set

Second, you can set the values via the configuration object:

# Set authentication credentials for Solid Errors
config.solid_errors.send_emails = true
config.solid_errors.email_from = "[email protected]"
config.solid_errors.email_to = "[email protected]"

If you have set send_emails to true and have set an email_to address, Solid Errors will send an email notification whenever an error occurs. If you have not set send_emails to true or have not set an email_to address, Solid Errors will not send any email notifications.

Examples

There are only two screens in the dashboard.

  • the index view of all unresolved errors:

image description

  • and the show view of a particular error:

image description

Usage with API-only Applications

If your Rails application is an API-only application (generated with the rails new --api command), you will need to add the following middleware to your config/application.rb file in order to use the dashboard UI provided by Solid Errors:

# /config/application.rb
config.middleware.use ActionDispatch::Cookies
config.middleware.use ActionDispatch::Session::CookieStore
config.middleware.use ActionDispatch::Flash

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/fractaledmind/solid_errors. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

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

Code of Conduct

Everyone interacting in the SolidErrors project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

More Repositories

1

acidic_job

Idempotent operations for Rails apps, built for ActiveJob or Sidekiq.
Ruby
387
star
2

hottable

A minimal Airtable clone built with Rails and HotWire
Ruby
95
star
3

alfred_zotquery

An Alfred workflow to interact with a user's Zotero data.
Python
53
star
4

activerecord-enhancedsqlite3-adapter

ActiveRecord adapter for SQLite that enhances the default. Back-ports generated column support, deferred foreign key support, custom foreign key support, improved default configuration, and adds support for pragma tuning and extension loading
Ruby
47
star
5

litestream-ruby

Ruby
41
star
6

alfred_libgen

Search and Dowload ebooks from Library Genesis through Alfred
Python
39
star
7

alfred_pandoctor

An Alfred GUI for Pandoc
Python
36
star
8

alfred_skimmer

PDF Actions for Skim App
Objective-C
33
star
9

turbolist

A basic clone of Superlist using Rails and Turbo 8
HTML
31
star
10

hackademic-bundle

A Collection of Applescripts for automating academic tasks
AppleScript
19
star
11

Classical-Studies-Resources

Structured data for classical studies
Python
18
star
12

metadata

Python library for filesearching using OS X metadata
Python
16
star
13

alfred_wikify

Wikify your Evernote with Alfred
Python
15
star
14

alfred_snippets

Simple, document-specific text snippets
Python
12
star
15

sasswind

A SASS port of the Tailwind CSS utility framework
CSS
10
star
16

alfred_bibquery

Search BibDesk from Alfred
Python
9
star
17

applescript_helpers

Handlers for AS user-interaction function
AppleScript
9
star
18

alfred_spritzr

an Alfred speed reader
Python
8
star
19

pandoc_docx_template

Reference .docx file for pandoc conversion
CSS
5
star
20

alfred_corpora

Alfred GUI for Classical Studies text corpora
Python
4
star
21

actionset

Wire-up ActiveSet collections with a Rails controller
Ruby
4
star
22

togglicons

Pure CSS animated icon set
CSS
3
star
23

sqlpkg-ruby

Ruby
3
star
24

solid_metrics

HTML
3
star
25

alfred_parsers

Greek and Latin parsers
Python
2
star
26

hackademic

A blog on hacking your education and tools
Makefile
2
star
27

noticed-sandbox

MVCE for noticed gem
Ruby
2
star
28

git-do

Pre-emptive commit messages for git
Shell
1
star
29

datasette

Ruby
1
star
30

hyperspeed

Create HTML in Ruby at hyperspeed.
Ruby
1
star
31

fractaled_mind

backend for personal blog
CSS
1
star
32

activeset

A toolkit for working with enumerable sets.
Ruby
1
star
33

alfred_send

Send documents to the cloud
Python
1
star
34

railsconf-2024

Ruby
1
star
35

tlgu

Command line utility to convert TLG Greek data into Unicode text files
C
1
star
36

funkstrap

Functional CSS for Bootstrap
CSS
1
star
37

rubyconftw

Ruby
1
star
38

sqlite.directory

Ruby
1
star