activeerror 1.0.7 → 1.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7ec417a0e0ca10408c0ccfdba79721e4e92c9e4ba64dafc888f4913f8c972493
4
- data.tar.gz: b311b8891817daf40b3494c23ff957c2d161f7ce28a357f4a3f106fe83785b0b
3
+ metadata.gz: 7558b7d240e80821f7d6d8640b5ca6ef7ef5b34634f40e3482bfc99bf64107ea
4
+ data.tar.gz: e10bda1728e93ca0ecbd4051e406cbaeb17548599c6d98591b5b9083036cb371
5
5
  SHA512:
6
- metadata.gz: 782e60a069cc4b71af4fd09cf43b679f4520dcf589f1451d9fd33936ec00821fab333267ec2e45de39f533a948a6c28a267974e1984ce831a16d6a30861c53d3
7
- data.tar.gz: ac1a8ae7cafc8e838ead1441b8b92138bb2b0419ff895c373656568645e3e0656eceece8c9fcd6c0c76e37b6981850ce324bd03d325c60c1f843d74bc171fd52
6
+ metadata.gz: f50369819d20d1b2c36ab8b6572f02ffd33da5c2abac74f1ecd177dbb0283493d2b9d572c3265ba135e0ece593c55bd1374b361aed66dcc90d16b5122c0bc5fd
7
+ data.tar.gz: 76d577c8e82e6e95ef1cdc9c8e01c12789278ae1f21a4c5424a03a484985990251fc48b8ab520dd7f4e1139a5c66d1972d11ddd913aed98bd46e4a3954e8fb8b
data/README.md CHANGED
@@ -8,8 +8,9 @@ looking at using your data as training
8
8
  data([link](https://blog.sentry.io/ai-privacy-and-terms-of-service-updates/?original_referrer=https%3A%2F%2Fsentry.io%2F))
9
9
  there should be an easy open source alternative where you control the data.
10
10
 
11
- ActiveError hooks into the middleware of Rails.
12
- These third party error loggers also try to make their own fancy
11
+ ActiveError hooks into the [error reporting
12
+ api](https://guides.rubyonrails.org/error_reporting.html) baked directly into
13
+ Rails. These third party error loggers also try to make their own fancy
13
14
  backtrace and debugging view. But the one Rails developers are most comfortable
14
15
  with is the one baked into Rails that we use everyday in development. So with
15
16
  ActiveError, when an error gets raised it's captured and stored in the
@@ -4,7 +4,7 @@ class CreateActiveErrorInstances < ActiveRecord::Migration[7.1]
4
4
  def change
5
5
  create_table :active_error_instances do |t|
6
6
  t.belongs_to :fault
7
- t.string :url
7
+ t.text :url
8
8
  t.binary :headers, limit: 512.megabytes
9
9
  t.binary :parameters, limit: 512.megabytes
10
10
 
@@ -1,25 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveError
4
- class Engine < ::Rails::Engine
5
- ActiveJobRequest = Struct.new(:parameters, :filtered_parameters, :env, :url)
4
+ ActiveJobRequest = Struct.new(:parameters, :filtered_parameters, :env, :url)
6
5
 
6
+ class Engine < ::Rails::Engine
7
7
  isolate_namespace ActiveError
8
8
 
9
- initializer "active_error.middleware" do |app|
10
- unless Rails.env.local?
11
- app.config.middleware.use ActiveError::Middleware
9
+ initializer "active_error.middleware" do |_app|
10
+ ActionController::Base.before_action do
11
+ Rails.error.set_context(active_error_request: request)
12
+ end
12
13
 
13
- ::ActiveJob::Base.class_eval do |base|
14
- base.set_callback :perform, :around do |_param, block|
15
- block.call
16
- rescue StandardError => e
17
- ActiveError::Captor.new(exception: e, request: ActiveJobRequest.new(
18
- serialize, serialize
19
- )).capture
20
- raise e
21
- end
22
- end
14
+ ActiveJob::Base.before_perform do
15
+ Rails.error.set_context(active_error_request:
16
+ ActiveJobRequest.new(serialize, serialize))
23
17
  end
24
18
  end
25
19
  end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveError
4
+ class ErrorSubscriber
5
+ def report(exception, context:, **_opts)
6
+ return if Rails.env.local?
7
+
8
+ Captor.new(exception:, request: context[:active_error_request]).capture
9
+ end
10
+ end
11
+
12
+ class Railtie < ::Rails::Railtie
13
+ initializer "active_error.error_reporter" do |_app|
14
+ Rails.error.subscribe(::ActiveError::ErrorSubscriber.new)
15
+ end
16
+ end
17
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveError
4
- VERSION = "1.0.7"
4
+ VERSION = "1.0.8"
5
5
  end
data/lib/active_error.rb CHANGED
@@ -5,8 +5,8 @@ require "active_error/exception_mock/template_error"
5
5
  require "active_error/exception_mock"
6
6
  require "active_error/captor"
7
7
  require "active_error/renderer"
8
- require "active_error/middleware"
9
8
  require "active_error/engine"
9
+ require "active_error/railtie"
10
10
  require "active_error/version"
11
11
 
12
12
  module ActiveError
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeerror
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Pezza
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-10 00:00:00.000000000 Z
11
+ date: 2024-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -66,7 +66,7 @@ files:
66
66
  - lib/active_error/exception_mock.rb
67
67
  - lib/active_error/exception_mock/default.rb
68
68
  - lib/active_error/exception_mock/template_error.rb
69
- - lib/active_error/middleware.rb
69
+ - lib/active_error/railtie.rb
70
70
  - lib/active_error/renderer.rb
71
71
  - lib/active_error/version.rb
72
72
  - lib/activeerror.rb
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ActiveError
4
- class Middleware
5
- def initialize(app)
6
- @app = app
7
- end
8
-
9
- def call(env)
10
- @app.call(env)
11
- rescue Exception => exception # rubocop:disable Lint/RescueException, Naming/RescuedExceptionsVariableName
12
- Captor.new(exception:, request: ActionDispatch::Request.new(env)).capture
13
-
14
- raise
15
- end
16
- end
17
- end