rails_discord_notifier 0.3.0 → 0.3.1

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: 6527e49521148326dc463e191ed0fe51097c0625e7a09b89074615eb6b21f431
4
- data.tar.gz: 3502ab8e704d8e0d995cdd17fb8d06fc36d9c6bae13122455cb33b013c9eff3c
3
+ metadata.gz: fbf5bc3adc89129d2ab69ef41705e363a214a53eb31dd1bd0dd2a4fb36253a8b
4
+ data.tar.gz: b35128c48b420cd7577a9a455f5d857ef952c08f0ef427136299a2e698e85101
5
5
  SHA512:
6
- metadata.gz: 2933ce5afd5ee5ae228d589c4c556fdde5dee1def8146a07204fc2230b80ccdbe89dbcbd055786af2389653518d8518e3de564d1dc3147851a8236a50f48ac5f
7
- data.tar.gz: 01a951280d579cac677a76e6e2120b9fb30b4c8c94fd584459423a0b4e1b7d65e8ab178584ef4e9b41178a216a3b010d2a0d34950d481e0ef341d28050609bc5
6
+ metadata.gz: 8187d0173472e8d83c8f4ce848b9d7fa9feb218db585853bbed1e784cd820f81fe93086f34c23c4b35800a4cefbe3997022d67b40a062bcd093b28afb8e03056
7
+ data.tar.gz: 975248f04642541592a440169438e6356f53e951a380f440d175a38cc42a81c7f4bd168b9786e21b20ab06bf08e576cc143eefb3efb06e7321934623a76c5b32
data/CHANGELOG.md CHANGED
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.3.1] - 2026-10-28
11
+
12
+ ### Changed
13
+
14
+ - **Backtraces show your app's frames.** The backtrace goes through
15
+ `Rails.backtrace_cleaner`, so your own lines are no longer crowded out by gem
16
+ frames and cut off at the size limit. An error that never reaches your code
17
+ keeps its library frames, with short gem paths.
18
+ - **`Host` shows the Heroku dyno name** (`web.1`, `worker.2`) instead of the
19
+ dyno's random hostname.
20
+ - **Google Chat reports from outside a request no longer repeat the error
21
+ class** as a heading above the message.
22
+
10
23
  ## [0.3.0] - 2026-10-28
11
24
 
12
25
  ### Added
data/README.md CHANGED
@@ -75,6 +75,12 @@ In Google Chat, the same details as a single text message, with the params and
75
75
  backtrace in code blocks. Chat has no per-message sender name or avatar: those
76
76
  come from the name and avatar you gave the webhook when you created it.
77
77
 
78
+ The backtrace goes through `Rails.backtrace_cleaner`, as on Rails' own error
79
+ pages, so it shows your app's frames rather than gem internals. When an error
80
+ never reaches your code, such as a job class that doesn't exist, the library
81
+ frames are shown with short gem paths instead. On Heroku, `Host` is the dyno
82
+ name (`web.1`, `worker.2`) rather than the dyno's random hostname.
83
+
78
84
  ## Configuration
79
85
 
80
86
  Everything is optional except `webhook_url`.
@@ -90,7 +96,7 @@ Everything is optional except `webhook_url`.
90
96
  | `ignored_exceptions` | routing/404-style noise (see below) | Exception class names, matched including subclasses. |
91
97
  | `include_params` | `true` | Include filtered request parameters. |
92
98
  | `filter_parameters` | `[]` | Extra redaction matchers, unioned with your app's `config.filter_parameters` and the gem's built-in list. |
93
- | `backtrace_lines` | `10` | Backtrace lines to send, trimmed to fit the message size limit. |
99
+ | `backtrace_lines` | `10` | Backtrace lines to send after cleaning, trimmed to fit the message size limit. |
94
100
  | `open_timeout` / `read_timeout` / `write_timeout` | `2` / `5` / `5` | Seconds. |
95
101
  | `environment` | `Rails.env`, else `RAILS_ENV`/`RACK_ENV` | Shown as a field, and decides the `enabled` default. |
96
102
  | `release` | `nil` | Shown as a field; handy for matching an error to a deploy. |
@@ -22,8 +22,11 @@ module RailsDiscordNotifier
22
22
 
23
23
  private
24
24
 
25
+ # Outside a request the title is only the class name, which the description
26
+ # already opens with, so it is left out rather than repeated.
25
27
  def render(embed)
26
- heading = [bold(embed[:title]), embed[:description], ""]
28
+ heading = [embed[:description], ""]
29
+ heading.unshift(bold(embed[:title])) if request
27
30
  (heading + embed[:fields].map { |field| render_field(field) }).join("\n")
28
31
  end
29
32
 
@@ -42,7 +45,7 @@ module RailsDiscordNotifier
42
45
  end
43
46
 
44
47
  def formatted_backtrace
45
- lines = Array(exception.backtrace).first(config.backtrace_lines)
48
+ lines = clean_backtrace
46
49
  return "No backtrace available" if lines.empty?
47
50
 
48
51
  fence(lines.join("\n"))
@@ -169,7 +169,7 @@ module RailsDiscordNotifier
169
169
  end
170
170
 
171
171
  def formatted_backtrace
172
- lines = Array(exception.backtrace).first(config.backtrace_lines)
172
+ lines = clean_backtrace
173
173
  return "No backtrace available" if lines.empty?
174
174
 
175
175
  lines.each_with_object(+"") do |line, out|
@@ -181,6 +181,21 @@ module RailsDiscordNotifier
181
181
  end
182
182
  end
183
183
 
184
+ # The app's own frames, as on Rails' error pages, so the lines that matter
185
+ # fit the message. An error raised entirely inside library code keeps its
186
+ # library frames, with gem paths shortened. Raw frames when the cleaner is
187
+ # unavailable (no Rails) or raises, and without an app root: Rails 6.1 and
188
+ # 7.0 would then strip the leading "/" from every path.
189
+ def clean_backtrace
190
+ lines = Array(exception.backtrace)
191
+ return lines.first(config.backtrace_lines) unless Rails.root
192
+
193
+ app_frames = Rails.backtrace_cleaner.clean(lines)
194
+ (app_frames.empty? ? Rails.backtrace_cleaner.clean(lines, :all) : app_frames).first(config.backtrace_lines)
195
+ rescue StandardError
196
+ Array(exception.backtrace).first(config.backtrace_lines)
197
+ end
198
+
184
199
  def filtered_url
185
200
  return nil unless request
186
201
 
@@ -232,8 +247,10 @@ module RailsDiscordNotifier
232
247
  @parameter_filter ||= ActiveSupport::ParameterFilter.new(config.filter_parameters)
233
248
  end
234
249
 
250
+ # Heroku hostnames are random IDs; DYNO ("web.1", "worker.2") names the process.
235
251
  def hostname
236
- @hostname ||= Socket.gethostname
252
+ dyno = ENV.fetch("DYNO", "")
253
+ @hostname ||= dyno.empty? ? Socket.gethostname : dyno
237
254
  rescue StandardError
238
255
  nil
239
256
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsDiscordNotifier
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_discord_notifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - GettinDrikkieWithIt