bugwatch-ruby 0.1.1 → 0.1.2

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: ae8a8f1bf91cd48c4650616ca55fef7a70cff443835631f6a61b6033ab8eea63
4
- data.tar.gz: a50b752f8c9d0ef56a4e2a9c04e5bca4f3299ca163b19d90000fa6e9299b1e03
3
+ metadata.gz: 57c0dd9d1f88dcfeb7bad5a6440ef0b7b9ccdbb0a0ca53bd777c4520f8257bea
4
+ data.tar.gz: 11bfad309a476d9d4501ee6be56ef27d6bb7157d6ef5744bc7401606e019346a
5
5
  SHA512:
6
- metadata.gz: f290d3a199271b963f6f71304d3a6a9dac3777d0cc12852091eef4dc2db2191d0f4e258eb3010b2a580f6f0d407d785f7d5263f19ac285500d8064ff9d7fd52c
7
- data.tar.gz: d36386cfc611b5886ee2b737c3210987674b5d009214e9c2ac83b69fb335c9ee2d42f62bb5f74b1f62d94d71b7451221b70b5f748ffa9419db06e3b527e8907a
6
+ metadata.gz: b81113875823f9826c3cc50c29a675adb53c1fcebe978836411549867a5eba6cdaf16df2fe9fe8d64fd5d30005f844705ede56a9d66fe13e655b995788c51f1f
7
+ data.tar.gz: 9990375e5142f344e6f883687250426c39fcf016625bf4140e990c679d8f18a7688ed94735294468aed95a834d039bb9b3cd898c5e6aa45593db4f73f9d7bfeb
@@ -0,0 +1,62 @@
1
+ require "socket"
2
+
3
+ module Bugwatch
4
+ class ReportBuilder
5
+ VALID_CATEGORIES = %w[ui behavior performance other].freeze
6
+
7
+ def initialize(title, category: "other", severity: "warning", tags: {}, config: Bugwatch.configuration)
8
+ @title = title.to_s
9
+ @category = VALID_CATEGORIES.include?(category.to_s) ? category.to_s : "other"
10
+ @severity = severity.to_s
11
+ @tags = tags || {}
12
+ @config = config
13
+ end
14
+
15
+ def build
16
+ {
17
+ issue_type: "manual",
18
+ category: @category,
19
+ exception: exception_payload,
20
+ app: app_payload,
21
+ user: UserContext.get,
22
+ breadcrumbs: BreadcrumbCollector.all,
23
+ tags: @tags,
24
+ severity: @severity
25
+ }
26
+ end
27
+
28
+ private
29
+
30
+ def exception_payload
31
+ {
32
+ error_class: "ManualReport::#{@category.capitalize}",
33
+ message: @title,
34
+ backtrace: caller_backtrace
35
+ }
36
+ end
37
+
38
+ def caller_backtrace
39
+ caller_locations(4, 10).map do |loc|
40
+ {
41
+ file: loc.path,
42
+ line: loc.lineno,
43
+ method: loc.label,
44
+ in_app: BacktraceCleaner.in_app?(loc.path)
45
+ }
46
+ end
47
+ end
48
+
49
+ def app_payload
50
+ payload = {
51
+ environment: @config.release_stage,
52
+ version: @config.app_version,
53
+ hostname: Socket.gethostname
54
+ }
55
+
56
+ payload[:ruby_version] = RUBY_VERSION if defined?(RUBY_VERSION)
57
+ payload[:rails_version] = Rails.version if defined?(Rails)
58
+
59
+ payload
60
+ end
61
+ end
62
+ end
@@ -1,3 +1,3 @@
1
1
  module Bugwatch
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/bugwatch.rb CHANGED
@@ -7,6 +7,7 @@ require_relative "bugwatch/user_context"
7
7
  require_relative "bugwatch/breadcrumb_collector"
8
8
  require_relative "bugwatch/backtrace_cleaner"
9
9
  require_relative "bugwatch/error_builder"
10
+ require_relative "bugwatch/report_builder"
10
11
  require_relative "bugwatch/notification"
11
12
  require_relative "bugwatch/middleware"
12
13
  require_relative "bugwatch/railtie" if defined?(Rails::Railtie)
@@ -30,6 +31,14 @@ module Bugwatch
30
31
  Notification.new(payload).deliver
31
32
  end
32
33
 
34
+ def report(title, category: "other", severity: "warning", tags: {})
35
+ return unless configuration.notify_for_release_stage?
36
+ return if title.to_s.strip.empty?
37
+
38
+ payload = ReportBuilder.new(title, category: category, severity: severity, tags: tags).build
39
+ Notification.new(payload).deliver
40
+ end
41
+
33
42
  def set_user(id: nil, email: nil, name: nil, **custom)
34
43
  UserContext.set(id: id, email: email, name: name, **custom)
35
44
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bugwatch-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - BugWatch
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-04-05 00:00:00.000000000 Z
10
+ date: 2026-04-12 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: railties
@@ -55,6 +55,7 @@ files:
55
55
  - lib/bugwatch/middleware.rb
56
56
  - lib/bugwatch/notification.rb
57
57
  - lib/bugwatch/railtie.rb
58
+ - lib/bugwatch/report_builder.rb
58
59
  - lib/bugwatch/user_context.rb
59
60
  - lib/bugwatch/version.rb
60
61
  homepage: https://github.com/bugwatch/bugwatch-ruby