Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attach reporter information to error reports #30

Merged
merged 1 commit into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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