snitch-rails 0.2.3 → 0.2.4
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/README.md +24 -3
- data/lib/generators/snitch/install/install_generator.rb +17 -0
- data/lib/snitch/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: 24e7f769e5a0ca5e3af5c85f174944fcb9883f6f70cef92f42dc29eedca8bcf5
|
|
4
|
+
data.tar.gz: e286ffc4b8320d31f5e1345005feb186991386a95197df8db9ae3dd7ecab62e2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 64eda4f8fd955360c4f0dbf03cfc00ad4fff5ddb0bc99903bb2982d59b36a4cf48218fa934209d813d85d15c4cdb4fc7107ab58c598b9d6139de9b6de70f2678
|
|
7
|
+
data.tar.gz: b9e9e351fb45771c3863fc77127b53db784bd87ad49e8d599fab393bffd3b417a59886629ac4377336e5dc62cd89c82b05932ce8b671b9525ba516752a9d4741
|
data/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# Snitch
|
|
2
2
|
|
|
3
|
-
Snitch
|
|
3
|
+
Snitch catches unhandled exceptions in your Rails application, persists them to the database, and reports them as GitHub issues that @mention Claude for automated investigation.
|
|
4
|
+
|
|
5
|
+

|
|
4
6
|
|
|
5
7
|
## Installation
|
|
6
8
|
|
|
@@ -55,10 +57,23 @@ end
|
|
|
55
57
|
|
|
56
58
|
Create a [personal access token](https://github.com/settings/tokens) with the `repo` scope and set it as an environment variable:
|
|
57
59
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
## Manual Reporting
|
|
61
|
+
|
|
62
|
+
Snitch automatically catches unhandled exceptions via middleware, but you can also report exceptions you rescue yourself:
|
|
63
|
+
|
|
64
|
+
```ruby
|
|
65
|
+
begin
|
|
66
|
+
SomeExternalService.call(params)
|
|
67
|
+
rescue ExternalService::Timeout => e
|
|
68
|
+
Snitch::ExceptionHandler.handle(e)
|
|
69
|
+
# continue with your fallback logic
|
|
70
|
+
end
|
|
60
71
|
```
|
|
61
72
|
|
|
73
|
+
This is useful for exceptions you want to recover from gracefully but still want visibility into — failed API calls, flaky third-party services, background job retries, etc.
|
|
74
|
+
|
|
75
|
+
The same fingerprinting and deduplication rules apply. If the same exception is reported multiple times, Snitch will increment the occurrence count and comment on the existing GitHub issue rather than creating a new one.
|
|
76
|
+
|
|
62
77
|
## How It Works
|
|
63
78
|
|
|
64
79
|
1. Rack middleware catches any unhandled exception (and re-raises it so normal error handling still applies)
|
|
@@ -67,6 +82,12 @@ export SNITCH_GITHUB_TOKEN=ghp_your_token_here
|
|
|
67
82
|
4. An ActiveJob is enqueued to create a GitHub issue (or comment on the existing one for duplicate exceptions)
|
|
68
83
|
5. The GitHub issue includes the full backtrace, request context, and an @mention for investigation
|
|
69
84
|
|
|
85
|
+
## Roadmap
|
|
86
|
+
|
|
87
|
+
- [ ] multi-db support
|
|
88
|
+
- [ ] simple dashboard to view captured exceptions (linked to gh issue)
|
|
89
|
+
- [ ] webhook to resolve snitch record, when issues resolve
|
|
90
|
+
|
|
70
91
|
## Requirements
|
|
71
92
|
|
|
72
93
|
- Ruby >= 3.1
|
|
@@ -8,6 +8,23 @@ module Snitch
|
|
|
8
8
|
|
|
9
9
|
source_root File.expand_path("templates", __dir__)
|
|
10
10
|
|
|
11
|
+
def ensure_gemfile_require
|
|
12
|
+
gemfile = File.join(destination_root, "Gemfile")
|
|
13
|
+
return unless File.exist?(gemfile)
|
|
14
|
+
|
|
15
|
+
content = File.read(gemfile)
|
|
16
|
+
|
|
17
|
+
# Skip if require: "snitch" is already present
|
|
18
|
+
return if content.match?(/gem\s+["']snitch-rails["'].*require:\s*["']snitch["']/)
|
|
19
|
+
|
|
20
|
+
# Add require: "snitch" to the existing gem line
|
|
21
|
+
if content.match?(/gem\s+["']snitch-rails["']/)
|
|
22
|
+
gsub_file "Gemfile",
|
|
23
|
+
/(gem\s+["']snitch-rails["'])/,
|
|
24
|
+
'\1, require: "snitch"'
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
11
28
|
def create_migration_file
|
|
12
29
|
migration_template "create_snitch_errors.rb.erb",
|
|
13
30
|
"db/migrate/create_snitch_errors.rb"
|
data/lib/snitch/version.rb
CHANGED