rails_error_notifier 0.2.0 → 0.2.3
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/.github/workflows/release.yml +65 -0
- data/README.md +43 -49
- data/lib/rails_error_notifier/notifier.rb +12 -4
- data/lib/rails_error_notifier/version.rb +1 -1
- metadata +16 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d9adbd6bf63931a372e50cb8bb41b681b731d294f4d2ed67f1b650444e9187d4
|
|
4
|
+
data.tar.gz: a57217e3a95d2ba2ecf73c9d2449a05876866d8d063777d29316fd0884800b2d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 72b4cfd00a642aeeb2c1a675ad61aff3cc16b226c235826879c65e9afadb66a48e48985da8da75e17f8df0c44db1a2fbc7573e76704f0fbbaf8e983dbfa384d6
|
|
7
|
+
data.tar.gz: 714531ca4fc52f5278de30e658dfbc220c64f04602e23619a4fc38cad0db0ffc34357fa9a54e8c0788d8dc9f57467bb93c16ff65b59a751c566ec01a9be72eea
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
name: Release to RubyGems
|
|
2
|
+
|
|
3
|
+
# Manual trigger
|
|
4
|
+
on:
|
|
5
|
+
workflow_dispatch:
|
|
6
|
+
inputs:
|
|
7
|
+
version:
|
|
8
|
+
description: 'Version of the gem to release (e.g., 0.2.0)'
|
|
9
|
+
required: true
|
|
10
|
+
default: '0.2.0'
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build-and-release:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
strategy:
|
|
16
|
+
matrix:
|
|
17
|
+
ruby: [2.5.9, 2.6.10, 2.7.8, 3.0.6, 3.2.0] # Ruby versions to test
|
|
18
|
+
steps:
|
|
19
|
+
# 1️⃣ Checkout repository
|
|
20
|
+
- name: Checkout repository
|
|
21
|
+
uses: actions/checkout@v3
|
|
22
|
+
|
|
23
|
+
# 2️⃣ Set up Ruby
|
|
24
|
+
- name: Set up Ruby
|
|
25
|
+
uses: ruby/setup-ruby@v1
|
|
26
|
+
with:
|
|
27
|
+
ruby-version: ${{ matrix.ruby }}
|
|
28
|
+
|
|
29
|
+
# 3️⃣ Install Bundler compatible with Ruby version
|
|
30
|
+
- name: Install Bundler
|
|
31
|
+
run: |
|
|
32
|
+
if [[ "${{ matrix.ruby }}" == 2.5.* ]]; then
|
|
33
|
+
gem install bundler -v 2.2.33
|
|
34
|
+
elif [[ "${{ matrix.ruby }}" < 3.2 ]]; then
|
|
35
|
+
gem install bundler -v 2.3.26
|
|
36
|
+
else
|
|
37
|
+
gem install bundler -v 2.7.1
|
|
38
|
+
fi
|
|
39
|
+
|
|
40
|
+
# 4️⃣ Install dependencies
|
|
41
|
+
- name: Install dependencies
|
|
42
|
+
run: bundle install
|
|
43
|
+
|
|
44
|
+
# 5️⃣ Run RSpec tests
|
|
45
|
+
- name: Run RSpec tests
|
|
46
|
+
run: bundle exec rspec
|
|
47
|
+
|
|
48
|
+
# 6️⃣ Update gem version (only Ruby 3.2.0)
|
|
49
|
+
- name: Update gem version
|
|
50
|
+
if: matrix.ruby == '3.2.0'
|
|
51
|
+
run: |
|
|
52
|
+
sed -i "s/^ s.version.*/ s.version = '${{ github.event.inputs.version }}'/" rails_error_notifier.gemspec
|
|
53
|
+
cat rails_error_notifier.gemspec | grep s.version
|
|
54
|
+
|
|
55
|
+
# 7️⃣ Build gem (only Ruby 3.2.0)
|
|
56
|
+
- name: Build gem
|
|
57
|
+
if: matrix.ruby == '3.2.0'
|
|
58
|
+
run: gem build rails_error_notifier.gemspec
|
|
59
|
+
|
|
60
|
+
# 8️⃣ Push gem to RubyGems (only Ruby 3.2.0)
|
|
61
|
+
- name: Push gem to RubyGems
|
|
62
|
+
if: matrix.ruby == '3.2.0'
|
|
63
|
+
env:
|
|
64
|
+
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
|
|
65
|
+
run: gem push rails_error_notifier-*.gem
|
data/README.md
CHANGED
|
@@ -1,33 +1,46 @@
|
|
|
1
|
-
# 🚨
|
|
1
|
+
# 🚨 Rails Error Notifier – Ruby Gem for Error Monitoring in Rails
|
|
2
|
+
|
|
3
|
+
[](https://rubygems.org/gems/rails_error_notifier)
|
|
4
|
+
[](https://github.com/mrmalvi/rails_error_notifier/actions)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
|
|
7
|
+
**Rails Error Notifier** is an open-source **Ruby gem** for **Rails 6+ applications** that automatically captures unhandled exceptions and sends instant notifications.
|
|
8
|
+
It integrates with **Slack**, **Discord**, **Email**, and **WhatsApp (Twilio)** so your team is immediately alerted to production errors.
|
|
9
|
+
|
|
10
|
+
👉 [RubyGems page](https://rubygems.org/gems/rails_error_notifier) |
|
|
11
|
+
👉 [Source code on GitHub](https://github.com/mrmalvi/rails_error_notifier)
|
|
2
12
|
|
|
3
|
-
RailsErrorNotifier is a Ruby gem that automatically captures errors in your Rails applications and sends notifications to your preferred channels.
|
|
4
|
-
It supports **Slack**, **Discord**, **Email**, and **WhatsApp**, ensuring you’re immediately informed about critical issues in production.
|
|
5
13
|
---
|
|
6
14
|
|
|
7
15
|
## ✨ Features
|
|
8
|
-
- 🔥
|
|
9
|
-
- 📩 Send error notifications to
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
16
|
+
- 🔥 Automatic error capturing in Rails via Rack middleware.
|
|
17
|
+
- 📩 Send error notifications to:
|
|
18
|
+
- Slack
|
|
19
|
+
- Discord
|
|
20
|
+
- Email
|
|
21
|
+
- WhatsApp (via Twilio API)
|
|
22
|
+
- ⚙️ Easy setup with Rails generator.
|
|
23
|
+
- 📝 Add custom context (current user, request path, environment).
|
|
24
|
+
- 🛡️ Safe failover (won’t crash if webhooks or configs are missing).
|
|
25
|
+
- 🧩 Works seamlessly with **Rails 6, Rails 7, and above**, and supports **Ruby 2.0+**.
|
|
13
26
|
|
|
14
27
|
---
|
|
15
28
|
|
|
16
29
|
## 📦 Installation
|
|
17
30
|
|
|
18
|
-
Add this line to your
|
|
31
|
+
Add this line to your `Gemfile`:
|
|
19
32
|
|
|
20
33
|
```ruby
|
|
21
|
-
gem 'rails_error_notifier'
|
|
34
|
+
gem 'rails_error_notifier'
|
|
22
35
|
```
|
|
23
36
|
|
|
24
|
-
|
|
37
|
+
Install the gem:
|
|
25
38
|
|
|
26
39
|
```bash
|
|
27
40
|
bundle install
|
|
28
41
|
```
|
|
29
42
|
|
|
30
|
-
Or install
|
|
43
|
+
Or install manually:
|
|
31
44
|
|
|
32
45
|
```bash
|
|
33
46
|
gem install rails_error_notifier
|
|
@@ -37,7 +50,7 @@ gem install rails_error_notifier
|
|
|
37
50
|
|
|
38
51
|
## ⚙️ Configuration
|
|
39
52
|
|
|
40
|
-
Generate
|
|
53
|
+
Generate initializer:
|
|
41
54
|
|
|
42
55
|
```bash
|
|
43
56
|
bin/rails generate rails_error_notifier:install
|
|
@@ -46,8 +59,6 @@ bin/rails generate rails_error_notifier:install
|
|
|
46
59
|
This creates `config/initializers/rails_error_notifier.rb`:
|
|
47
60
|
|
|
48
61
|
```ruby
|
|
49
|
-
# frozen_string_literal: true
|
|
50
|
-
|
|
51
62
|
RailsErrorNotifier.configure do |config|
|
|
52
63
|
# Slack + Discord
|
|
53
64
|
config.slack_webhook = ENV["SLACK_WEBHOOK_URL"] # "https://hooks.slack.com/services/T000/B000/XXXX"
|
|
@@ -57,13 +68,13 @@ RailsErrorNotifier.configure do |config|
|
|
|
57
68
|
config.error_email_to = ENV["ERROR_EMAIL_TO"] # e.g. "dev-team@example.com"
|
|
58
69
|
config.error_email_from = ENV["ERROR_EMAIL_FROM"] # e.g. "notifier@example.com"
|
|
59
70
|
|
|
60
|
-
# WhatsApp (Twilio)
|
|
71
|
+
# WhatsApp (via Twilio)
|
|
61
72
|
config.twilio_sid = ENV["TWILIO_SID"] #"AC1234567890abcdef1234567890abcd"
|
|
62
73
|
config.twilio_token = ENV["TWILIO_TOKEN"] #"your_auth_token_here"
|
|
63
74
|
config.twilio_from = ENV["TWILIO_FROM"] #"+14155552671"
|
|
64
75
|
config.twilio_to = ENV["TWILIO_TO"] # "whatsapp:+919876543210"
|
|
65
76
|
|
|
66
|
-
# Enable
|
|
77
|
+
# Enable in production only
|
|
67
78
|
config.enabled = !Rails.env.development? && !Rails.env.test?
|
|
68
79
|
end
|
|
69
80
|
```
|
|
@@ -73,10 +84,9 @@ end
|
|
|
73
84
|
## 🚀 Usage
|
|
74
85
|
|
|
75
86
|
### Automatic Error Notifications
|
|
76
|
-
|
|
77
|
-
Whenever an exception occurs, a notification is sent to your configured services.
|
|
87
|
+
Rails middleware will automatically send alerts for any unhandled exception.
|
|
78
88
|
|
|
79
|
-
### Manual Notifications
|
|
89
|
+
### Manual Error Notifications
|
|
80
90
|
```ruby
|
|
81
91
|
begin
|
|
82
92
|
risky_operation
|
|
@@ -94,8 +104,6 @@ end
|
|
|
94
104
|
🚨 Rails Error Notifier
|
|
95
105
|
Message: undefined method `foo' for nil:NilClass
|
|
96
106
|
Context: {:user_id=>42, :path=>"/dashboard"}
|
|
97
|
-
Backtrace:
|
|
98
|
-
app/controllers/dashboard_controller.rb:12:in `index'
|
|
99
107
|
```
|
|
100
108
|
|
|
101
109
|
### Discord
|
|
@@ -108,9 +116,9 @@ Context: {:host=>"db.example.com", :env=>"production"}
|
|
|
108
116
|
|
|
109
117
|
---
|
|
110
118
|
|
|
111
|
-
## 🧪
|
|
119
|
+
## 🧪 Development & Testing
|
|
112
120
|
|
|
113
|
-
Clone
|
|
121
|
+
Clone and setup:
|
|
114
122
|
|
|
115
123
|
```bash
|
|
116
124
|
git clone https://github.com/mrmalvi/rails_error_notifier.git
|
|
@@ -118,52 +126,38 @@ cd rails_error_notifier
|
|
|
118
126
|
bundle install
|
|
119
127
|
```
|
|
120
128
|
|
|
121
|
-
Run
|
|
129
|
+
Run specs:
|
|
122
130
|
|
|
123
131
|
```bash
|
|
124
132
|
bundle exec rspec
|
|
125
133
|
```
|
|
126
134
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
```bash
|
|
130
|
-
bin/console
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
Build and install the gem locally:
|
|
135
|
+
Build gem locally:
|
|
134
136
|
|
|
135
137
|
```bash
|
|
136
138
|
bundle exec rake install
|
|
137
139
|
```
|
|
138
140
|
|
|
139
|
-
Release a
|
|
141
|
+
Release a version:
|
|
140
142
|
|
|
141
143
|
```bash
|
|
142
144
|
bundle exec rake release
|
|
143
145
|
```
|
|
144
146
|
|
|
145
|
-
This will:
|
|
146
|
-
- Create a Git tag for the version
|
|
147
|
-
- Push commits and tags
|
|
148
|
-
- Publish the `.gem` file to [rubygems.org](https://rubygems.org)
|
|
149
|
-
|
|
150
147
|
---
|
|
151
148
|
|
|
152
149
|
## 🤝 Contributing
|
|
153
150
|
|
|
154
|
-
Contributions are welcome!
|
|
155
|
-
|
|
156
|
-
1. Fork the repo
|
|
157
|
-
2. Create a new branch (`git checkout -b my-feature`)
|
|
158
|
-
3. Commit your changes (`git commit -am 'Add feature'`)
|
|
159
|
-
4. Push to the branch (`git push origin my-feature`)
|
|
160
|
-
5. Open a Pull Request
|
|
161
|
-
|
|
162
|
-
Bug reports and pull requests are welcome on GitHub:
|
|
163
|
-
👉 [https://github.com/mrmalvi/rails_error_notifier](https://github.com/mrmalvi/rails_error_notifier)
|
|
151
|
+
Contributions, bug reports, and pull requests are welcome!
|
|
152
|
+
See [issues](https://github.com/mrmalvi/rails_error_notifier/issues).
|
|
164
153
|
|
|
165
154
|
---
|
|
166
155
|
|
|
167
156
|
## 📜 License
|
|
168
157
|
|
|
169
|
-
|
|
158
|
+
Released under the [MIT License](LICENSE.txt).
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
### 📈 SEO Keywords
|
|
163
|
+
*Rails error notifier gem, Ruby gem for error logging, Slack error notification Rails, Discord error notification Rails, Rails exception tracker, Rails monitoring gem, Ruby on Rails error reporting.*
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
require "net/http"
|
|
2
2
|
require "json"
|
|
3
|
+
require "faraday"
|
|
4
|
+
|
|
3
5
|
begin
|
|
4
6
|
require 'twilio-ruby'
|
|
5
7
|
rescue LoadError
|
|
@@ -69,10 +71,16 @@ module RailsErrorNotifier
|
|
|
69
71
|
}
|
|
70
72
|
end
|
|
71
73
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
begin
|
|
75
|
+
Net::HTTP.post(uri, data.to_json, "Content-Type" => "application/json")
|
|
76
|
+
rescue
|
|
77
|
+
begin
|
|
78
|
+
Faraday.post(uri.to_s, data.to_json, "Content-Type" => "application/json")
|
|
79
|
+
rescue => e
|
|
80
|
+
warn "[RailsErrorNotifier] Slack/Discord delivery failed: #{e.message}"
|
|
81
|
+
nil
|
|
82
|
+
end
|
|
83
|
+
end
|
|
76
84
|
end
|
|
77
85
|
|
|
78
86
|
def send_to_email(payload)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rails_error_notifier
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- mrmalvi
|
|
@@ -29,6 +29,20 @@ dependencies:
|
|
|
29
29
|
- - "<"
|
|
30
30
|
- !ruby/object:Gem::Version
|
|
31
31
|
version: '8.0'
|
|
32
|
+
- !ruby/object:Gem::Dependency
|
|
33
|
+
name: faraday
|
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
|
35
|
+
requirements:
|
|
36
|
+
- - ">="
|
|
37
|
+
- !ruby/object:Gem::Version
|
|
38
|
+
version: '0'
|
|
39
|
+
type: :runtime
|
|
40
|
+
prerelease: false
|
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
42
|
+
requirements:
|
|
43
|
+
- - ">="
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: '0'
|
|
32
46
|
- !ruby/object:Gem::Dependency
|
|
33
47
|
name: rspec
|
|
34
48
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -65,6 +79,7 @@ executables: []
|
|
|
65
79
|
extensions: []
|
|
66
80
|
extra_rdoc_files: []
|
|
67
81
|
files:
|
|
82
|
+
- ".github/workflows/release.yml"
|
|
68
83
|
- ".github/workflows/rubyonrails.yml"
|
|
69
84
|
- ".ruby-version"
|
|
70
85
|
- LICENSE.txt
|