snitch_reporting 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6a1aa5a3caefa942217670a6afbf15688875a996ec9e3b2991b843a6e415e08e
4
- data.tar.gz: 496da79e68c0c376b4a073c5830504c7822bd90d200218e0687db1b8397dc6dd
3
+ metadata.gz: 9f9dd6556f79b56caaf6baade6c7bd4b1cbb6536ac5b92b03186ee3551f4ffcf
4
+ data.tar.gz: d6447f72373880ef558c1f996532c3afe518e3777be1ac55a35ed22a02428b3b
5
5
  SHA512:
6
- metadata.gz: f0ccd94e6296060d68498c9c1694562eec6cd2a0b7e20773d35f5b91966e7ebda607e9b170be918fd8528502caafcbe38084ebfd79440ea6363d6f02db3abbbc
7
- data.tar.gz: 8ca4544b0990ba43908da155a77acad9f735b69bba53298ef4d5ba97e3a95e2382d4bd74ab36f462f080ff7c760d7f99baa4001d8de177f54112db664e1484bc
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
- report = retrieve_or_create_existing_report(log_level, santize_title(report_title), env, base_exception, arg_hash)
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
- SnitchReporting::SnitchReport.fatal("Failed to create report. (#{ex.class})", env.inspect, ex.inspect)
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: (exception.try(:class) || sanitized_title.presence).to_s,
207
- message: sanitized_title.presence,
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)
@@ -1,3 +1,3 @@
1
1
  module SnitchReporting
2
- VERSION = '1.2.1'
2
+ VERSION = '1.2.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snitch_reporting
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rocco Nicholls