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 +4 -4
- data/CHANGELOG.md +13 -0
- data/README.md +7 -1
- data/lib/rails_discord_notifier/google_chat_payload.rb +5 -2
- data/lib/rails_discord_notifier/payload.rb +19 -2
- data/lib/rails_discord_notifier/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fbf5bc3adc89129d2ab69ef41705e363a214a53eb31dd1bd0dd2a4fb36253a8b
|
|
4
|
+
data.tar.gz: b35128c48b420cd7577a9a455f5d857ef952c08f0ef427136299a2e698e85101
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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 = [
|
|
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 =
|
|
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 =
|
|
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
|
-
|
|
252
|
+
dyno = ENV.fetch("DYNO", "")
|
|
253
|
+
@hostname ||= dyno.empty? ? Socket.gethostname : dyno
|
|
237
254
|
rescue StandardError
|
|
238
255
|
nil
|
|
239
256
|
end
|