debug-assist 1.0.0

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/debug_assist.rb +68 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b74320aeacff727002ea42008a50cb2554564562c5714a19f4475381173525a9
4
+ data.tar.gz: 4041f6f6aa8b61aababfba617f5fd0dbd3c936a68d6f247845ae40d54d35cd54
5
+ SHA512:
6
+ metadata.gz: e121215c3562d4b9a77cdcbfe1c61f63092a1120d1e9de2f94085309cf66cc0c1f3e3373602d8a59751df4bf23c09c49022edbedfd472742e3442bad7cc222f8
7
+ data.tar.gz: 55fcb7e3181e6e782462c2395dd3f5007b707df1be07d1e2e453f768a4aa080f5347acf883b1763ce5090525106f4a510905ad4da3e341edbc2f4ca7aa4d4a05
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ # DebugAssist SDK for Ruby
4
+ #
5
+ # Captures unhandled exceptions and reports them to DebugAssist.
6
+ #
7
+ # Usage:
8
+ # require 'debug_assist' # só isso
9
+ #
10
+ # Configuration (env vars):
11
+ # DEBUG_ASSIST_API_KEY — your API key
12
+ # DEBUG_ASSIST_BASE_URL — base URL (default: https://debug-assist.onrender.com)
13
+ # DEBUG_ASSIST_PROJECT — project name (default: unknown)
14
+ # DEBUG_ASSIST_ENABLED=0 — disable SDK
15
+
16
+ require 'net/http'
17
+ require 'json'
18
+ require 'uri'
19
+
20
+ module DebugAssist
21
+ API_KEY = ENV.fetch('DEBUG_ASSIST_API_KEY', '').freeze
22
+ BASE_URL = ENV.fetch('DEBUG_ASSIST_BASE_URL', 'https://debug-assist.onrender.com').chomp('/').freeze
23
+ PROJECT = ENV.fetch('DEBUG_ASSIST_PROJECT', 'unknown').freeze
24
+ ENABLED = ENV['DEBUG_ASSIST_ENABLED'] != '0'
25
+
26
+ def self.send_diagnostic(message, exception_type, stack)
27
+ return unless ENABLED && !API_KEY.empty?
28
+
29
+ payload = JSON.generate(
30
+ tipo: 'silent_backend_error',
31
+ mensagem: message.to_s,
32
+ contexto: {
33
+ project_name: PROJECT,
34
+ exception_type: exception_type.to_s,
35
+ stack: stack.to_s
36
+ }
37
+ )
38
+
39
+ uri = URI("#{BASE_URL}/v1/diagnosticos")
40
+ http = Net::HTTP.new(uri.host, uri.port)
41
+ http.use_ssl = uri.scheme == 'https'
42
+ http.open_timeout = 10
43
+ http.read_timeout = 10
44
+
45
+ req = Net::HTTP::Post.new(uri.path.empty? ? '/' : uri.path)
46
+ req['Content-Type'] = 'application/json'
47
+ req['Authorization'] = "Bearer #{API_KEY}"
48
+ req.body = payload
49
+
50
+ http.request(req)
51
+ rescue StandardError => e
52
+ warn "[DebugAssist] Falha ao enviar diagnóstico: #{e.message}"
53
+ end
54
+
55
+ # Register at_exit hook
56
+ if ENABLED && !API_KEY.empty?
57
+ at_exit do
58
+ err = $!
59
+ next if err.nil? || err.is_a?(SystemExit)
60
+
61
+ DebugAssist.send_diagnostic(
62
+ err.message,
63
+ err.class.name,
64
+ err.backtrace&.join("\n") || ''
65
+ )
66
+ end
67
+ end
68
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: debug-assist
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - DebugAssist
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-03-28 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: DebugAssist SDK for Ruby — captures unhandled exceptions and reports
14
+ them to DebugAssist for diagnosis.
15
+ email: hi@debug-assist.app
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/debug_assist.rb
21
+ homepage: https://github.com/debug-assist/sdk-ruby
22
+ licenses:
23
+ - MIT
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '2.7'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubygems_version: 3.4.19
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Auto-capture runtime errors and send diagnostics to DebugAssist API
44
+ test_files: []