telebugs 0.7.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fcdd2da95dea7cff1e8e90761d19258da064ca26c88feacf218107878e7867c0
4
- data.tar.gz: a094bb5882fb527d00be117a18fe9da8543c6e0e85aed80daf1f554c4dfb1a04
3
+ metadata.gz: aa8891b6ca7665271200ac99930e2e44eaa4a23225996650b794ab3561e2d9c0
4
+ data.tar.gz: a1a4ff3942f1a68b544040589653ee7355e0daea98d23b114dbaea2de7150b04
5
5
  SHA512:
6
- metadata.gz: ea4f4760d4de5182bbce41cb5f90a1f0171281c1d341cf18f47c8a8cd2e9e4fb20eea712f7acf1c145f63a01109a0861ad601ea88a6ba18e06d7fad6dd8a7c5c
7
- data.tar.gz: 02706c551ab96f3774e26875dde6a807c9a917bdbb2aa4613aa4427c1af4963dcc28c1e158be75bcd45564027e46dc972a01271267676a9a4d29c981a9e80f38
6
+ metadata.gz: e65e6264b1bd55c51c81d43d64cb684d7ded53cb97e607a73820bf129d99f6c6c04cbb089e32af538a82490d5387c6bc32650b259b52dbe4abd79324ab9bbac0
7
+ data.tar.gz: 3cdf9ef3c6f5a3d0851124ee546fc3507648ca453684463e4d71c8c375de042b28660b645c5097dc2034ed82238a3bc3019367230a440b26f0602f8d7b0b8f8a
data/README.md CHANGED
@@ -1,8 +1,11 @@
1
1
  # Telebugs for Ruby
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/telebugs.svg)](https://badge.fury.io/rb/telebugs)
4
+
3
5
  Simple error monitoring for developers. Monitor production errors in real-time
4
6
  and get them reported to Telegram with Telebugs.
5
7
 
8
+ - [Official Documentation](https://telebugs.com/docs/integrations/ruby)
6
9
  - [FAQ](https://telebugs.com/faq)
7
10
  - [Telebugs News](https://t.me/TelebugsNews)
8
11
  - [Telebugs Community](https://t.me/TelebugsCommunity)
@@ -10,12 +13,13 @@ and get them reported to Telegram with Telebugs.
10
13
  ## Introduction
11
14
 
12
15
  Any Ruby application or script can be integrated with
13
- [Telebugs](https://telebugs.com) using the `telebugs` gem. The gem is designed
14
- to be simple and easy to use. It provides a simple API to send errors to
15
- Telebugs, which will then be reported to your Telegram project. This guide will
16
- help you get started with Telebugs for Ruby.
16
+ [Telebugs](https://telebugs.com) using the
17
+ [`telebugs`](https://rubygems.org/gems/telebugs) gem. The gem is designed to be
18
+ simple and easy to use. It provides a simple API to send errors to Telebugs,
19
+ which will then be reported to your Telegram project. This guide will help you
20
+ get started with Telebugs for Ruby.
17
21
 
18
- For full details, please refer to the [Telebugs documentation](https://telebugs.com/new/docs/integrations/ruby).
22
+ For full details, please refer to the [Telebugs documentation](https://telebugs.com/docs/integrations/ruby).
19
23
 
20
24
  ## Installation
21
25
 
@@ -8,7 +8,9 @@ module Telebugs
8
8
  :middleware
9
9
 
10
10
  attr_reader :api_url,
11
- :root_directory
11
+ :root_directory,
12
+ :ignore_environments,
13
+ :environment
12
14
 
13
15
  class << self
14
16
  attr_writer :instance
@@ -22,6 +24,18 @@ module Telebugs
22
24
  reset
23
25
  end
24
26
 
27
+ def reset
28
+ self.api_key = nil
29
+ self.api_url = ERROR_API_URL
30
+
31
+ @middleware = MiddlewareStack.new
32
+ @middleware.use Middleware::GemRootFilter.new
33
+
34
+ self.root_directory = (defined?(Bundler) && Bundler.root) || Dir.pwd
35
+ self.environment = ""
36
+ self.ignore_environments = []
37
+ end
38
+
25
39
  def api_url=(url)
26
40
  @api_url = URI(url)
27
41
  end
@@ -29,23 +43,22 @@ module Telebugs
29
43
  def root_directory=(directory)
30
44
  @root_directory = File.realpath(directory)
31
45
 
32
- if @middleware
33
- @middleware.delete(Middleware::RootDirectoryFilter)
34
- @middleware.use Middleware::RootDirectoryFilter.new(@root_directory)
35
- end
46
+ @middleware.delete(Middleware::RootDirectoryFilter)
47
+ @middleware.use Middleware::RootDirectoryFilter.new(@root_directory)
36
48
  end
37
49
 
38
- def reset
39
- self.api_key = nil
40
- self.api_url = ERROR_API_URL
41
- self.root_directory = File.realpath(
42
- (defined?(Bundler) && Bundler.root) ||
43
- Dir.pwd
44
- )
50
+ def environment=(environment)
51
+ @environment = environment
45
52
 
46
- @middleware = MiddlewareStack.new
47
- @middleware.use Middleware::GemRootFilter.new
48
- @middleware.use Middleware::RootDirectoryFilter.new(root_directory)
53
+ @middleware.delete(Middleware::IgnoreEnvironments)
54
+ @middleware.use Middleware::IgnoreEnvironments.new(@environment, @ignore_environments)
55
+ end
56
+
57
+ def ignore_environments=(ignore_environments)
58
+ @ignore_environments = ignore_environments
59
+
60
+ @middleware.delete(Middleware::IgnoreEnvironments)
61
+ @middleware.use Middleware::IgnoreEnvironments.new(@environment, @ignore_environments)
49
62
  end
50
63
  end
51
64
  end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telebugs
4
+ class Middleware
5
+ class IgnoreEnvironments < Telebugs::Middleware
6
+ def initialize(current_env, ignore_envs)
7
+ @current_env = current_env
8
+ @ignore_envs = ignore_envs
9
+ end
10
+
11
+ def call(report)
12
+ report.ignored = @ignore_envs.include?(@current_env)
13
+ end
14
+
15
+ def weight
16
+ -1000
17
+ end
18
+ end
19
+ end
20
+ end
@@ -18,7 +18,7 @@ module Telebugs
18
18
  end
19
19
 
20
20
  def use(new_middleware)
21
- @middlewares = (@middlewares << new_middleware).sort_by(&:weight).reverse
21
+ @middlewares = (@middlewares << new_middleware).sort_by(&:weight)
22
22
  end
23
23
 
24
24
  def delete(middleware_class)
@@ -19,6 +19,11 @@ module Telebugs
19
19
  # The maximum size of hashes, arrays and strings in the report.
20
20
  DATA_MAX_SIZE = 10000
21
21
 
22
+ REPORTER = {
23
+ library: {name: "telebugs", version: Telebugs::VERSION}.freeze,
24
+ platform: {name: "Ruby", version: RUBY_VERSION}.freeze
25
+ }.freeze
26
+
22
27
  attr_reader :data
23
28
  attr_accessor :ignored
24
29
 
@@ -27,7 +32,8 @@ module Telebugs
27
32
  @truncator = Truncator.new(DATA_MAX_SIZE)
28
33
 
29
34
  @data = {
30
- errors: errors_as_json(error)
35
+ errors: errors_as_json(error),
36
+ reporters: [REPORTER]
31
37
  }
32
38
  end
33
39
 
@@ -13,14 +13,14 @@ module Telebugs
13
13
 
14
14
  def initialize
15
15
  @sender = Sender.new
16
- @middleware = Config.instance.middleware
16
+ @config = Config.instance
17
17
  end
18
18
 
19
19
  def report(error)
20
20
  Telebugs::Promise.new(error) do
21
21
  report = Report.new(error)
22
22
 
23
- @middleware.call(report)
23
+ @config.middleware.call(report)
24
24
  next if report.ignored
25
25
 
26
26
  @sender.send(report)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Telebugs
4
- VERSION = "0.7.0"
4
+ VERSION = "0.9.0"
5
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Telebugs
2
4
  # WrappedError unwraps an error and its causes up to a certain depth.
3
5
  class WrappedError
data/lib/telebugs.rb CHANGED
@@ -21,6 +21,7 @@ require_relative "telebugs/truncator"
21
21
 
22
22
  require_relative "telebugs/middleware/gem_root_filter"
23
23
  require_relative "telebugs/middleware/root_directory_filter"
24
+ require_relative "telebugs/middleware/ignore_environments"
24
25
 
25
26
  module Telebugs
26
27
  # The general error that this library uses when it wants to raise.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: telebugs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyrylo Silin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-06-20 00:00:00.000000000 Z
11
+ date: 2024-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -39,8 +39,8 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3.23'
41
41
  description: |
42
- Telebugs Ruby is an SDK for Telebugs (https://telebugs.com/), a simple error monitoring tool for developers. With
43
- Telebugs, you can track production errors in real-time and report them to Telegram.
42
+ Telebugs for Ruby is an error reporting library for Telebugs (https://telebugs.com/), a simple error monitoring tool
43
+ for developers. With Telebugs, you can track production errors in real-time and report them to Telegram.
44
44
  email:
45
45
  - help@telebugs.com
46
46
  executables: []
@@ -59,6 +59,7 @@ files:
59
59
  - lib/telebugs/file_cache.rb
60
60
  - lib/telebugs/middleware.rb
61
61
  - lib/telebugs/middleware/gem_root_filter.rb
62
+ - lib/telebugs/middleware/ignore_environments.rb
62
63
  - lib/telebugs/middleware/root_directory_filter.rb
63
64
  - lib/telebugs/middleware_stack.rb
64
65
  - lib/telebugs/promise.rb
@@ -90,8 +91,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
91
  - !ruby/object:Gem::Version
91
92
  version: '0'
92
93
  requirements: []
93
- rubygems_version: 3.5.3
94
+ rubygems_version: 3.5.11
94
95
  signing_key:
95
96
  specification_version: 4
96
- summary: Report errors to Telebugs with the offical Ruby SDK
97
+ summary: Report errors to Telebugs with the offical library for Ruby.
97
98
  test_files: []