raygun4ruby 3.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rspec +1 -0
- data/.travis.yml +0 -2
- data/CHANGELOG.md +5 -0
- data/Rakefile +9 -2
- data/lib/raygun.rb +2 -0
- data/lib/raygun/configuration.rb +6 -0
- data/lib/raygun/javascript_tracker.rb +42 -0
- data/lib/raygun/middleware/javascript_exception_tracking.rb +30 -0
- data/lib/raygun/railtie.rb +2 -1
- data/lib/raygun/version.rb +1 -1
- data/raygun4ruby.gemspec +8 -1
- data/spec/dummy/.ruby-version +1 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/config/manifest.js +3 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/javascripts/cable.js +13 -0
- data/spec/dummy/app/assets/javascripts/channels/.keep +0 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
- data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
- data/spec/dummy/app/controllers/application_controller.rb +2 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/controllers/home_controller.rb +4 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/jobs/application_job.rb +2 -0
- data/spec/dummy/app/mailers/application_mailer.rb +4 -0
- data/spec/dummy/app/models/application_record.rb +3 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/views/home/index.html.erb +3 -0
- data/spec/dummy/app/views/home/index.json.erb +1 -0
- data/spec/dummy/app/views/layouts/application.html.erb +15 -0
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +36 -0
- data/spec/dummy/bin/update +31 -0
- data/spec/dummy/bin/yarn +11 -0
- data/spec/dummy/config.ru +5 -0
- data/spec/dummy/config/application.rb +18 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/cable.yml +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +61 -0
- data/spec/dummy/config/environments/production.rb +94 -0
- data/spec/dummy/config/environments/test.rb +46 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/dummy/config/initializers/assets.rb +14 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/content_security_policy.rb +25 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +33 -0
- data/spec/dummy/config/puma.rb +34 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/config/spring.rb +6 -0
- data/spec/dummy/config/storage.yml +34 -0
- data/spec/dummy/db/schema.rb +15 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/package.json +5 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/storage/.keep +0 -0
- data/spec/features/javascript_spec.rb +48 -0
- data/spec/rails_helper.rb +4 -0
- data/{specs → spec}/raygun/breadcrumbs/breadcrumb_spec.rb +19 -19
- data/{specs → spec}/raygun/breadcrumbs/store_spec.rb +21 -23
- data/{specs → spec}/raygun/raygun_spec.rb +5 -8
- data/{specs → spec}/services/apply_whitelist_filter_to_payload_spec.rb +9 -9
- data/spec/spec_helper.rb +24 -0
- data/spec/support/fake_logger.rb +17 -0
- data/test/test_helper.rb +1 -0
- data/test/unit/configuration_test.rb +12 -0
- metadata +163 -9
- data/specs/spec_helper.rb +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: acbc458153d576b6856920cb72985952f9f6ed22
|
4
|
+
data.tar.gz: bb9976f64347bce6b6a6a6f3920564b489b478bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d603e52d886065cf9cc7b26f6639a8f6c237447d2af106bd5e55b96e5d25b721b1b2607a34f25b71ef9ea5514252492dd7f584463d36a7dd2d614db1a00b66c1
|
7
|
+
data.tar.gz: 9c1f5c46f012cc003a32ed8829755f3c8321d3049c6b1c7c349063461674f6bf0a6c7114fb9bf444f8ce926c101cd9125c96f92438a34c2a6f1dd8322e650734
|
data/.gitignore
CHANGED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## 3.1.0 (15/01/2019):
|
2
|
+
|
3
|
+
Feature:
|
4
|
+
- 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)])
|
5
|
+
|
1
6
|
## 3.0.0 (18/12/2018):
|
2
7
|
Breaking changes:
|
3
8
|
Parameter filters are now applied if you are using the `filter_payload_with_whitelist` functionality. Previously if this was set to true the parameter filtering was bailed out of ([#136](https://github.com/MindscapeHQ/raygun4ruby/pull/136/files))
|
data/Rakefile
CHANGED
@@ -7,7 +7,7 @@ namespace :test do
|
|
7
7
|
|
8
8
|
desc "Test the basics of the adapter"
|
9
9
|
Rake::TestTask.new(:units) do |t|
|
10
|
-
t.test_files = FileList["test/unit/*_test.rb"
|
10
|
+
t.test_files = FileList["test/unit/*_test.rb"]
|
11
11
|
end
|
12
12
|
|
13
13
|
desc "Run a test against the live API"
|
@@ -15,6 +15,13 @@ namespace :test do
|
|
15
15
|
t.test_files = FileList["test/integration/*_test.rb"]
|
16
16
|
end
|
17
17
|
|
18
|
+
begin
|
19
|
+
require 'rspec/core/rake_task'
|
20
|
+
|
21
|
+
RSpec::Core::RakeTask.new(:spec)
|
22
|
+
|
23
|
+
rescue LoadError
|
24
|
+
end
|
18
25
|
end
|
19
26
|
|
20
|
-
task default: "test:units"
|
27
|
+
task default: ["test:units", "test:spec"]
|
data/lib/raygun.rb
CHANGED
@@ -14,8 +14,10 @@ end
|
|
14
14
|
require "raygun/version"
|
15
15
|
require "raygun/configuration"
|
16
16
|
require "raygun/client"
|
17
|
+
require "raygun/javascript_tracker"
|
17
18
|
require "raygun/middleware/rack_exception_interceptor"
|
18
19
|
require "raygun/middleware/breadcrumbs_store_initializer"
|
20
|
+
require "raygun/middleware/javascript_exception_tracking"
|
19
21
|
require "raygun/testable"
|
20
22
|
require "raygun/error"
|
21
23
|
require "raygun/affected_user"
|
data/lib/raygun/configuration.rb
CHANGED
@@ -25,6 +25,12 @@ module Raygun
|
|
25
25
|
# Your Raygun API Key - this can be found on your dashboard at Raygun.io
|
26
26
|
config_option :api_key
|
27
27
|
|
28
|
+
# Your JS Raygun API Key - Should be different to your api_key, it's best practice to separate your errors between front end and back end.
|
29
|
+
config_option :js_api_key
|
30
|
+
|
31
|
+
# Your JS Raygun API Version, defaults to latest as found on https://raygun.com/raygun-providers/javascript
|
32
|
+
config_option :js_api_version
|
33
|
+
|
28
34
|
# Array of exception classes to ignore
|
29
35
|
config_option :ignore
|
30
36
|
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# Client for injecting JavaScript code for tracking front end exceptions
|
2
|
+
# https://raygun.com/docs/languages/javascript
|
3
|
+
module Raygun
|
4
|
+
class JavaScriptTracker
|
5
|
+
def head_html
|
6
|
+
return unless js_api_key?
|
7
|
+
[
|
8
|
+
'<script type="text/javascript">',
|
9
|
+
'!function(a,b,c,d,e,f,g,h){a.RaygunObject=e,a[e]=a[e]||function(){',
|
10
|
+
'(a[e].o=a[e].o||[]).push(arguments)},f=b.createElement(c),g=b.getElementsByTagName(c)[0],',
|
11
|
+
'f.async=1,f.src=d,g.parentNode.insertBefore(f,g),h=a.onerror,a.onerror=function(b,c,d,f,g){',
|
12
|
+
'h&&h(b,c,d,f,g),g||(g=new Error(b)),a[e].q=a[e].q||[],a[e].q.push({',
|
13
|
+
'e:g})}}(window,document,"script","//cdn.raygun.io/raygun4js/' + js_api_version + 'raygun.min.js","rg4js");',
|
14
|
+
'</script>'
|
15
|
+
].join('').html_safe
|
16
|
+
end
|
17
|
+
|
18
|
+
def body_html
|
19
|
+
return unless js_api_key?
|
20
|
+
[
|
21
|
+
'<script type="text/javascript">',
|
22
|
+
"rg4js('apiKey', '#{js_api_key}');",
|
23
|
+
"rg4js('enableCrashReporting', true);",
|
24
|
+
'</script>'
|
25
|
+
].join('').html_safe
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def js_api_key
|
31
|
+
@js_api_key ||= Raygun.configuration.js_api_key
|
32
|
+
end
|
33
|
+
|
34
|
+
def js_api_version
|
35
|
+
@js_api_version ||= Raygun.configuration.js_api_version ? "#{Raygun.configuration.js_api_version}/" : ''
|
36
|
+
end
|
37
|
+
|
38
|
+
def js_api_key?
|
39
|
+
js_api_key.present?
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Raygun::Middleware
|
2
|
+
class JavascriptExceptionTracking
|
3
|
+
def initialize(app)
|
4
|
+
@app = app
|
5
|
+
end
|
6
|
+
|
7
|
+
def call(env)
|
8
|
+
status, headers, response = @app.call(env)
|
9
|
+
|
10
|
+
# It's a html file, inject our JS
|
11
|
+
if headers['Content-Type'].include?('text/html')
|
12
|
+
response = inject_javascript_to_response(response)
|
13
|
+
end
|
14
|
+
|
15
|
+
[status, headers, response]
|
16
|
+
end
|
17
|
+
|
18
|
+
def inject_javascript_to_response(response)
|
19
|
+
response[0].gsub!('</head>', "#{js_tracker.head_html}</head>")
|
20
|
+
response[0].gsub!('</body>', "#{js_tracker.body_html}</body>")
|
21
|
+
|
22
|
+
response
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
def js_tracker
|
27
|
+
@js_tracker = Raygun::JavaScriptTracker.new
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/raygun/railtie.rb
CHANGED
@@ -19,7 +19,8 @@ class Raygun::Railtie < Rails::Railtie
|
|
19
19
|
raygun_middleware = [
|
20
20
|
Raygun::Middleware::RailsInsertAffectedUser,
|
21
21
|
Raygun::Middleware::RackExceptionInterceptor,
|
22
|
-
Raygun::Middleware::BreadcrumbsStoreInitializer
|
22
|
+
Raygun::Middleware::BreadcrumbsStoreInitializer,
|
23
|
+
Raygun::Middleware::JavascriptExceptionTracking
|
23
24
|
]
|
24
25
|
raygun_middleware = raygun_middleware.map(&:to_s) unless Rails::VERSION::STRING >= "5"
|
25
26
|
raygun_middleware.each do |m|
|
data/lib/raygun/version.rb
CHANGED
data/raygun4ruby.gemspec
CHANGED
@@ -28,11 +28,18 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_development_dependency "bundler", ">= 1.1"
|
29
29
|
spec.add_development_dependency "rake", "~> 11"
|
30
30
|
spec.add_development_dependency "timecop"
|
31
|
-
spec.add_development_dependency "minitest", "~>
|
31
|
+
spec.add_development_dependency "minitest", "~> 5.11"
|
32
32
|
spec.add_development_dependency "redis-namespace", ">= 1.3.1"
|
33
33
|
spec.add_development_dependency "resque"
|
34
34
|
spec.add_development_dependency "sidekiq", [">= 3", "< 3.2.2"]
|
35
35
|
spec.add_development_dependency "mocha"
|
36
36
|
spec.add_development_dependency "pry"
|
37
37
|
spec.add_development_dependency "webmock"
|
38
|
+
|
39
|
+
spec.add_development_dependency 'rails', "= 5.2"
|
40
|
+
spec.add_development_dependency 'sqlite3'
|
41
|
+
spec.add_development_dependency 'capybara'
|
42
|
+
spec.add_development_dependency "rspec-rails"
|
43
|
+
spec.add_development_dependency "launchy"
|
44
|
+
spec.add_development_dependency "simplecov"
|
38
45
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
2.5.1
|
data/spec/dummy/Rakefile
ADDED
File without changes
|
@@ -0,0 +1,15 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require rails-ujs
|
14
|
+
//= require activestorage
|
15
|
+
//= require_tree .
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// Action Cable provides the framework to deal with WebSockets in Rails.
|
2
|
+
// You can generate new channels where WebSocket features live using the `rails generate channel` command.
|
3
|
+
//
|
4
|
+
//= require action_cable
|
5
|
+
//= require_self
|
6
|
+
//= require_tree ./channels
|
7
|
+
|
8
|
+
(function() {
|
9
|
+
this.App || (this.App = {});
|
10
|
+
|
11
|
+
App.cable = ActionCable.createConsumer();
|
12
|
+
|
13
|
+
}).call(this);
|
File without changes
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
{}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</title>
|
5
|
+
<%= csrf_meta_tags %>
|
6
|
+
<%= csp_meta_tag %>
|
7
|
+
|
8
|
+
<%= stylesheet_link_tag 'application', media: 'all' %>
|
9
|
+
<%= javascript_include_tag 'application' %>
|
10
|
+
</head>
|
11
|
+
|
12
|
+
<body>
|
13
|
+
<%= yield %>
|
14
|
+
</body>
|
15
|
+
</html>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= yield %>
|
data/spec/dummy/bin/rake
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'fileutils'
|
3
|
+
include FileUtils
|
4
|
+
|
5
|
+
# path to your application root.
|
6
|
+
APP_ROOT = File.expand_path('..', __dir__)
|
7
|
+
|
8
|
+
def system!(*args)
|
9
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
10
|
+
end
|
11
|
+
|
12
|
+
chdir APP_ROOT do
|
13
|
+
# This script is a starting point to setup your application.
|
14
|
+
# Add necessary setup steps to this file.
|
15
|
+
|
16
|
+
puts '== Installing dependencies =='
|
17
|
+
system! 'gem install bundler --conservative'
|
18
|
+
system('bundle check') || system!('bundle install')
|
19
|
+
|
20
|
+
# Install JavaScript dependencies if using Yarn
|
21
|
+
# system('bin/yarn')
|
22
|
+
|
23
|
+
# puts "\n== Copying sample files =="
|
24
|
+
# unless File.exist?('config/database.yml')
|
25
|
+
# cp 'config/database.yml.sample', 'config/database.yml'
|
26
|
+
# end
|
27
|
+
|
28
|
+
puts "\n== Preparing database =="
|
29
|
+
system! 'bin/rails db:setup'
|
30
|
+
|
31
|
+
puts "\n== Removing old logs and tempfiles =="
|
32
|
+
system! 'bin/rails log:clear tmp:clear'
|
33
|
+
|
34
|
+
puts "\n== Restarting application server =="
|
35
|
+
system! 'bin/rails restart'
|
36
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'fileutils'
|
3
|
+
include FileUtils
|
4
|
+
|
5
|
+
# path to your application root.
|
6
|
+
APP_ROOT = File.expand_path('..', __dir__)
|
7
|
+
|
8
|
+
def system!(*args)
|
9
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
10
|
+
end
|
11
|
+
|
12
|
+
chdir APP_ROOT do
|
13
|
+
# This script is a way to update your development environment automatically.
|
14
|
+
# Add necessary update steps to this file.
|
15
|
+
|
16
|
+
puts '== Installing dependencies =='
|
17
|
+
system! 'gem install bundler --conservative'
|
18
|
+
system('bundle check') || system!('bundle install')
|
19
|
+
|
20
|
+
# Install JavaScript dependencies if using Yarn
|
21
|
+
# system('bin/yarn')
|
22
|
+
|
23
|
+
puts "\n== Updating database =="
|
24
|
+
system! 'bin/rails db:migrate'
|
25
|
+
|
26
|
+
puts "\n== Removing old logs and tempfiles =="
|
27
|
+
system! 'bin/rails log:clear tmp:clear'
|
28
|
+
|
29
|
+
puts "\n== Restarting application server =="
|
30
|
+
system! 'bin/rails restart'
|
31
|
+
end
|