raygun4ruby 1.1.6 → 1.1.8

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: c58d71eb4bdeab659d2f45cf26a950329300de06
4
- data.tar.gz: 8a45df3769e8718f25833068771206bd83293391
3
+ metadata.gz: 273d85a675cf0614daea64f24b92c3a11ac72f51
4
+ data.tar.gz: 33f936b5e6a73da371987b563481f3ef9e82ea06
5
5
  SHA512:
6
- metadata.gz: 5921a260da5a54631c0edbd07741817c0262e994de2e4c96956c32eab9c03d3168a88d7e4ab4349e6557b7179656d765e2aab40e7ff425051cd10efb09835c07
7
- data.tar.gz: c15e7d386feccdaf30bcfe841ebf84b6525ff962d0ea7952ce70635c3950dec7e276d13e56fb23f08a13c918e1baa3a87e907568d7dff81469e6682a3343b9c0
6
+ metadata.gz: 0559ec4c81322a5c05ca0c4ebeabbb62d09c1c969e865d7b525ce8ea9de2570b2e3017e30cc60e80a8a58f7b6ab9507bae4c3cb6d87401a79b9e3c5c96b980db
7
+ data.tar.gz: 65ca7914244a2695511de1616f04706f41b69c88ad36fb38fa9e63e3c90fffc1bd4d5340551a2ccbac5768033c6e3aae7f580661c1b6ae4650a0ef83eec9bb78
data/README.md CHANGED
@@ -47,7 +47,7 @@ Raygun4Ruby doesn't currently support Rails 2. If you'd like Rails 2 support, [d
47
47
 
48
48
  To enable exception tracking in Sinatra, just add configure Raygun and use the Rack middleware in your app:
49
49
 
50
- ```
50
+ ```ruby
51
51
  require 'raygun4ruby'
52
52
  Raygun.setup do |config|
53
53
  config.api_key = "YOUR_API_KEY_HERE"
@@ -169,6 +169,27 @@ end
169
169
 
170
170
  (Remember to set `affected_user_method` to `:raygun_user` in your config block...)
171
171
 
172
+ ### Version tracking
173
+
174
+ Raygun can attach the version of your application to its error reports. In your Raygun.setup block, set `version` to the current version of your app.
175
+
176
+ ```ruby
177
+ Raygun.setup do |config|
178
+ config.version = "1.0.0.4" # you could also pull this from ENV or however you want to set it.
179
+ end
180
+ ```
181
+
182
+ ### Tags
183
+
184
+ Raygun allows you to tag error reports with any number of tags. In your Raygun.setup block, set `tags` to an array of strings to have those
185
+ set on any error reports sent by the gem.
186
+
187
+ ```ruby
188
+ Raygun.setup do |config|
189
+ config.tags = ['heroku']
190
+ end
191
+ ```
192
+
172
193
  ### Resque Error Tracking
173
194
 
174
195
  Raygun4Ruby also includes a Resque failure backend. You should include it inside your Resque initializer (usually something like `config/initializers/load_resque.rb`)
data/lib/raygun/client.rb CHANGED
@@ -30,7 +30,7 @@ module Raygun
30
30
  private
31
31
 
32
32
  def enable_http_proxy
33
- self.class.http_proxy(Raygun.configuration.proxy_settings[:address],
33
+ self.class.http_proxy(Raygun.configuration.proxy_settings[:address],
34
34
  Raygun.configuration.proxy_settings[:port] || "80",
35
35
  Raygun.configuration.proxy_settings[:username],
36
36
  Raygun.configuration.proxy_settings[:password])
@@ -78,11 +78,11 @@ module Raygun
78
78
  !!env["raygun.affected_user"]
79
79
  end
80
80
 
81
- def error_tags
82
- [ENV["RACK_ENV"]]
81
+ def rack_env
82
+ ENV["RACK_ENV"]
83
83
  end
84
84
 
85
- def error_tags_present?
85
+ def rack_env_present?
86
86
  !!ENV["RACK_ENV"]
87
87
  end
88
88
 
@@ -131,13 +131,15 @@ module Raygun
131
131
  def raw_data(rack_env)
132
132
  request = Rack::Request.new(rack_env)
133
133
  unless request.form_data?
134
- form_params(rack_env)
134
+ form_params(rack_env)
135
135
  end
136
136
  end
137
137
 
138
138
  # see http://raygun.io/raygun-providers/rest-json-api?v=1
139
139
  def build_payload_hash(exception_instance, env = {})
140
140
  custom_data = env.delete(:custom_data) || {}
141
+ tags = env.delete(:tags) || []
142
+ tags << rack_env if rack_env_present?
141
143
 
142
144
  error_details = {
143
145
  machineName: hostname,
@@ -145,10 +147,10 @@ module Raygun
145
147
  client: client_details,
146
148
  error: error_details(exception_instance),
147
149
  userCustomData: Raygun.configuration.custom_data.merge(custom_data),
150
+ tags: Raygun.configuration.tags.concat(tags).uniq,
148
151
  request: request_information(env)
149
152
  }
150
153
 
151
- error_details.merge!(tags: error_tags) if error_tags_present?
152
154
  error_details.merge!(user: user_information(env)) if affected_user_present?(env)
153
155
 
154
156
  {
@@ -23,6 +23,9 @@ module Raygun
23
23
  # Custom Data to send with each exception
24
24
  config_option :custom_data
25
25
 
26
+ # Tags to send with each exception
27
+ config_option :tags
28
+
26
29
  # Logger to use when if we find an exception :)
27
30
  config_option :logger
28
31
 
@@ -65,6 +68,7 @@ module Raygun
65
68
  @defaults = OpenStruct.new({
66
69
  ignore: IGNORE_DEFAULT,
67
70
  custom_data: {},
71
+ tags: [],
68
72
  enable_reporting: true,
69
73
  affected_user_method: :current_user,
70
74
  affected_user_identifier_methods: [ :email, :username, :id ],
@@ -109,4 +113,4 @@ module Raygun
109
113
  end
110
114
 
111
115
  end
112
- end
116
+ end
@@ -1,3 +1,3 @@
1
1
  module Raygun
2
- VERSION = "1.1.6"
2
+ VERSION = "1.1.8"
3
3
  end
@@ -92,6 +92,22 @@ class ClientTest < Raygun::UnitTest
92
92
  assert_equal expected_hash, @client.send(:build_payload_hash, e, test_env)[:details][:user]
93
93
  end
94
94
 
95
+ def test_tags
96
+ configuration_tags = %w{alpha beta gaga}
97
+ explicit_env_tags = %w{one two three four}
98
+ rack_env_tag = %w{test}
99
+
100
+ Raygun.setup do |config|
101
+ config.tags = configuration_tags
102
+ end
103
+
104
+ e = TestException.new("A test message")
105
+ test_env = { tags: explicit_env_tags }
106
+ expected_tags = configuration_tags + explicit_env_tags + rack_env_tag
107
+
108
+ assert_equal expected_tags, @client.send(:build_payload_hash, e, test_env)[:details][:tags]
109
+ end
110
+
95
111
  def test_hostname
96
112
  assert_equal Socket.gethostname, @client.send(:hostname)
97
113
  end
@@ -377,7 +393,7 @@ class ClientTest < Raygun::UnitTest
377
393
  private
378
394
 
379
395
  def sample_env_hash
380
- {
396
+ {
381
397
  "SERVER_NAME"=>"localhost",
382
398
  "REQUEST_METHOD"=>"POST",
383
399
  "REQUEST_PATH"=>"/",
@@ -52,6 +52,10 @@ class ConfigurationTest < Raygun::UnitTest
52
52
  assert_equal({}, Raygun.configuration.custom_data)
53
53
  end
54
54
 
55
+ def test_default_tags_set
56
+ assert_equal([], Raygun.configuration.tags)
57
+ end
58
+
55
59
  def test_overriding_defaults
56
60
  Raygun.default_configuration.custom_data = { robby: "robot" }
57
61
  assert_equal({ robby: "robot" }, Raygun.configuration.custom_data)
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: 1.1.6
4
+ version: 1.1.8
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: 2015-05-09 00:00:00.000000000 Z
12
+ date: 2015-09-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
@@ -240,7 +240,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
240
240
  version: '0'
241
241
  requirements: []
242
242
  rubyforge_project:
243
- rubygems_version: 2.2.2
243
+ rubygems_version: 2.4.6
244
244
  signing_key:
245
245
  specification_version: 4
246
246
  summary: This gem provides support for Ruby and Ruby on Rails for the Raygun.io error