snitch_reporting 1.2.1 → 1.2.2
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f9dd6556f79b56caaf6baade6c7bd4b1cbb6536ac5b92b03186ee3551f4ffcf
|
4
|
+
data.tar.gz: d6447f72373880ef558c1f996532c3afe518e3777be1ac55a35ed22a02428b3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09bc2d5bd44d91588b2d79d8cb70fcbb0663f3530ed0c024832510abd668923c93a56c2c64abb59d17eba0681861fd11ac7fec67fda1cc106256f9fbc703d83b'
|
7
|
+
data.tar.gz: 7a4118612f92924279cc1f057cfe4e1018fe6bc414b1d196a91b891cca8c53a655a3b0a0b01ee1a26d2ffd44534af5751e0e51d8f48aa5c8bbc929a7fab92fec
|
@@ -7,6 +7,7 @@ class ::SnitchReporting::SnitchReportsController < ApplicationController
|
|
7
7
|
layout "application"
|
8
8
|
|
9
9
|
def index
|
10
|
+
::SnitchReporting::SnitchReport.warn("Error", some: :data)
|
10
11
|
@reports = ::SnitchReporting::SnitchReport.order("last_occurrence_at DESC NULLS LAST").page(params[:page]).per(params[:per] || 25)
|
11
12
|
|
12
13
|
# set_report_preferences
|
@@ -67,7 +67,8 @@ class SnitchReporting::SnitchReport < ApplicationRecord
|
|
67
67
|
always_notify = arg_hash.delete(:always_notify)
|
68
68
|
|
69
69
|
report_title = retrieve_report_title(base_exception, arg_hash, arg_values)
|
70
|
-
|
70
|
+
report_error = retrieve_error_string(base_exception, arg_hash, arg_values)
|
71
|
+
report = retrieve_or_create_existing_report(log_level, santize_title(report_title), santize_title(report_error), env, base_exception, arg_hash)
|
71
72
|
return SnitchReporting::SnitchReport.error("Failed to save report.", report.errors.full_messages) unless report.persisted?
|
72
73
|
|
73
74
|
report_data = gather_report_data(env, exceptions, arg_hash, arg_values)
|
@@ -86,7 +87,8 @@ class SnitchReporting::SnitchReport < ApplicationRecord
|
|
86
87
|
occurrence
|
87
88
|
rescue StandardError => ex
|
88
89
|
env ||= {}
|
89
|
-
|
90
|
+
binding.pry
|
91
|
+
SnitchReporting::SnitchReport.fatal("Failed to create report. (#{ex.class})", env.to_s, ex.to_s)
|
90
92
|
end
|
91
93
|
|
92
94
|
def format_args(args)
|
@@ -183,6 +185,15 @@ class SnitchReporting::SnitchReport < ApplicationRecord
|
|
183
185
|
report_title
|
184
186
|
end
|
185
187
|
|
188
|
+
def retrieve_error_string(exception, arg_hash, arg_values)
|
189
|
+
report_error ||= arg_values&.find { |arg_value| arg_value.is_a?(String) }
|
190
|
+
report_error ||= (arg_hash[:klass] || arg_hash[:class]).presence
|
191
|
+
report_error ||= arg_hash&.first.to_s.presence
|
192
|
+
report_error ||= trace_from_exception(exception).find { |row| row.include?("/app/") }
|
193
|
+
report_error ||= exception.try(:class).presence
|
194
|
+
report_error
|
195
|
+
end
|
196
|
+
|
186
197
|
def add_leftover_objects_to_report_data(report_data, exceptions, arg_hash, arg_values)
|
187
198
|
report_data[:exceptions] = exceptions.map { |ex| "#{ex.try(:class)}: #{ex.try(:message)}" } if exceptions.present?
|
188
199
|
report_data.merge!(arg_hash)
|
@@ -201,10 +212,10 @@ class SnitchReporting::SnitchReport < ApplicationRecord
|
|
201
212
|
report_title.to_s.gsub(regex_find_numbers_and_words_with_numbers, "").presence
|
202
213
|
end
|
203
214
|
|
204
|
-
def retrieve_or_create_existing_report(log_level, sanitized_title, env, exception, arg_hash)
|
215
|
+
def retrieve_or_create_existing_report(log_level, sanitized_title, sanitized_error_msg, env, exception, arg_hash)
|
205
216
|
report_identifiable_data = {
|
206
|
-
error:
|
207
|
-
message:
|
217
|
+
error: sanitized_title.presence,
|
218
|
+
message: sanitized_error_msg.presence,
|
208
219
|
log_level: log_level,
|
209
220
|
klass: env&.dig(:"action_controller.instance").try(:class).to_s.split("::").last&.gsub("Controller", ""),
|
210
221
|
action: env&.dig(:"action_controller.instance").try(:action_name)
|