raygun4ruby 3.1.1 → 3.2.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
  SHA1:
3
- metadata.gz: 1b2d4b0893569016193338e74716ee400aa22318
4
- data.tar.gz: c95e698b2376c2592dc19b341a3c82ca213d64bd
3
+ metadata.gz: 38293d7b440b4bfd6832b011cd1e21e35bb6fbf9
4
+ data.tar.gz: b6f121cd013f4bb492f818a1affc0d4d8e85c42b
5
5
  SHA512:
6
- metadata.gz: a7ac04cea20753d0e5618af7d8676c8ce48648932de4311d5dc38d311b942f9677e352c3739bb21591b61aeb40859aa1f34af8698a7257a6d27b25a60cba1462
7
- data.tar.gz: e1374a86dc5768b89fc10e32548dc6f6beb22b9560b35d9d81b0aee467f53f945cd6c1bc865816fef72fea52db37e2ab64fce8f758b89dced6fb9fd9a53b60b3
6
+ metadata.gz: 39e682dda4b6aeb589c7cd1dab4f3314f170cabdbbaf83538aab686197237bc8ba3b4618307b12ad9cacc8f3fb5e5dd3e2bf8d0df96ae13849895027eea6c95c
7
+ data.tar.gz: d35f07722386ed7b3b27827709be074dbd52e1984860689290466af3dcfe19b98487a770db769b717ba17d988bdb868ab178a61c4f560b8b8571a208943a9d5f
@@ -1,3 +1,11 @@
1
+ ## 3.2.0 (21/02/2019):
2
+ Bugfix:
3
+ - Fix NoMethodError Exception: undefined method `include?' for nil:NilClass in `JavascriptExceptionTracking` class. Thanks @yamanaltereh for this ([#141](https://github.com/MindscapeHQ/raygun4ruby/pull/141))
4
+ - Fix ([#145](https://github.com/MindscapeHQ/raygun4ruby/issues/145)), "raygun4ruby will load pry if it is in the gem bundle". Thanks to @eoinkelly for reporting this
5
+
6
+ Feature:
7
+ - If you have recorded a large number of Breadcrumbs, or just very large ones, Raygun4Ruby will now only send up to 100KB of them instead of all of them, potentially going over the 128KB payload limit Raygun accepts ([#147](https://github.com/MindscapeHQ/raygun4ruby/pull/147))
8
+
1
9
  ## 3.1.1 (16/01/2019):
2
10
  Bugfix:
3
11
  - Don't attempt to modify response unless JS api key is present
@@ -6,7 +14,7 @@ Bugfix:
6
14
 
7
15
  ## 3.1.0 (15/01/2019):
8
16
 
9
- Feature:
17
+ Feature:
10
18
  - Ability to automatically configure Raygun4JS on the client side by injecting it into outbound HTML pages. Thanks @MikeRogers0 for this ([#138](https://github.com/MindscapeHQ/raygun4ruby/pull/138))
11
19
 
12
20
  ## 3.0.0 (18/12/2018):
data/README.md CHANGED
@@ -19,7 +19,7 @@ Or install it yourself as:
19
19
 
20
20
  ## Usage
21
21
 
22
- ### Rails 3/4
22
+ ### Rails 3/4/5
23
23
 
24
24
  Run:
25
25
 
@@ -83,7 +83,7 @@ rescue => e
83
83
  end
84
84
  ```
85
85
 
86
- You can also pass a Hash as the second parameter to `track_exception`. It should look like a [Rack Env Hash](http://rack.rubyforge.org/doc/SPEC.html)
86
+ You can also pass a Hash as the second parameter to `track_exception`. It should look like a [Rack Env Hash](https://www.rubydoc.info/github/rack/rack/master/file/SPEC)
87
87
 
88
88
  ### Customizing The Parameter Filtering
89
89
 
@@ -6,11 +6,6 @@ require "socket"
6
6
  require "rack"
7
7
  require "ostruct"
8
8
 
9
- begin
10
- require "pry"
11
- rescue LoadError
12
- end
13
-
14
9
  require "raygun/version"
15
10
  require "raygun/configuration"
16
11
  require "raygun/client"
@@ -152,6 +147,8 @@ module Raygun
152
147
  env[:custom_data] ||= {}
153
148
  env[:custom_data].merge!(original_stacktrace: exception_instance.backtrace)
154
149
 
150
+ ::Raygun::Breadcrumbs::Store.clear
151
+
155
152
  track_exception(new_exception, env, user, retry_count - 1)
156
153
  else
157
154
  raise e
@@ -25,6 +25,10 @@ module Raygun
25
25
  v != nil
26
26
  end]
27
27
  end
28
+
29
+ def size
30
+ return message.length + 100
31
+ end
28
32
  end
29
33
  end
30
34
  end
@@ -47,6 +47,16 @@ module Raygun
47
47
  stored != nil && stored.length > 0
48
48
  end
49
49
 
50
+ def self.take_until_size(size)
51
+ breadcrumb_size = 0
52
+
53
+ stored.reverse.take_while do |crumb|
54
+ breadcrumb_size += crumb.size
55
+
56
+ breadcrumb_size < size
57
+ end.reverse
58
+ end
59
+
50
60
  private
51
61
 
52
62
  def self.should_record?(crumb)
@@ -5,6 +5,7 @@ module Raygun
5
5
 
6
6
  ENV_IP_ADDRESS_KEYS = %w(action_dispatch.remote_ip raygun.remote_ip REMOTE_ADDR)
7
7
  NO_API_KEY_MESSAGE = "[RAYGUN] Just a note, you've got no API Key configured, which means we can't report exceptions. Specify your Raygun API key using Raygun#setup (find yours at https://app.raygun.io)"
8
+ MAX_BREADCRUMBS_SIZE = 100_000
8
9
 
9
10
  include HTTParty
10
11
 
@@ -214,7 +215,7 @@ module Raygun
214
215
  }
215
216
  }
216
217
  store = ::Raygun::Breadcrumbs::Store
217
- error_details[:breadcrumbs] = store.stored.map(&:build_payload) if store.any?
218
+ error_details[:breadcrumbs] = store.take_until_size(MAX_BREADCRUMBS_SIZE).map(&:build_payload) if store.any?
218
219
 
219
220
  Raygun.log('set details and breadcrumbs')
220
221
 
@@ -8,7 +8,7 @@ module Raygun::Middleware
8
8
  status, headers, response = @app.call(env)
9
9
 
10
10
  # It's a html file, inject our JS
11
- if headers['Content-Type'].include?('text/html')
11
+ if headers['Content-Type']&.include?('text/html')
12
12
  response = inject_javascript_to_response(response)
13
13
  end
14
14
 
@@ -1,3 +1,3 @@
1
1
  module Raygun
2
- VERSION = "3.1.1"
2
+ VERSION = "3.2.0"
3
3
  end
@@ -37,7 +37,7 @@ Gem::Specification.new do |spec|
37
37
  spec.add_development_dependency "webmock"
38
38
 
39
39
  spec.add_development_dependency 'rails', "= 5.2"
40
- spec.add_development_dependency 'sqlite3'
40
+ spec.add_development_dependency 'sqlite3', '~> 1.3.6'
41
41
  spec.add_development_dependency 'capybara'
42
42
  spec.add_development_dependency "rspec-rails"
43
43
  spec.add_development_dependency "launchy"
@@ -129,6 +129,43 @@ module Raygun
129
129
  expect(payload[:CustomData]).to eq(foo: 'bar')
130
130
  end
131
131
  end
132
+
133
+ describe "#size" do
134
+ before do
135
+ Timecop.freeze
136
+ Store.initialize
137
+ end
138
+ after do
139
+ Timecop.return
140
+ Store.clear
141
+ end
142
+
143
+ let(:message) { "This is a breadcrumb message" }
144
+
145
+ let(:breadcrumb) do
146
+ Store.record(
147
+ message: message,
148
+ category: "test",
149
+ level: :info,
150
+ class_name: "HomeController",
151
+ method_name: "index",
152
+ line_number: 17,
153
+ metadata: {
154
+ foo: 'bar'
155
+ }
156
+ )
157
+
158
+ Store.stored[0]
159
+ end
160
+
161
+ let(:size) { breadcrumb.size }
162
+
163
+ it "returns the estimated size of the breadcrumb" do
164
+ # Can't check all the fields but message so assume a standard 100 length for all of them
165
+ # The message should be the bulk of large breadcrumbs anyway
166
+ expect(size).to eq(message.length + 100)
167
+ end
168
+ end
132
169
  end
133
170
  end
134
171
  end
@@ -67,6 +67,30 @@ module Raygun
67
67
  end
68
68
  end
69
69
 
70
+ describe "#take_until_size" do
71
+ before do
72
+ subject.initialize
73
+ end
74
+
75
+ it "takes the most recent breadcrumbs until the size limit is reached" do
76
+ subject.record(message: '1' * 100)
77
+ subject.record(message: '2' * 100)
78
+ subject.record(message: '3' * 100)
79
+
80
+ crumbs = subject.take_until_size(500)
81
+
82
+ expect(crumbs.length).to eq(2)
83
+ expect(crumbs[0].message).to eq('2' * 100)
84
+ expect(crumbs[1].message).to eq('3' * 100)
85
+ end
86
+
87
+ it "does not crash with no recorded breadcrumbs" do
88
+ crumbs = subject.take_until_size(500)
89
+
90
+ expect(crumbs).to eq([])
91
+ end
92
+ end
93
+
70
94
  context "adding a breadcrumb" do
71
95
  class Foo
72
96
  include ::Raygun::Breadcrumbs
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raygun4ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mindscape
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-01-16 00:00:00.000000000 Z
12
+ date: 2019-02-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
@@ -231,16 +231,16 @@ dependencies:
231
231
  name: sqlite3
232
232
  requirement: !ruby/object:Gem::Requirement
233
233
  requirements:
234
- - - ">="
234
+ - - "~>"
235
235
  - !ruby/object:Gem::Version
236
- version: '0'
236
+ version: 1.3.6
237
237
  type: :development
238
238
  prerelease: false
239
239
  version_requirements: !ruby/object:Gem::Requirement
240
240
  requirements:
241
- - - ">="
241
+ - - "~>"
242
242
  - !ruby/object:Gem::Version
243
- version: '0'
243
+ version: 1.3.6
244
244
  - !ruby/object:Gem::Dependency
245
245
  name: capybara
246
246
  requirement: !ruby/object:Gem::Requirement