mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-26 00:06:21 +00:00
mejorar notificación de errores
This commit is contained in:
parent
a25ddb004a
commit
5977aa37af
6 changed files with 36 additions and 6 deletions
|
@ -2,6 +2,8 @@
|
|||
|
||||
# Procesa los errores de JavaScript
|
||||
class BacktraceJob < ApplicationJob
|
||||
class BacktraceException < RuntimeError; end
|
||||
|
||||
queue_as :low_priority
|
||||
|
||||
attr_reader :params, :site_id
|
||||
|
@ -26,9 +28,9 @@ class BacktraceJob < ApplicationJob
|
|||
end
|
||||
|
||||
begin
|
||||
raise NoMethodError
|
||||
rescue NoMethodError => e
|
||||
ExceptionNotifier.notify_exception(e, data: { site: site.name, params: params })
|
||||
raise BacktraceException, params['errors']&.first&.dig('message')
|
||||
rescue BacktraceException => e
|
||||
ExceptionNotifier.notify_exception(e, data: { site: site.name, params: params, backtrace: true })
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -40,7 +42,13 @@ class BacktraceJob < ApplicationJob
|
|||
|
||||
# Obtiene todos los archivos del backtrace
|
||||
def files
|
||||
@files ||= params['errors'].map { |x| x['backtrace'] }.flatten.map { |x| x['file'].split('@').last }.uniq.select { |x| x&.start_with?(site.url) }
|
||||
@files ||= params['errors'].map do |x|
|
||||
x['backtrace']
|
||||
end.flatten.map do |x|
|
||||
x['file'].split('@').last
|
||||
end.uniq.select do |x|
|
||||
x&.start_with?(site.url)
|
||||
end
|
||||
end
|
||||
|
||||
# Asume que todos los sourcemaps comparten la misma URL, lo
|
||||
|
|
3
app/views/exception_notifier/_backtrace.text.erb
Normal file
3
app/views/exception_notifier/_backtrace.text.erb
Normal file
|
@ -0,0 +1,3 @@
|
|||
```
|
||||
<%= raw @backtrace.join("\n") %>
|
||||
```
|
12
app/views/exception_notifier/_data.text.erb
Normal file
12
app/views/exception_notifier/_data.text.erb
Normal file
|
@ -0,0 +1,12 @@
|
|||
<% if @data['backtrace'] %>
|
||||
<% @data['errors'].each do |error| %>
|
||||
# <%= error['type'] %>: <%= error['message'] %>
|
||||
|
||||
<%= Terminal::Table.new headings: error['backtrace'].first.keys, rows: error['backtrace'].map(&:values) %>
|
||||
|
||||
<% end %>
|
||||
<% else %>
|
||||
```ruby
|
||||
<%= raw PP.pp(@data, "") %>
|
||||
```
|
||||
<% end %>
|
6
app/views/exception_notifier/_session.text.erb
Normal file
6
app/views/exception_notifier/_session.text.erb
Normal file
|
@ -0,0 +1,6 @@
|
|||
* session id: <%= @request.ssl? ? "[FILTERED]" : (raw (@request.session['session_id'] || (@request.env["rack.session.options"] and @request.env["rack.session.options"][:id])).inspect.html_safe) %>
|
||||
* data:
|
||||
|
||||
```ruby
|
||||
<%= raw PP.pp(@request.session.to_hash, "") %>
|
||||
```
|
|
@ -151,7 +151,8 @@ Rails.application.configure do
|
|||
email: {
|
||||
email_prefix: '[ERROR] ',
|
||||
sender_address: ENV['DEFAULT_FROM'],
|
||||
exception_recipients: ENV['EXCEPTION_TO']
|
||||
exception_recipients: ENV['EXCEPTION_TO'],
|
||||
normalize_subject: true
|
||||
}
|
||||
|
||||
Rails.application.routes.default_url_options[:host] = "panel.#{ENV.fetch('SUTTY', 'sutty.nl')}"
|
||||
|
|
|
@ -4,5 +4,5 @@
|
|||
|
||||
# Configure sensitive parameters which will be filtered from the log file.
|
||||
Rails.application.config.filter_parameters += %i[
|
||||
password passw secret token _key crypt salt certificate otp ssn
|
||||
password passw secret token _key crypt salt certificate otp ssn key
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue