Skip to content

Commit

Permalink
Attach reporter information to error reports
Browse files Browse the repository at this point in the history
  • Loading branch information
kyrylo committed Jun 21, 2024
1 parent a0090f0 commit f30ca29
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/telebugs/report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ class Report
# The maximum size of hashes, arrays and strings in the report.
DATA_MAX_SIZE = 10000

REPORTER = {
library: { name: "telebugs", version: Telebugs::VERSION }.freeze,
platform: { name: "Ruby", version: RUBY_VERSION }.freeze
}.freeze

attr_reader :data
attr_accessor :ignored

Expand All @@ -27,7 +32,8 @@ def initialize(error)
@truncator = Truncator.new(DATA_MAX_SIZE)

@data = {
errors: errors_as_json(error)
errors: errors_as_json(error),
reporters: [REPORTER]
}
end

Expand Down
5 changes: 5 additions & 0 deletions test/test_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,9 @@ def test_to_json
json = r.to_json
assert_match(/"errors".+StandardError.+"test error"/, json)
end

def test_data_reporters
r = Telebugs::Report.new(StandardError.new)
assert_equal [Telebugs::Report::REPORTER], r.data[:reporters]
end
end

0 comments on commit f30ca29

Please sign in to comment.