5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-14 23:11:42 +00:00

mejorar notificación de errores

This commit is contained in:
f 2021-03-19 19:41:03 -03:00
parent a25ddb004a
commit 5977aa37af
6 changed files with 36 additions and 6 deletions

View file

@ -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

View file

@ -0,0 +1,3 @@
```
<%= raw @backtrace.join("\n") %>
```

View 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 %>

View 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, "") %>
```

View file

@ -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')}"

View file

@ -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
]