exception_hunter 0.1.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +56 -11
  3. data/app/assets/stylesheets/exception_hunter/base.css +62 -8
  4. data/app/assets/stylesheets/exception_hunter/errors.css +166 -24
  5. data/app/assets/stylesheets/exception_hunter/navigation.css +20 -5
  6. data/app/assets/stylesheets/exception_hunter/sessions.css +71 -0
  7. data/app/controllers/concerns/exception_hunter/authorization.rb +23 -0
  8. data/app/controllers/exception_hunter/application_controller.rb +2 -0
  9. data/app/controllers/exception_hunter/errors_controller.rb +27 -4
  10. data/app/controllers/exception_hunter/resolved_errors_controller.rb +11 -0
  11. data/app/helpers/exception_hunter/errors_helper.rb +7 -0
  12. data/app/helpers/exception_hunter/sessions_helper.rb +16 -0
  13. data/app/models/exception_hunter/application_record.rb +8 -0
  14. data/app/models/exception_hunter/error.rb +20 -7
  15. data/app/models/exception_hunter/error_group.rb +23 -4
  16. data/app/presenters/exception_hunter/dashboard_presenter.rb +54 -0
  17. data/app/presenters/exception_hunter/error_group_presenter.rb +25 -0
  18. data/app/presenters/exception_hunter/error_presenter.rb +9 -0
  19. data/app/views/exception_hunter/devise/sessions/new.html.erb +24 -0
  20. data/app/views/exception_hunter/errors/_error_row.erb +44 -0
  21. data/app/views/exception_hunter/errors/_error_summary.erb +23 -10
  22. data/app/views/exception_hunter/errors/_error_user_data.erb +4 -5
  23. data/app/views/exception_hunter/errors/_errors_table.erb +1 -0
  24. data/app/views/exception_hunter/errors/_last_7_days_errors_table.erb +12 -0
  25. data/app/views/exception_hunter/errors/index.html.erb +71 -30
  26. data/app/views/exception_hunter/errors/pagy/_pagy_nav.html.erb +15 -15
  27. data/app/views/exception_hunter/errors/show.html.erb +58 -22
  28. data/app/views/layouts/exception_hunter/application.html.erb +65 -6
  29. data/app/views/layouts/exception_hunter/exception_hunter_logged_out.html.erb +24 -0
  30. data/config/rails_best_practices.yml +2 -3
  31. data/config/routes.rb +19 -1
  32. data/lib/exception_hunter.rb +12 -2
  33. data/lib/exception_hunter/config.rb +8 -1
  34. data/lib/exception_hunter/devise.rb +17 -0
  35. data/lib/exception_hunter/engine.rb +5 -0
  36. data/{app/services → lib}/exception_hunter/error_creator.rb +15 -3
  37. data/lib/exception_hunter/error_reaper.rb +12 -0
  38. data/lib/exception_hunter/middleware/delayed_job_hunter.rb +69 -0
  39. data/lib/exception_hunter/middleware/request_hunter.rb +71 -0
  40. data/lib/exception_hunter/middleware/sidekiq_hunter.rb +59 -0
  41. data/lib/exception_hunter/tracking.rb +16 -0
  42. data/lib/exception_hunter/user_attributes_collector.rb +4 -0
  43. data/lib/exception_hunter/version.rb +1 -1
  44. data/lib/generators/exception_hunter/create_users/create_users_generator.rb +8 -1
  45. data/lib/generators/exception_hunter/install/install_generator.rb +3 -1
  46. data/lib/generators/exception_hunter/install/templates/create_exception_hunter_error_groups.rb.erb +3 -0
  47. data/lib/generators/exception_hunter/install/templates/exception_hunter.rb.erb +23 -0
  48. data/lib/tasks/exception_hunter_tasks.rake +6 -4
  49. metadata +25 -10
  50. data/config/initializers/exception_hunter.rb +0 -16
  51. data/lib/exception_hunter/railtie.rb +0 -11
  52. data/lib/exception_hunter/request_hunter.rb +0 -41
@@ -1,4 +1,6 @@
1
- # desc "Explaining what the task does"
2
- # task :exception_hunter do
3
- # # Task goes here
4
- # end
1
+ namespace :exception_hunter do
2
+ desc 'Purges old errors'
3
+ task purge_errors: [:environment] do
4
+ ::ExceptionHunter::ErrorReaper.call
5
+ end
6
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exception_hunter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bruno Vezoli
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-05-16 00:00:00.000000000 Z
12
+ date: 2020-08-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pagy
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '3.8'
20
+ version: '3'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: '3.8'
27
+ version: '3'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: brakeman
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -115,14 +115,14 @@ dependencies:
115
115
  requirements:
116
116
  - - "~>"
117
117
  - !ruby/object:Gem::Version
118
- version: 0.18.5
118
+ version: 0.17.1
119
119
  type: :development
120
120
  prerelease: false
121
121
  version_requirements: !ruby/object:Gem::Requirement
122
122
  requirements:
123
123
  - - "~>"
124
124
  - !ruby/object:Gem::Version
125
- version: 0.18.5
125
+ version: 0.17.1
126
126
  description:
127
127
  email:
128
128
  - bruno.vezoli@rootstrap.com
@@ -139,31 +139,46 @@ files:
139
139
  - app/assets/stylesheets/exception_hunter/base.css
140
140
  - app/assets/stylesheets/exception_hunter/errors.css
141
141
  - app/assets/stylesheets/exception_hunter/navigation.css
142
+ - app/assets/stylesheets/exception_hunter/sessions.css
143
+ - app/controllers/concerns/exception_hunter/authorization.rb
142
144
  - app/controllers/exception_hunter/application_controller.rb
143
145
  - app/controllers/exception_hunter/errors_controller.rb
146
+ - app/controllers/exception_hunter/resolved_errors_controller.rb
144
147
  - app/helpers/exception_hunter/application_helper.rb
148
+ - app/helpers/exception_hunter/errors_helper.rb
149
+ - app/helpers/exception_hunter/sessions_helper.rb
145
150
  - app/jobs/exception_hunter/application_job.rb
146
151
  - app/mailers/exception_hunter/application_mailer.rb
147
152
  - app/models/exception_hunter/application_record.rb
148
153
  - app/models/exception_hunter/error.rb
149
154
  - app/models/exception_hunter/error_group.rb
155
+ - app/presenters/exception_hunter/dashboard_presenter.rb
156
+ - app/presenters/exception_hunter/error_group_presenter.rb
150
157
  - app/presenters/exception_hunter/error_presenter.rb
151
- - app/services/exception_hunter/error_creator.rb
158
+ - app/views/exception_hunter/devise/sessions/new.html.erb
152
159
  - app/views/exception_hunter/errors/_error_backtrace.erb
160
+ - app/views/exception_hunter/errors/_error_row.erb
153
161
  - app/views/exception_hunter/errors/_error_summary.erb
154
162
  - app/views/exception_hunter/errors/_error_user_data.erb
163
+ - app/views/exception_hunter/errors/_errors_table.erb
164
+ - app/views/exception_hunter/errors/_last_7_days_errors_table.erb
155
165
  - app/views/exception_hunter/errors/index.html.erb
156
166
  - app/views/exception_hunter/errors/pagy/_pagy_nav.html.erb
157
167
  - app/views/exception_hunter/errors/show.html.erb
158
168
  - app/views/layouts/exception_hunter/application.html.erb
159
- - config/initializers/exception_hunter.rb
169
+ - app/views/layouts/exception_hunter/exception_hunter_logged_out.html.erb
160
170
  - config/rails_best_practices.yml
161
171
  - config/routes.rb
162
172
  - lib/exception_hunter.rb
163
173
  - lib/exception_hunter/config.rb
174
+ - lib/exception_hunter/devise.rb
164
175
  - lib/exception_hunter/engine.rb
165
- - lib/exception_hunter/railtie.rb
166
- - lib/exception_hunter/request_hunter.rb
176
+ - lib/exception_hunter/error_creator.rb
177
+ - lib/exception_hunter/error_reaper.rb
178
+ - lib/exception_hunter/middleware/delayed_job_hunter.rb
179
+ - lib/exception_hunter/middleware/request_hunter.rb
180
+ - lib/exception_hunter/middleware/sidekiq_hunter.rb
181
+ - lib/exception_hunter/tracking.rb
167
182
  - lib/exception_hunter/user_attributes_collector.rb
168
183
  - lib/exception_hunter/version.rb
169
184
  - lib/generators/exception_hunter/create_users/create_users_generator.rb
@@ -1,16 +0,0 @@
1
- ExceptionHunter.setup do |config|
2
- # == Current User
3
- #
4
- # Exception Hunter will include the user as part of the environment
5
- # data, if it was to be available. The default configuration uses devise
6
- # :current_user method. You can change it in case
7
- #
8
- config.current_user_method = :current_user
9
-
10
- # == Current User Attributes
11
- #
12
- # Exception Hunter will try to include the attributes defined here
13
- # as part of the user information that is kept from the request.
14
- #
15
- config.user_attributes = [:id, :email]
16
- end
@@ -1,11 +0,0 @@
1
- require_dependency 'exception_hunter/request_hunter'
2
-
3
- module ExceptionHunter
4
- class Railtie < Rails::Railtie
5
- initializer 'exception_hunter.add_middleware', after: :load_config_initializers do |app|
6
- app.config.middleware.insert_after(
7
- ActionDispatch::DebugExceptions, ExceptionHunter::RequestHunter
8
- )
9
- end
10
- end
11
- end
@@ -1,41 +0,0 @@
1
- module ExceptionHunter
2
- class RequestHunter
3
- ENVIRONMENT_KEYS =
4
- %w[PATH_INFO QUERY_STRING REMOTE_HOST REQUEST_METHOD REQUEST_URI
5
- SERVER_PROTOCOL HTTP_HOST HTTP_USER_AGENT].freeze
6
-
7
- def initialize(app)
8
- @app = app
9
- end
10
-
11
- def call(env)
12
- @app.call(env)
13
- rescue Exception => exception
14
- catch_prey(env, exception)
15
- raise exception
16
- end
17
-
18
- private
19
-
20
- def catch_prey(env, exception)
21
- user = user_from_env(env)
22
- ErrorCreator.call(
23
- class_name: exception.class.to_s,
24
- message: exception.message,
25
- environment_data: environment_data(env),
26
- backtrace: exception.backtrace,
27
- user: user
28
- )
29
- end
30
-
31
- def environment_data(env)
32
- env.select { |key, _value| ENVIRONMENT_KEYS.include?(key) }
33
- end
34
-
35
- def user_from_env(env)
36
- current_user_method = Config.current_user_method
37
- controller = env['action_controller.instance']
38
- controller.try(current_user_method)
39
- end
40
- end
41
- end