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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f4510d9170b5fd671b0511a772c746a48b6ba9a0a6b959e967bd66eaf49bbd43
4
- data.tar.gz: 55c50540ed460878b90d94276bd98e88b1dad1314fee74ecefc31983e49ac6cc
3
+ metadata.gz: 24e7f769e5a0ca5e3af5c85f174944fcb9883f6f70cef92f42dc29eedca8bcf5
4
+ data.tar.gz: e286ffc4b8320d31f5e1345005feb186991386a95197df8db9ae3dd7ecab62e2
5
5
  SHA512:
6
- metadata.gz: 2a58f507595dd81b3ec81dc0746da75e3f48a0f779c17f2918057b720fc06abaa2da51a396eb4cfb8ee977686cf4ed42963be191d35d57f2075916589da8ba5e
7
- data.tar.gz: 5d549635ee294c1365e76ca4750f3de3ab029e906d200bee99dbef2f65d6552c5f6f40231a8d2c91fcabe5b46956ef62d5d1784f63377ca072056f32febdff5e
6
+ metadata.gz: 64eda4f8fd955360c4f0dbf03cfc00ad4fff5ddb0bc99903bb2982d59b36a4cf48218fa934209d813d85d15c4cdb4fc7107ab58c598b9d6139de9b6de70f2678
7
+ data.tar.gz: b9e9e351fb45771c3863fc77127b53db784bd87ad49e8d599fab393bffd3b417a59886629ac4377336e5dc62cd89c82b05932ce8b671b9525ba516752a9d4741
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Snitch
2
2
 
3
- Snitch automatically catches unhandled exceptions in your Rails application, persists them to the database, and reports them as GitHub issues that @mention Claude for automated investigation.
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
+ ![Example GitHub issue created by Snitch](example.png)
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
- ```bash
59
- export SNITCH_GITHUB_TOKEN=ghp_your_token_here
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"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Snitch
4
- VERSION = '0.2.3'
4
+ VERSION = '0.2.4'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snitch-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - RiseKit