Class: BugReportsClient::ErrorEvent
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- BugReportsClient::ErrorEvent
- Defined in:
- app/models/bug_reports_client/error_event.rb
Overview
A captured 500 attributed to the signed-in user who hit it. Surfaced on the report form ("did your problem relate to this error?") so user bug reports can reference the automatically-filed error issue by fingerprint. Events are short-lived working data - old ones are pruned on write.
Constant Summary collapse
- RETENTION =
seconds; errors older than this are pruned
30 * 24 * 60 * 60
Class Method Summary collapse
-
.record!(user_id:, fingerprint:, exception_class:, message:, occurred_at:, activity: nil) ⇒ Object
Records an occurrence for a user and prunes their stale events.
Instance Method Summary collapse
-
#summary ⇒ Object
Technical one-liner for the GitHub issue markdown - never shown to end users.
-
#user_facing_description ⇒ Object
What the user sees on the report form: what they were doing, not the exception ("something went wrong while viewing invoices").
Class Method Details
.record!(user_id:, fingerprint:, exception_class:, message:, occurred_at:, activity: nil) ⇒ Object
Records an occurrence for a user and prunes their stale events.
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/models/bug_reports_client/error_event.rb', line 17 def self.record!(user_id:, fingerprint:, exception_class:, message:, occurred_at:, activity: nil) where(user_id: user_id).where(occurred_at: ...(Time.current - RETENTION)).delete_all create!( user_id: user_id, fingerprint: fingerprint, exception_class: exception_class, message: .to_s.truncate(200), activity: activity, occurred_at: occurred_at ) end |
Instance Method Details
#summary ⇒ Object
Technical one-liner for the GitHub issue markdown - never shown to end users.
32 33 34 |
# File 'app/models/bug_reports_client/error_event.rb', line 32 def summary "#{exception_class}: #{}".truncate(110) end |
#user_facing_description ⇒ Object
What the user sees on the report form: what they were doing, not the exception ("something went wrong while viewing invoices").
38 39 40 41 42 43 44 |
# File 'app/models/bug_reports_client/error_event.rb', line 38 def user_facing_description if activity.present? I18n.t("bug_reports_client.form.related_error.option_with_activity", activity: activity) else I18n.t("bug_reports_client.form.related_error.option_generic") end end |