From 0868c2be4e046936fcd544c39ecf504fa52a5f59 Mon Sep 17 00:00:00 2001 From: Kyrylo Silin Date: Sat, 22 Jun 2024 01:25:25 +0300 Subject: [PATCH] Attach reporter information to error reports --- lib/telebugs/report.rb | 8 +++++++- test/test_report.rb | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/telebugs/report.rb b/lib/telebugs/report.rb index 03a8554..13f76a8 100644 --- a/lib/telebugs/report.rb +++ b/lib/telebugs/report.rb @@ -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 @@ -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 diff --git a/test/test_report.rb b/test/test_report.rb index f47362f..4c2218c 100644 --- a/test/test_report.rb +++ b/test/test_report.rb @@ -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