dead_bro 0.2.16 → 0.2.17

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: 0bfea7b6292743b5e6a0f7226c1bd8877ebfbe1131f95d5c1679f07377768ed2
4
- data.tar.gz: '08ab07422afbd9d2d340e5195f47ceda9a184faa9a870e5464d6169dfc86ee6b'
3
+ metadata.gz: 0e9e839180ccf5281f99f831a4d437bdadd74a835c7e8f80fe321efb8bb1c9f7
4
+ data.tar.gz: c85de05b244a13bac3a2786624bd67f2f18d3b08c3ab3bcaa511857f8c276b90
5
5
  SHA512:
6
- metadata.gz: 76822c848e35d76f6cb54d7953e9ad7bb68de09b706be6f7586c4c67a3e430074fcd33515394965aeeb1d41c74577295ce56942badb05d96fd390e1daefeb410
7
- data.tar.gz: 2cd76061aa3f443723dfc3e934b1cd36e7e7576257f6637a4a1deab4e05c3154d309c9d4b59d084b46e89521774e47475a84fdc711db42d03b1dab496682d532
6
+ metadata.gz: 87c69d57f3c712fc993663e4f8df46ad49ec584f0ccdd3f5f1a6c5eededbc8a9542f2b0d4cee446fb049288c5d7f086528fa91f1467aa778dea4cfd4b09302e4
7
+ data.tar.gz: 1aed3c8185b4b1f14b7707c97c9d38baa5cb19da9c268d7f6ae11024563e4f9452048a61fdbe616a6adadb4847559f1459a0c5b695306a31a0d579a66e2b5825
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.17] - 2026-05-25
4
+
5
+ ### Added
6
+ - `DeadBro.track(error, **context)`: manually report a rescued exception to the DeadBro backend from any `rescue` block. Accepts any `Exception` subclass and optional keyword arguments forwarded as a `:context` hash in the payload. The report includes exception class, message, a 50-frame backtrace, `occurred_at` timestamp, environment, and any captured log lines from the current request. Never raises — APM reporting will not interfere with your application code.
7
+
3
8
  ## [0.2.16] - 2026-05-24
4
9
 
5
10
  ### Added
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DeadBro
4
- VERSION = "0.2.16"
4
+ VERSION = "0.2.17"
5
5
  end
data/lib/dead_bro.rb CHANGED
@@ -137,6 +137,61 @@ module DeadBro
137
137
  @monitor = monitor
138
138
  end
139
139
 
140
+ # Manually report a rescued exception to the DeadBro backend.
141
+ #
142
+ # Call this from any rescue block to track an error even when your app
143
+ # handles it gracefully and doesn't re-raise.
144
+ #
145
+ # Usage:
146
+ # begin
147
+ # charge_card(user)
148
+ # rescue Stripe::CardError => e
149
+ # DeadBro.track(e, user_id: current_user.id, plan: "pro")
150
+ # render json: { error: "Card declined" }, status: 422
151
+ # end
152
+ #
153
+ # Any keyword arguments are forwarded as a :context hash in the payload.
154
+ def self.track(error, **context)
155
+ return unless error.is_a?(Exception)
156
+
157
+ begin
158
+ exception_class = error.class.name.to_s
159
+ event_name = exception_class.empty? ? "exception.tracked" : exception_class
160
+
161
+ payload = {
162
+ exception_class: exception_class,
163
+ message: error.message.to_s[0, 1000],
164
+ backtrace: Array(error.backtrace).first(50),
165
+ occurred_at: Process.clock_gettime(Process::CLOCK_REALTIME).to_i, # report time, not raise time
166
+ tracked: true,
167
+ rails_env: env,
168
+ app: begin
169
+ if defined?(Rails) && Rails.respond_to?(:application)
170
+ Rails.application.class.module_parent_name
171
+ else
172
+ ""
173
+ end
174
+ rescue StandardError
175
+ ""
176
+ end,
177
+ pid: Process.pid,
178
+ logs: begin
179
+ logger.logs
180
+ rescue StandardError
181
+ []
182
+ end
183
+ }
184
+
185
+ payload[:context] = context unless context.empty?
186
+
187
+ client.post_metric(event_name: event_name, payload: payload, force: true)
188
+ rescue StandardError => _e
189
+ # Never let APM reporting interfere with the host app
190
+ end
191
+
192
+ nil
193
+ end
194
+
140
195
  # Shared constant for tracking start time (used by all subscribers)
141
196
  TRACKING_START_TIME_KEY = :dead_bro_tracking_start_time
142
197
  MAX_TRACKING_DURATION_SECONDS = 3600 # 1 hour
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dead_bro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.16
4
+ version: 0.2.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emanuel Comsa