solid_errors 0.5.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +34 -1
- data/config/routes.rb +1 -1
- data/lib/generators/solid_errors/install/USAGE +1 -1
- data/lib/generators/solid_errors/install/install_generator.rb +15 -17
- data/lib/generators/solid_errors/install/templates/db/errors_schema.rb +27 -0
- data/lib/solid_errors/version.rb +1 -1
- metadata +4 -4
- data/lib/generators/solid_errors/install/templates/create_solid_errors_tables.rb.erb +0 -24
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: acc9e46b7ee94e391df6d5fa4b11fd0550dcef9eca0f1b2089ec8ea81d6dc47e
         | 
| 4 | 
            +
              data.tar.gz: 37fda129cbac297cb10da823a70188515f29f57f02160b2acf01fd010345698a
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 1f2cd0c74b2a38ac93abb353cc8083cb623b942cd117df06efaf246afc0e42e2cd40732692fb6e7510c2962fab5a3826d88c674c21d1c2582de8264a4ccbca82
         | 
| 7 | 
            +
              data.tar.gz: 1ecc1ebc03b277fa8840cdc3550ad0e64f566761a3ecdc5ad45a2daa39fde4b8922c528eec6fa3097fd15f098bfcbe7b372bc26197855e5507990d04e1729ce3
         | 
    
        data/README.md
    CHANGED
    
    | @@ -49,7 +49,40 @@ After installing the gem, run the installer: | |
| 49 49 | 
             
            $ rails generate solid_errors:install
         | 
| 50 50 | 
             
            ```
         | 
| 51 51 |  | 
| 52 | 
            -
            This will  | 
| 52 | 
            +
            This will create the `db/errors_schema.rb` file.
         | 
| 53 | 
            +
             | 
| 54 | 
            +
            You will then have to add the configuration for the errors database in `config/database.yml`. If you're using sqlite, it'll look something like this:
         | 
| 55 | 
            +
             | 
| 56 | 
            +
            ```yaml
         | 
| 57 | 
            +
            production:
         | 
| 58 | 
            +
              primary:
         | 
| 59 | 
            +
                <<: *default
         | 
| 60 | 
            +
                database: storage/production.sqlite3
         | 
| 61 | 
            +
              errors:
         | 
| 62 | 
            +
                <<: *default
         | 
| 63 | 
            +
                database: storage/production_errors.sqlite3
         | 
| 64 | 
            +
                migrations_paths: db/errors_migrate
         | 
| 65 | 
            +
            ```
         | 
| 66 | 
            +
             | 
| 67 | 
            +
            ...or if you're using MySQL/PostgreSQL/Trilogy:
         | 
| 68 | 
            +
             | 
| 69 | 
            +
            ```yaml
         | 
| 70 | 
            +
            production:
         | 
| 71 | 
            +
              primary: &primary_production
         | 
| 72 | 
            +
                <<: *default
         | 
| 73 | 
            +
                database: app_production
         | 
| 74 | 
            +
                username: app
         | 
| 75 | 
            +
                password: <%= ENV["APP_DATABASE_PASSWORD"] %>
         | 
| 76 | 
            +
              errors:
         | 
| 77 | 
            +
                <<: *primary_production
         | 
| 78 | 
            +
                database: app_production_errors
         | 
| 79 | 
            +
                migrations_paths: db/errors_migrate
         | 
| 80 | 
            +
            ```
         | 
| 81 | 
            +
             | 
| 82 | 
            +
            > [!NOTE]
         | 
| 83 | 
            +
            > Calling `bin/rails solid_errors:install` will automatically add `config.solid_errors.connects_to = { database: { writing: :errors } }` to `config/environments/production.rb`, so no additional configuration is needed there (although you must make sure that you use the `errors` name in `database.yml` for this to match!). But if you want to use Solid Errors in a different environment (like staging or even development), you'll have to manually add that `config.solid_errors.connects_to` line to the respective environment file. And, as always, make sure that the name you're using for the database in `config/database.yml` matches the name you use in `config.solid_errors.connects_to`.
         | 
| 84 | 
            +
             | 
| 85 | 
            +
            Then run `db:prepare` in production to ensure the database is created and the schema is loaded.
         | 
| 53 86 |  | 
| 54 87 | 
             
            Then mount the engine in your `config/routes.rb` file:
         | 
| 55 88 | 
             
            ```ruby
         | 
    
        data/config/routes.rb
    CHANGED
    
    
| @@ -1,32 +1,30 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 | 
            -
            require "rails/generators"
         | 
| 4 | 
            -
            require "rails/generators/active_record"
         | 
| 5 | 
            -
             | 
| 6 3 | 
             
            module SolidErrors
         | 
| 7 4 | 
             
              #
         | 
| 8 5 | 
             
              # Rails generator used for setting up SolidErrors in a Rails application.
         | 
| 9 6 | 
             
              # Run it with +bin/rails g solid_errors:install+ in your console.
         | 
| 10 7 | 
             
              #
         | 
| 11 8 | 
             
              class InstallGenerator < Rails::Generators::Base
         | 
| 12 | 
            -
                include ActiveRecord::Generators::Migration
         | 
| 13 | 
            -
             | 
| 14 9 | 
             
                source_root File.expand_path("templates", __dir__)
         | 
| 15 10 |  | 
| 16 | 
            -
                 | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
                # Generates monolithic migration file that contains all database changes.
         | 
| 20 | 
            -
                def create_migration_file
         | 
| 21 | 
            -
                  return if options[:skip_migrations]
         | 
| 22 | 
            -
             | 
| 23 | 
            -
                  migration_template "create_solid_errors_tables.rb.erb", File.join(db_migrate_path, "create_solid_errors_tables.rb")
         | 
| 11 | 
            +
                def add_solid_errors_db_schema
         | 
| 12 | 
            +
                  template "db/errors_schema.rb"
         | 
| 24 13 | 
             
                end
         | 
| 25 14 |  | 
| 26 | 
            -
                 | 
| 27 | 
            -
             | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 15 | 
            +
                def configure_solid_errors
         | 
| 16 | 
            +
                  insert_into_file Pathname(destination_root).join("config/environments/production.rb"), after: /^([ \t]*).*?(?=\nend)$/ do
         | 
| 17 | 
            +
                    [
         | 
| 18 | 
            +
                      "",
         | 
| 19 | 
            +
                      '\1# Configure Solid Errors',
         | 
| 20 | 
            +
                      '\1config.solid_errors.connects_to = { database: { writing: :errors } }',
         | 
| 21 | 
            +
                      '\1config.solid_errors.send_emails = true',
         | 
| 22 | 
            +
                      '\1config.solid_errors.email_from = ""',
         | 
| 23 | 
            +
                      '\1config.solid_errors.email_to = ""',
         | 
| 24 | 
            +
                      '\1config.solid_errors.username = Rails.application.credentials.dig(:solid_errors, :username)',
         | 
| 25 | 
            +
                      '\1config.solid_errors.password = Rails.application.credentials.dig(:solid_errors, :password)'
         | 
| 26 | 
            +
                    ].join("\n")
         | 
| 27 | 
            +
                  end
         | 
| 30 28 | 
             
                end
         | 
| 31 29 | 
             
              end
         | 
| 32 30 | 
             
            end
         | 
| @@ -0,0 +1,27 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            ActiveRecord::Schema[7.1].define(version: 1) do
         | 
| 4 | 
            +
              create_table "solid_errors", force: :cascade do |t|
         | 
| 5 | 
            +
                t.text "exception_class", null: false
         | 
| 6 | 
            +
                t.text "message", null: false
         | 
| 7 | 
            +
                t.text "severity", null: false
         | 
| 8 | 
            +
                t.text "source"
         | 
| 9 | 
            +
                t.datetime "resolved_at"
         | 
| 10 | 
            +
                t.string "fingerprint", limit: 64, null: false
         | 
| 11 | 
            +
                t.datetime "created_at", null: false
         | 
| 12 | 
            +
                t.datetime "updated_at", null: false
         | 
| 13 | 
            +
                t.index ["fingerprint"], name: "index_solid_errors_on_fingerprint", unique: true
         | 
| 14 | 
            +
                t.index ["resolved_at"], name: "index_solid_errors_on_resolved_at"
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
              create_table "solid_errors_occurrences", force: :cascade do |t|
         | 
| 18 | 
            +
                t.integer "error_id", null: false
         | 
| 19 | 
            +
                t.text "backtrace"
         | 
| 20 | 
            +
                t.json "context"
         | 
| 21 | 
            +
                t.datetime "created_at", null: false
         | 
| 22 | 
            +
                t.datetime "updated_at", null: false
         | 
| 23 | 
            +
                t.index ["error_id"], name: "index_solid_errors_occurrences_on_error_id"
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
              add_foreign_key "solid_errors_occurrences", "solid_errors", column: "error_id"
         | 
| 27 | 
            +
            end
         | 
    
        data/lib/solid_errors/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: solid_errors
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.6.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Stephen Margheim
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2024- | 
| 11 | 
            +
            date: 2024-09-18 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: actionmailer
         | 
| @@ -142,7 +142,7 @@ files: | |
| 142 142 | 
             
            - config/routes.rb
         | 
| 143 143 | 
             
            - lib/generators/solid_errors/install/USAGE
         | 
| 144 144 | 
             
            - lib/generators/solid_errors/install/install_generator.rb
         | 
| 145 | 
            -
            - lib/generators/solid_errors/install/templates/ | 
| 145 | 
            +
            - lib/generators/solid_errors/install/templates/db/errors_schema.rb
         | 
| 146 146 | 
             
            - lib/solid_errors.rb
         | 
| 147 147 | 
             
            - lib/solid_errors/engine.rb
         | 
| 148 148 | 
             
            - lib/solid_errors/sanitizer.rb
         | 
| @@ -169,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 169 169 | 
             
                - !ruby/object:Gem::Version
         | 
| 170 170 | 
             
                  version: '0'
         | 
| 171 171 | 
             
            requirements: []
         | 
| 172 | 
            -
            rubygems_version: 3.5. | 
| 172 | 
            +
            rubygems_version: 3.5.11
         | 
| 173 173 | 
             
            signing_key:
         | 
| 174 174 | 
             
            specification_version: 4
         | 
| 175 175 | 
             
            summary: Database-backed Rails error subscriber
         | 
| @@ -1,24 +0,0 @@ | |
| 1 | 
            -
            # frozen_string_literal: true
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            class CreateSolidErrorsTables < ActiveRecord::Migration<%= migration_version %>
         | 
| 4 | 
            -
              def change
         | 
| 5 | 
            -
                create_table :solid_errors do |t|
         | 
| 6 | 
            -
                  t.text :exception_class, null: false
         | 
| 7 | 
            -
                  t.text :message, null: false
         | 
| 8 | 
            -
                  t.text :severity, null: false
         | 
| 9 | 
            -
                  t.text :source
         | 
| 10 | 
            -
                  t.datetime :resolved_at, index: true
         | 
| 11 | 
            -
                  t.string :fingerprint, null: false, limit: 64, index: { unique: true }
         | 
| 12 | 
            -
             | 
| 13 | 
            -
                  t.timestamps
         | 
| 14 | 
            -
                end
         | 
| 15 | 
            -
             | 
| 16 | 
            -
                create_table :solid_errors_occurrences do |t|
         | 
| 17 | 
            -
                  t.belongs_to :error, null: false, foreign_key: { to_table: :solid_errors }
         | 
| 18 | 
            -
                  t.text :backtrace
         | 
| 19 | 
            -
                  t.json :context
         | 
| 20 | 
            -
             | 
| 21 | 
            -
                  t.timestamps
         | 
| 22 | 
            -
                end
         | 
| 23 | 
            -
              end
         | 
| 24 | 
            -
            end
         |