exception_hunter 0.2.0 → 0.3.0

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.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +29 -6
  3. data/app/assets/stylesheets/exception_hunter/base.css +62 -8
  4. data/app/assets/stylesheets/exception_hunter/errors.css +163 -25
  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/sessions_helper.rb +16 -0
  12. data/app/models/exception_hunter/application_record.rb +8 -0
  13. data/app/models/exception_hunter/error.rb +20 -7
  14. data/app/models/exception_hunter/error_group.rb +23 -4
  15. data/app/presenters/exception_hunter/dashboard_presenter.rb +54 -0
  16. data/app/presenters/exception_hunter/error_group_presenter.rb +25 -0
  17. data/app/presenters/exception_hunter/error_presenter.rb +1 -0
  18. data/app/views/exception_hunter/devise/sessions/new.html.erb +24 -0
  19. data/app/views/exception_hunter/errors/_error_row.erb +44 -0
  20. data/app/views/exception_hunter/errors/_error_summary.erb +5 -5
  21. data/app/views/exception_hunter/errors/_errors_table.erb +1 -0
  22. data/app/views/exception_hunter/errors/_last_7_days_errors_table.erb +12 -0
  23. data/app/views/exception_hunter/errors/index.html.erb +71 -30
  24. data/app/views/exception_hunter/errors/pagy/_pagy_nav.html.erb +15 -15
  25. data/app/views/exception_hunter/errors/show.html.erb +58 -22
  26. data/app/views/layouts/exception_hunter/application.html.erb +65 -6
  27. data/app/views/layouts/exception_hunter/exception_hunter_logged_out.html.erb +24 -0
  28. data/config/rails_best_practices.yml +2 -2
  29. data/config/routes.rb +19 -1
  30. data/lib/exception_hunter.rb +11 -1
  31. data/lib/exception_hunter/config.rb +8 -1
  32. data/lib/exception_hunter/devise.rb +17 -0
  33. data/{app/services → lib}/exception_hunter/error_creator.rb +15 -3
  34. data/lib/exception_hunter/error_reaper.rb +12 -0
  35. data/lib/exception_hunter/middleware/request_hunter.rb +1 -0
  36. data/lib/exception_hunter/middleware/sidekiq_hunter.rb +1 -0
  37. data/lib/exception_hunter/tracking.rb +16 -0
  38. data/lib/exception_hunter/user_attributes_collector.rb +4 -0
  39. data/lib/exception_hunter/version.rb +1 -1
  40. data/lib/generators/exception_hunter/create_users/create_users_generator.rb +8 -1
  41. data/lib/generators/exception_hunter/install/install_generator.rb +3 -1
  42. data/lib/generators/exception_hunter/install/templates/create_exception_hunter_error_groups.rb.erb +3 -0
  43. data/lib/generators/exception_hunter/install/templates/exception_hunter.rb.erb +23 -0
  44. data/lib/tasks/exception_hunter_tasks.rake +6 -4
  45. metadata +18 -5
  46. data/config/initializers/exception_hunter.rb +0 -16
@@ -1,3 +1,3 @@
1
1
  module ExceptionHunter
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '0.3.0'.freeze
3
3
  end
@@ -22,7 +22,14 @@ module ExceptionHunter
22
22
  end
23
23
 
24
24
  def create_admin_user
25
- invoke 'devise', [name]
25
+ invoke 'devise', [name], routes: false
26
+ end
27
+
28
+ def remove_registerable_from_model
29
+ return if options[:registerable]
30
+
31
+ model_file = File.join(destination_root, 'app', 'models', "#{file_path}.rb")
32
+ gsub_file model_file, /\:registerable([.]*,)?/, ''
26
33
  end
27
34
  end
28
35
  end
@@ -15,7 +15,9 @@ module ExceptionHunter
15
15
 
16
16
  def setup_routes
17
17
  if options[:users]
18
- inject_into_file 'config/routes.rb', "\n ExceptionHunter.routes(self)", after: /devise_for .*/
18
+ gsub_file 'config/routes.rb',
19
+ "\n devise_for :#{plural_table_name}, skip: :all",
20
+ "\n ExceptionHunter.routes(self)"
19
21
  else
20
22
  route 'ExceptionHunter.routes(self)'
21
23
  end
@@ -5,10 +5,13 @@ class CreateExceptionHunterErrorGroups < ActiveRecord::Migration[<%= ActiveRecor
5
5
  create_table :exception_hunter_error_groups do |t|
6
6
  t.string :error_class_name, null: false
7
7
  t.string :message
8
+ t.integer :status, default: 0
9
+ t.text :tags, array: true, default: []
8
10
 
9
11
  t.timestamps
10
12
 
11
13
  t.index :message, opclass: :gin_trgm_ops, using: :gin
14
+ t.index :status
12
15
  end
13
16
  end
14
17
  end
@@ -1,4 +1,19 @@
1
1
  ExceptionHunter.setup do |config|
2
+ # == Enabling
3
+ #
4
+ # This flag allows disabling error tracking, it's set to track in
5
+ # any environment but development or test by default
6
+ #
7
+ config.enabled = !(Rails.env.development? || Rails.env.test?)
8
+
9
+ # == Dashboard User
10
+ # Exception Hunter allows you to restrict users who can see the dashboard
11
+ # to the ones included in the database. You can change the table name in
12
+ # case you are not satisfied with the default one. You can also remove the
13
+ # configuration if you wish to have no access restrictions for the dashboard.
14
+ #
15
+ <%= @use_authentication_method ? "config.admin_user_class = '#{name}'" : "# config.admin_user_class = '#{name}'" %>
16
+
2
17
  # == Current User
3
18
  #
4
19
  # Exception Hunter will include the user as part of the environment
@@ -15,4 +30,12 @@ ExceptionHunter.setup do |config|
15
30
  # as part of the user information that is kept from the request.
16
31
  #
17
32
  config.user_attributes = [:id, :email]
33
+
34
+ # == Stale errors
35
+ #
36
+ # You can configure how long it takes for errors to go stale. This is
37
+ # taken into account when purging old error messages but nothing will
38
+ # happen automatically.
39
+ #
40
+ # config.errors_stale_time = 45.days
18
41
  end
@@ -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.2.0
4
+ version: 0.3.0
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-18 00:00:00.000000000 Z
12
+ date: 2020-06-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pagy
@@ -139,32 +139,45 @@ 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
145
148
  - app/helpers/exception_hunter/errors_helper.rb
149
+ - app/helpers/exception_hunter/sessions_helper.rb
146
150
  - app/jobs/exception_hunter/application_job.rb
147
151
  - app/mailers/exception_hunter/application_mailer.rb
148
152
  - app/models/exception_hunter/application_record.rb
149
153
  - app/models/exception_hunter/error.rb
150
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
151
157
  - app/presenters/exception_hunter/error_presenter.rb
152
- - app/services/exception_hunter/error_creator.rb
158
+ - app/views/exception_hunter/devise/sessions/new.html.erb
153
159
  - app/views/exception_hunter/errors/_error_backtrace.erb
160
+ - app/views/exception_hunter/errors/_error_row.erb
154
161
  - app/views/exception_hunter/errors/_error_summary.erb
155
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
156
165
  - app/views/exception_hunter/errors/index.html.erb
157
166
  - app/views/exception_hunter/errors/pagy/_pagy_nav.html.erb
158
167
  - app/views/exception_hunter/errors/show.html.erb
159
168
  - app/views/layouts/exception_hunter/application.html.erb
160
- - config/initializers/exception_hunter.rb
169
+ - app/views/layouts/exception_hunter/exception_hunter_logged_out.html.erb
161
170
  - config/rails_best_practices.yml
162
171
  - config/routes.rb
163
172
  - lib/exception_hunter.rb
164
173
  - lib/exception_hunter/config.rb
174
+ - lib/exception_hunter/devise.rb
165
175
  - lib/exception_hunter/engine.rb
176
+ - lib/exception_hunter/error_creator.rb
177
+ - lib/exception_hunter/error_reaper.rb
166
178
  - lib/exception_hunter/middleware/request_hunter.rb
167
179
  - lib/exception_hunter/middleware/sidekiq_hunter.rb
180
+ - lib/exception_hunter/tracking.rb
168
181
  - lib/exception_hunter/user_attributes_collector.rb
169
182
  - lib/exception_hunter/version.rb
170
183
  - lib/generators/exception_hunter/create_users/create_users_generator.rb
@@ -194,7 +207,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
194
207
  - !ruby/object:Gem::Version
195
208
  version: '0'
196
209
  requirements: []
197
- rubygems_version: 3.0.8
210
+ rubygems_version: 3.1.2
198
211
  signing_key:
199
212
  specification_version: 4
200
213
  summary: Exception tracking engine
@@ -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