Skip to content

Commit

Permalink
Merge pull request #30 from telebugs/reporter-info
Browse files Browse the repository at this point in the history
Attach reporter information to error reports
  • Loading branch information
kyrylo authored Jun 21, 2024
2 parents a0090f0 + 0868c2b commit d67dd07
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 d67dd07

Please sign in to comment.