raygun4ruby 3.2.6 → 4.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/tests.yml +48 -0
- data/.gitignore +22 -21
- data/.rspec +1 -1
- data/Appraisals +19 -0
- data/CHANGELOG.md +169 -133
- data/Gemfile +4 -4
- data/LICENSE.txt +22 -22
- data/README.md +424 -420
- data/Rakefile +32 -27
- data/examples/sinatras_raygun.rb +17 -17
- data/gemfiles/rails_6.gemfile +9 -0
- data/gemfiles/rails_7.gemfile +10 -0
- data/gemfiles/rails_7_sidekiq_6.gemfile +10 -0
- data/lib/generators/raygun/install_generator.rb +26 -26
- data/lib/raygun/affected_user.rb +59 -59
- data/lib/raygun/breadcrumbs/breadcrumb.rb +34 -34
- data/lib/raygun/breadcrumbs/store.rb +86 -86
- data/lib/raygun/breadcrumbs.rb +34 -34
- data/lib/raygun/client.rb +313 -308
- data/lib/raygun/configuration.rb +197 -194
- data/lib/raygun/demo_exception.rb +22 -22
- data/lib/raygun/error.rb +10 -10
- data/lib/raygun/error_subscriber.rb +21 -0
- data/lib/raygun/javascript_tracker.rb +42 -42
- data/lib/raygun/middleware/breadcrumbs_store_initializer.rb +19 -19
- data/lib/raygun/middleware/javascript_exception_tracking.rb +40 -32
- data/lib/raygun/middleware/rack_exception_interceptor.rb +18 -18
- data/lib/raygun/middleware/rails_insert_affected_user.rb +26 -26
- data/lib/raygun/railtie.rb +47 -39
- data/lib/raygun/services/apply_whitelist_filter_to_payload.rb +27 -27
- data/lib/raygun/sidekiq.rb +51 -71
- data/lib/raygun/version.rb +3 -3
- data/lib/raygun.rb +197 -179
- data/lib/raygun4ruby.rb +1 -1
- data/lib/resque/failure/raygun.rb +25 -25
- data/lib/tasks/raygun.tasks +7 -7
- data/raygun4ruby.gemspec +43 -45
- data/spec/features/javascript_spec.rb +48 -48
- data/spec/rails_applications/6.1.4/Gemfile +56 -0
- data/spec/{dummy/README.rdoc → rails_applications/6.1.4/README.md} +24 -28
- data/spec/{dummy → rails_applications/6.1.4}/Rakefile +6 -6
- data/spec/rails_applications/6.1.4/app/assets/config/manifest.js +2 -0
- data/spec/{dummy → rails_applications/6.1.4}/app/assets/images/.keep +0 -0
- data/spec/{dummy → rails_applications/6.1.4}/app/assets/stylesheets/application.css +15 -15
- data/spec/rails_applications/6.1.4/app/channels/application_cable/channel.rb +4 -0
- data/spec/rails_applications/6.1.4/app/channels/application_cable/connection.rb +4 -0
- data/spec/rails_applications/6.1.4/app/controllers/application_controller.rb +2 -0
- data/spec/{dummy → rails_applications/6.1.4}/app/controllers/concerns/.keep +0 -0
- data/spec/{dummy → rails_applications/6.1.4}/app/controllers/home_controller.rb +4 -4
- data/spec/{dummy → rails_applications/6.1.4}/app/helpers/application_helper.rb +2 -2
- data/spec/rails_applications/6.1.4/app/javascript/channels/consumer.js +6 -0
- data/spec/rails_applications/6.1.4/app/javascript/channels/index.js +5 -0
- data/spec/rails_applications/6.1.4/app/javascript/packs/application.js +13 -0
- data/spec/rails_applications/6.1.4/app/jobs/application_job.rb +7 -0
- data/spec/rails_applications/6.1.4/app/mailers/application_mailer.rb +4 -0
- data/spec/rails_applications/6.1.4/app/models/application_record.rb +3 -0
- data/spec/{dummy/app/mailers → rails_applications/6.1.4/app/models/concerns}/.keep +0 -0
- data/spec/{dummy → rails_applications/6.1.4}/app/views/home/index.html.erb +3 -3
- data/spec/{dummy → rails_applications/6.1.4}/app/views/home/index.json.erb +1 -1
- data/spec/rails_applications/6.1.4/app/views/layouts/application.html.erb +13 -0
- data/spec/rails_applications/6.1.4/app/views/layouts/mailer.html.erb +13 -0
- data/spec/rails_applications/6.1.4/app/views/layouts/mailer.text.erb +1 -0
- data/spec/rails_applications/6.1.4/bin/rails +5 -0
- data/spec/rails_applications/6.1.4/bin/rake +5 -0
- data/spec/rails_applications/6.1.4/bin/setup +36 -0
- data/spec/rails_applications/6.1.4/bin/spring +14 -0
- data/spec/rails_applications/6.1.4/bin/yarn +17 -0
- data/spec/rails_applications/6.1.4/config/application.rb +22 -0
- data/spec/rails_applications/6.1.4/config/boot.rb +3 -0
- data/spec/rails_applications/6.1.4/config/cable.yml +10 -0
- data/spec/rails_applications/6.1.4/config/credentials.yml.enc +1 -0
- data/spec/{dummy → rails_applications/6.1.4}/config/database.yml +25 -25
- data/spec/{dummy → rails_applications/6.1.4}/config/environment.rb +5 -5
- data/spec/rails_applications/6.1.4/config/environments/development.rb +76 -0
- data/spec/rails_applications/6.1.4/config/environments/production.rb +120 -0
- data/spec/rails_applications/6.1.4/config/environments/test.rb +60 -0
- data/spec/rails_applications/6.1.4/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/rails_applications/6.1.4/config/initializers/assets.rb +14 -0
- data/spec/rails_applications/6.1.4/config/initializers/backtrace_silencers.rb +8 -0
- data/spec/rails_applications/6.1.4/config/initializers/content_security_policy.rb +30 -0
- data/spec/{dummy → rails_applications/6.1.4}/config/initializers/cookies_serializer.rb +5 -3
- data/spec/{dummy → rails_applications/6.1.4}/config/initializers/filter_parameter_logging.rb +6 -4
- data/spec/{dummy → rails_applications/6.1.4}/config/initializers/inflections.rb +16 -16
- data/spec/{dummy → rails_applications/6.1.4}/config/initializers/mime_types.rb +4 -4
- data/spec/rails_applications/6.1.4/config/initializers/permissions_policy.rb +11 -0
- data/spec/{dummy → rails_applications/6.1.4}/config/initializers/wrap_parameters.rb +14 -14
- data/spec/{dummy → rails_applications/6.1.4}/config/locales/en.yml +33 -23
- data/spec/rails_applications/6.1.4/config/master.key +1 -0
- data/spec/rails_applications/6.1.4/config/puma.rb +43 -0
- data/spec/rails_applications/6.1.4/config/routes.rb +4 -0
- data/spec/rails_applications/6.1.4/config/spring.rb +6 -0
- data/spec/rails_applications/6.1.4/config/storage.yml +34 -0
- data/spec/{dummy → rails_applications/6.1.4}/config.ru +6 -4
- data/spec/rails_applications/6.1.4/db/seeds.rb +7 -0
- data/spec/{dummy → rails_applications/6.1.4}/db/test.sqlite3 +0 -0
- data/spec/{dummy/app/models → rails_applications/6.1.4/lib/assets}/.keep +0 -0
- data/spec/{dummy/app/models/concerns → rails_applications/6.1.4/lib/tasks}/.keep +0 -0
- data/spec/rails_applications/6.1.4/package.json +11 -0
- data/spec/{dummy → rails_applications/6.1.4}/public/404.html +67 -67
- data/spec/{dummy → rails_applications/6.1.4}/public/422.html +67 -67
- data/spec/{dummy → rails_applications/6.1.4}/public/500.html +66 -66
- data/spec/{dummy/lib/assets/.keep → rails_applications/6.1.4/public/apple-touch-icon-precomposed.png} +0 -0
- data/spec/{dummy/lib/tasks/.keep → rails_applications/6.1.4/public/apple-touch-icon.png} +0 -0
- data/spec/{dummy → rails_applications/6.1.4}/public/favicon.ico +0 -0
- data/spec/rails_applications/6.1.4/public/robots.txt +1 -0
- data/spec/{dummy/log → rails_applications/6.1.4/storage}/.keep +0 -0
- data/spec/rails_applications/7.1.3/.dockerignore +37 -0
- data/spec/rails_applications/7.1.3/.gitattributes +9 -0
- data/spec/rails_applications/7.1.3/.gitignore +35 -0
- data/spec/rails_applications/7.1.3/.ruby-version +1 -0
- data/spec/rails_applications/7.1.3/Dockerfile +62 -0
- data/spec/rails_applications/7.1.3/Gemfile +67 -0
- data/spec/rails_applications/7.1.3/README.md +24 -0
- data/spec/rails_applications/7.1.3/Rakefile +6 -0
- data/spec/rails_applications/7.1.3/app/assets/config/manifest.js +4 -0
- data/spec/{dummy/test/controllers → rails_applications/7.1.3/app/assets/images}/.keep +0 -0
- data/spec/rails_applications/7.1.3/app/assets/stylesheets/application.css +15 -0
- data/spec/rails_applications/7.1.3/app/channels/application_cable/channel.rb +4 -0
- data/spec/rails_applications/7.1.3/app/channels/application_cable/connection.rb +4 -0
- data/spec/rails_applications/7.1.3/app/controllers/application_controller.rb +2 -0
- data/spec/{dummy/test/fixtures → rails_applications/7.1.3/app/controllers/concerns}/.keep +0 -0
- data/spec/rails_applications/7.1.3/app/controllers/home_controller.rb +2 -0
- data/spec/rails_applications/7.1.3/app/helpers/application_helper.rb +2 -0
- data/spec/rails_applications/7.1.3/app/helpers/home_helper.rb +2 -0
- data/spec/rails_applications/7.1.3/app/javascript/application.js +3 -0
- data/spec/rails_applications/7.1.3/app/javascript/controllers/application.js +9 -0
- data/spec/rails_applications/7.1.3/app/javascript/controllers/hello_controller.js +7 -0
- data/spec/rails_applications/7.1.3/app/javascript/controllers/index.js +11 -0
- data/spec/rails_applications/7.1.3/app/jobs/application_job.rb +7 -0
- data/spec/rails_applications/7.1.3/app/mailers/application_mailer.rb +4 -0
- data/spec/rails_applications/7.1.3/app/models/application_record.rb +3 -0
- data/spec/{dummy/test/helpers → rails_applications/7.1.3/app/models/concerns}/.keep +0 -0
- data/spec/rails_applications/7.1.3/app/views/home/index.html.erb +3 -0
- data/spec/rails_applications/7.1.3/app/views/home/index.json.erb +1 -0
- data/spec/rails_applications/7.1.3/app/views/layouts/application.html.erb +16 -0
- data/spec/rails_applications/7.1.3/app/views/layouts/mailer.html.erb +13 -0
- data/spec/rails_applications/7.1.3/app/views/layouts/mailer.text.erb +1 -0
- data/spec/rails_applications/7.1.3/bin/bundle +109 -0
- data/spec/rails_applications/7.1.3/bin/docker-entrypoint +8 -0
- data/spec/rails_applications/7.1.3/bin/importmap +4 -0
- data/spec/rails_applications/7.1.3/bin/rails +4 -0
- data/spec/rails_applications/7.1.3/bin/rake +4 -0
- data/spec/rails_applications/7.1.3/bin/setup +33 -0
- data/spec/rails_applications/7.1.3/config/application.rb +27 -0
- data/spec/rails_applications/7.1.3/config/boot.rb +4 -0
- data/spec/rails_applications/7.1.3/config/cable.yml +11 -0
- data/spec/rails_applications/7.1.3/config/credentials.yml.enc +1 -0
- data/spec/rails_applications/7.1.3/config/database.yml +25 -0
- data/spec/rails_applications/7.1.3/config/environment.rb +5 -0
- data/spec/rails_applications/7.1.3/config/environments/development.rb +76 -0
- data/spec/rails_applications/7.1.3/config/environments/production.rb +97 -0
- data/spec/rails_applications/7.1.3/config/environments/test.rb +64 -0
- data/spec/rails_applications/7.1.3/config/importmap.rb +7 -0
- data/spec/rails_applications/7.1.3/config/initializers/assets.rb +12 -0
- data/spec/rails_applications/7.1.3/config/initializers/content_security_policy.rb +25 -0
- data/spec/rails_applications/7.1.3/config/initializers/filter_parameter_logging.rb +8 -0
- data/spec/rails_applications/7.1.3/config/initializers/inflections.rb +16 -0
- data/spec/rails_applications/7.1.3/config/initializers/permissions_policy.rb +13 -0
- data/spec/rails_applications/7.1.3/config/locales/en.yml +31 -0
- data/spec/rails_applications/7.1.3/config/puma.rb +35 -0
- data/spec/rails_applications/7.1.3/config/routes.rb +11 -0
- data/spec/rails_applications/7.1.3/config/storage.yml +34 -0
- data/spec/rails_applications/7.1.3/config.ru +6 -0
- data/spec/rails_applications/7.1.3/db/seeds.rb +9 -0
- data/spec/{dummy/test/integration → rails_applications/7.1.3/lib/assets}/.keep +0 -0
- data/spec/{dummy/test/mailers → rails_applications/7.1.3/lib/tasks}/.keep +0 -0
- data/spec/rails_applications/7.1.3/public/404.html +67 -0
- data/spec/rails_applications/7.1.3/public/422.html +67 -0
- data/spec/rails_applications/7.1.3/public/500.html +66 -0
- data/spec/{dummy/test/models/.keep → rails_applications/7.1.3/public/apple-touch-icon-precomposed.png} +0 -0
- data/spec/{dummy/vendor/assets/javascripts/.keep → rails_applications/7.1.3/public/apple-touch-icon.png} +0 -0
- data/spec/{dummy/vendor/assets/stylesheets/.keep → rails_applications/7.1.3/public/favicon.ico} +0 -0
- data/spec/rails_applications/7.1.3/public/robots.txt +1 -0
- data/spec/rails_applications/7.1.3/storage/.keep +0 -0
- data/spec/rails_applications/7.1.3/test/application_system_test_case.rb +5 -0
- data/spec/rails_applications/7.1.3/test/channels/application_cable/connection_test.rb +13 -0
- data/spec/rails_applications/7.1.3/test/controllers/.keep +0 -0
- data/spec/rails_applications/7.1.3/test/controllers/home_controller_test.rb +7 -0
- data/spec/rails_applications/7.1.3/test/fixtures/files/.keep +0 -0
- data/spec/rails_applications/7.1.3/test/helpers/.keep +0 -0
- data/spec/rails_applications/7.1.3/test/integration/.keep +0 -0
- data/spec/rails_applications/7.1.3/test/mailers/.keep +0 -0
- data/spec/rails_applications/7.1.3/test/models/.keep +0 -0
- data/spec/rails_applications/7.1.3/test/system/.keep +0 -0
- data/spec/rails_applications/7.1.3/test/test_helper.rb +15 -0
- data/spec/rails_applications/7.1.3/vendor/.keep +0 -0
- data/spec/rails_applications/7.1.3/vendor/javascript/.keep +0 -0
- data/spec/rails_helper.rb +8 -4
- data/spec/raygun/breadcrumbs/breadcrumb_spec.rb +171 -171
- data/spec/raygun/breadcrumbs/store_spec.rb +170 -170
- data/spec/services/apply_whitelist_filter_to_payload_spec.rb +251 -251
- data/spec/spec_helper.rb +24 -24
- data/spec/support/fake_logger.rb +17 -17
- data/test/integration/client_test.rb +19 -19
- data/test/rails_helper.rb +6 -0
- data/test/test_helper.rb +76 -72
- data/test/unit/affected_user_test.rb +136 -136
- data/test/unit/client_test.rb +812 -812
- data/test/unit/configuration_test.rb +202 -206
- data/test/unit/error_subscriber_test.rb +43 -0
- data/test/unit/raygun_test.rb +106 -25
- data/test/unit/resque_failure_test.rb +27 -24
- data/test/unit/sidekiq_failure_test.rb +42 -32
- metadata +186 -125
- data/.travis.yml +0 -20
- data/spec/dummy/.gitignore +0 -17
- data/spec/dummy/Gemfile +0 -47
- data/spec/dummy/app/assets/config/manifest.js +0 -3
- data/spec/dummy/app/assets/javascripts/application.js +0 -13
- data/spec/dummy/app/controllers/application_controller.rb +0 -5
- data/spec/dummy/app/views/layouts/application.html.erb +0 -14
- data/spec/dummy/bin/bundle +0 -3
- data/spec/dummy/bin/rails +0 -9
- data/spec/dummy/bin/rake +0 -9
- data/spec/dummy/bin/setup +0 -29
- data/spec/dummy/bin/spring +0 -17
- data/spec/dummy/config/application.rb +0 -26
- data/spec/dummy/config/boot.rb +0 -3
- data/spec/dummy/config/environments/development.rb +0 -41
- data/spec/dummy/config/environments/production.rb +0 -79
- data/spec/dummy/config/environments/test.rb +0 -42
- data/spec/dummy/config/initializers/assets.rb +0 -11
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/session_store.rb +0 -3
- data/spec/dummy/config/initializers/to_time_preserves_timezone.rb +0 -10
- data/spec/dummy/config/routes.rb +0 -58
- data/spec/dummy/config/secrets.yml +0 -22
- data/spec/dummy/db/seeds.rb +0 -7
- data/spec/dummy/public/robots.txt +0 -5
- data/spec/dummy/test/test_helper.rb +0 -10
- data/spec/raygun/raygun_spec.rb +0 -47
data/Rakefile
CHANGED
@@ -1,27 +1,32 @@
|
|
1
|
-
|
2
|
-
require "bundler/gem_tasks"
|
3
|
-
|
4
|
-
require "
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
|
1
|
+
require "bundler/setup"
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
|
4
|
+
require "appraisal"
|
5
|
+
require "rake/testtask"
|
6
|
+
|
7
|
+
namespace :test do
|
8
|
+
|
9
|
+
desc "Test the basics of the adapter"
|
10
|
+
Rake::TestTask.new(:units) do |t|
|
11
|
+
t.test_files = FileList["test/unit/*_test.rb"]
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "Run a test against the live API"
|
15
|
+
Rake::TestTask.new(:integration) do |t|
|
16
|
+
t.test_files = FileList["test/integration/*_test.rb"]
|
17
|
+
end
|
18
|
+
|
19
|
+
begin
|
20
|
+
require 'rspec/core/rake_task'
|
21
|
+
|
22
|
+
RSpec::Core::RakeTask.new(:spec)
|
23
|
+
|
24
|
+
rescue LoadError
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
if !ENV["APPRAISAL_INITIALIZED"] && !ENV["CI"]
|
29
|
+
task default: :appraisal
|
30
|
+
else
|
31
|
+
task default: ["test:units", "test:spec"]
|
32
|
+
end
|
data/examples/sinatras_raygun.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
# NB: You'll need to install the 'sinatra' gem for this to work :)
|
2
|
-
# $ gem install sinatra
|
3
|
-
# $ ruby sinatras_raygun.rb
|
4
|
-
|
5
|
-
require 'sinatra'
|
6
|
-
require_relative '../lib/raygun4ruby'
|
7
|
-
|
8
|
-
Raygun.setup do |config|
|
9
|
-
config.api_key = YOUR_RAYGUN_API_KEY_HERE
|
10
|
-
end
|
11
|
-
|
12
|
-
use Raygun::RackExceptionInterceptor
|
13
|
-
|
14
|
-
set :raise_errors, true
|
15
|
-
|
16
|
-
get '/' do
|
17
|
-
raise "This is an exception that will be sent to Raygun!"
|
1
|
+
# NB: You'll need to install the 'sinatra' gem for this to work :)
|
2
|
+
# $ gem install sinatra
|
3
|
+
# $ ruby sinatras_raygun.rb
|
4
|
+
|
5
|
+
require 'sinatra'
|
6
|
+
require_relative '../lib/raygun4ruby'
|
7
|
+
|
8
|
+
Raygun.setup do |config|
|
9
|
+
config.api_key = YOUR_RAYGUN_API_KEY_HERE
|
10
|
+
end
|
11
|
+
|
12
|
+
use Raygun::RackExceptionInterceptor
|
13
|
+
|
14
|
+
set :raise_errors, true
|
15
|
+
|
16
|
+
get '/' do
|
17
|
+
raise "This is an exception that will be sent to Raygun!"
|
18
18
|
end
|
@@ -1,26 +1,26 @@
|
|
1
|
-
module Raygun
|
2
|
-
class InstallGenerator < Rails::Generators::Base
|
3
|
-
|
4
|
-
argument :api_key
|
5
|
-
|
6
|
-
desc "This generator creates a configuration file for the Raygun ruby adapter inside config/initializers"
|
7
|
-
def create_configuration_file
|
8
|
-
filter_parameters = if defined?(Rails)
|
9
|
-
"config.filter_parameters = Rails.application.config.filter_parameters"
|
10
|
-
else
|
11
|
-
"config.filter_parameters = [ :password, :card_number, :cvv ] # don't forget to filter out sensitive parameters"
|
12
|
-
end
|
13
|
-
initializer "raygun.rb" do
|
14
|
-
<<-EOS
|
15
|
-
Raygun.setup do |config|
|
16
|
-
config.api_key = "#{api_key}"
|
17
|
-
#{filter_parameters}
|
18
|
-
|
19
|
-
# The default is Rails.env.production?
|
20
|
-
# config.enable_reporting = !Rails.env.development? && !Rails.env.test?
|
21
|
-
end
|
22
|
-
EOS
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
1
|
+
module Raygun
|
2
|
+
class InstallGenerator < Rails::Generators::Base
|
3
|
+
|
4
|
+
argument :api_key
|
5
|
+
|
6
|
+
desc "This generator creates a configuration file for the Raygun ruby adapter inside config/initializers"
|
7
|
+
def create_configuration_file
|
8
|
+
filter_parameters = if defined?(Rails)
|
9
|
+
"config.filter_parameters = Rails.application.config.filter_parameters"
|
10
|
+
else
|
11
|
+
"config.filter_parameters = [ :password, :card_number, :cvv ] # don't forget to filter out sensitive parameters"
|
12
|
+
end
|
13
|
+
initializer "raygun.rb" do
|
14
|
+
<<-EOS
|
15
|
+
Raygun.setup do |config|
|
16
|
+
config.api_key = "#{api_key}"
|
17
|
+
#{filter_parameters}
|
18
|
+
|
19
|
+
# The default is Rails.env.production?
|
20
|
+
# config.enable_reporting = !Rails.env.development? && !Rails.env.test?
|
21
|
+
end
|
22
|
+
EOS
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/raygun/affected_user.rb
CHANGED
@@ -1,59 +1,59 @@
|
|
1
|
-
module Raygun
|
2
|
-
class AffectedUser
|
3
|
-
|
4
|
-
DEFAULT_MAPPING = {
|
5
|
-
identifier: [ :id, :username ],
|
6
|
-
email: :email,
|
7
|
-
full_name: [ :full_name, :name ],
|
8
|
-
first_name: :first_name,
|
9
|
-
uuid: :uuid
|
10
|
-
}.freeze
|
11
|
-
SUPPORTED_ATTRIBUTES = DEFAULT_MAPPING.keys.freeze
|
12
|
-
NAME_TO_RAYGUN_NAME_MAPPING = {
|
13
|
-
identifier: :identifier,
|
14
|
-
email: :email,
|
15
|
-
full_name: :fullName,
|
16
|
-
first_name: :firstName,
|
17
|
-
uuid: :uuid
|
18
|
-
}.freeze
|
19
|
-
|
20
|
-
class << self
|
21
|
-
def information_hash(user_object)
|
22
|
-
if user_object.nil? || user_object.is_a?(String)
|
23
|
-
handle_anonymous_user(user_object)
|
24
|
-
else
|
25
|
-
handle_known_user(user_object)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def handle_anonymous_user(user_object)
|
32
|
-
result = { isAnonymous: true }
|
33
|
-
result[:identifier] = user_object unless user_object.nil?
|
34
|
-
result
|
35
|
-
end
|
36
|
-
|
37
|
-
def handle_known_user(user_object)
|
38
|
-
SUPPORTED_ATTRIBUTES.reduce({ isAnonymous: false }) do |result, attribute|
|
39
|
-
mapping = Raygun.configuration.affected_user_mapping
|
40
|
-
method = mapping[attribute]
|
41
|
-
|
42
|
-
value = if method.is_a? Proc
|
43
|
-
method.call(user_object)
|
44
|
-
else
|
45
|
-
attributes = Array(method)
|
46
|
-
attribute_to_use = attributes.select do |attr|
|
47
|
-
user_object.respond_to?(attr, true)
|
48
|
-
end.first
|
49
|
-
|
50
|
-
user_object.send(attribute_to_use) unless attribute_to_use == nil
|
51
|
-
end
|
52
|
-
|
53
|
-
result[NAME_TO_RAYGUN_NAME_MAPPING[attribute]] = value unless value == nil
|
54
|
-
result
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
1
|
+
module Raygun
|
2
|
+
class AffectedUser
|
3
|
+
|
4
|
+
DEFAULT_MAPPING = {
|
5
|
+
identifier: [ :id, :username ],
|
6
|
+
email: :email,
|
7
|
+
full_name: [ :full_name, :name ],
|
8
|
+
first_name: :first_name,
|
9
|
+
uuid: :uuid
|
10
|
+
}.freeze
|
11
|
+
SUPPORTED_ATTRIBUTES = DEFAULT_MAPPING.keys.freeze
|
12
|
+
NAME_TO_RAYGUN_NAME_MAPPING = {
|
13
|
+
identifier: :identifier,
|
14
|
+
email: :email,
|
15
|
+
full_name: :fullName,
|
16
|
+
first_name: :firstName,
|
17
|
+
uuid: :uuid
|
18
|
+
}.freeze
|
19
|
+
|
20
|
+
class << self
|
21
|
+
def information_hash(user_object)
|
22
|
+
if user_object.nil? || user_object.is_a?(String)
|
23
|
+
handle_anonymous_user(user_object)
|
24
|
+
else
|
25
|
+
handle_known_user(user_object)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def handle_anonymous_user(user_object)
|
32
|
+
result = { isAnonymous: true }
|
33
|
+
result[:identifier] = user_object unless user_object.nil?
|
34
|
+
result
|
35
|
+
end
|
36
|
+
|
37
|
+
def handle_known_user(user_object)
|
38
|
+
SUPPORTED_ATTRIBUTES.reduce({ isAnonymous: false }) do |result, attribute|
|
39
|
+
mapping = Raygun.configuration.affected_user_mapping
|
40
|
+
method = mapping[attribute]
|
41
|
+
|
42
|
+
value = if method.is_a? Proc
|
43
|
+
method.call(user_object)
|
44
|
+
else
|
45
|
+
attributes = Array(method)
|
46
|
+
attribute_to_use = attributes.select do |attr|
|
47
|
+
user_object.respond_to?(attr, true)
|
48
|
+
end.first
|
49
|
+
|
50
|
+
user_object.send(attribute_to_use) unless attribute_to_use == nil
|
51
|
+
end
|
52
|
+
|
53
|
+
result[NAME_TO_RAYGUN_NAME_MAPPING[attribute]] = value unless value == nil
|
54
|
+
result
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -1,34 +1,34 @@
|
|
1
|
-
module Raygun
|
2
|
-
module Breadcrumbs
|
3
|
-
class Breadcrumb
|
4
|
-
ATTRIBUTES = [
|
5
|
-
:message, :category, :metadata, :class_name,
|
6
|
-
:method_name, :line_number, :timestamp, :level,
|
7
|
-
:type
|
8
|
-
]
|
9
|
-
attr_accessor(*ATTRIBUTES)
|
10
|
-
|
11
|
-
def build_payload
|
12
|
-
payload = {
|
13
|
-
message: message,
|
14
|
-
category: category,
|
15
|
-
level: Breadcrumbs::BREADCRUMB_LEVELS.index(level),
|
16
|
-
CustomData: metadata,
|
17
|
-
timestamp: timestamp,
|
18
|
-
type: type
|
19
|
-
}
|
20
|
-
|
21
|
-
payload[:location] = "#{class_name}:#{method_name}" unless class_name == nil
|
22
|
-
payload[:location] += ":#{line_number}" if payload.has_key?(:location) && line_number != nil
|
23
|
-
|
24
|
-
Hash[payload.select do |k, v|
|
25
|
-
v != nil
|
26
|
-
end]
|
27
|
-
end
|
28
|
-
|
29
|
-
def size
|
30
|
-
return message.length + 100
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
1
|
+
module Raygun
|
2
|
+
module Breadcrumbs
|
3
|
+
class Breadcrumb
|
4
|
+
ATTRIBUTES = [
|
5
|
+
:message, :category, :metadata, :class_name,
|
6
|
+
:method_name, :line_number, :timestamp, :level,
|
7
|
+
:type
|
8
|
+
]
|
9
|
+
attr_accessor(*ATTRIBUTES)
|
10
|
+
|
11
|
+
def build_payload
|
12
|
+
payload = {
|
13
|
+
message: message,
|
14
|
+
category: category,
|
15
|
+
level: Breadcrumbs::BREADCRUMB_LEVELS.index(level),
|
16
|
+
CustomData: metadata,
|
17
|
+
timestamp: timestamp,
|
18
|
+
type: type
|
19
|
+
}
|
20
|
+
|
21
|
+
payload[:location] = "#{class_name}:#{method_name}" unless class_name == nil
|
22
|
+
payload[:location] += ":#{line_number}" if payload.has_key?(:location) && line_number != nil
|
23
|
+
|
24
|
+
Hash[payload.select do |k, v|
|
25
|
+
v != nil
|
26
|
+
end]
|
27
|
+
end
|
28
|
+
|
29
|
+
def size
|
30
|
+
return message.length + 100
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -1,86 +1,86 @@
|
|
1
|
-
require_relative 'breadcrumb'
|
2
|
-
|
3
|
-
module Raygun
|
4
|
-
module Breadcrumbs
|
5
|
-
class Store
|
6
|
-
def self.initialize
|
7
|
-
Thread.current[:breadcrumbs] ||=
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.clear
|
11
|
-
Thread.current[:breadcrumbs] = nil
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.stored
|
15
|
-
Thread.current[:breadcrumbs]
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.record(
|
19
|
-
message: nil,
|
20
|
-
category: '',
|
21
|
-
level: :info,
|
22
|
-
timestamp: Time.now.utc.to_i,
|
23
|
-
metadata: {},
|
24
|
-
class_name: nil,
|
25
|
-
method_name: nil,
|
26
|
-
line_number: nil
|
27
|
-
)
|
28
|
-
raise ArgumentError.new('missing keyword: message') if message == nil
|
29
|
-
crumb = Breadcrumb.new
|
30
|
-
|
31
|
-
crumb.message = message
|
32
|
-
crumb.category = category
|
33
|
-
crumb.level = level
|
34
|
-
crumb.metadata = metadata
|
35
|
-
crumb.timestamp = timestamp
|
36
|
-
crumb.type = 'manual'
|
37
|
-
|
38
|
-
caller = caller_locations[1]
|
39
|
-
crumb.class_name = class_name
|
40
|
-
crumb.method_name = method_name || caller.label
|
41
|
-
crumb.line_number = line_number || caller.lineno
|
42
|
-
|
43
|
-
Thread.current[:breadcrumbs] << crumb if should_record?(crumb)
|
44
|
-
end
|
45
|
-
|
46
|
-
def self.any?
|
47
|
-
stored != nil && stored.length > 0
|
48
|
-
end
|
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
|
-
|
60
|
-
private
|
61
|
-
|
62
|
-
def self.should_record?(crumb)
|
63
|
-
if stored.nil?
|
64
|
-
if Raygun.configuration.debug
|
65
|
-
Raygun.log('[Raygun.breadcrumbs] store is uninitialized while breadcrumb is being recorded, discarding breadcrumb')
|
66
|
-
end
|
67
|
-
|
68
|
-
return false
|
69
|
-
end
|
70
|
-
|
71
|
-
levels = Raygun::Breadcrumbs::BREADCRUMB_LEVELS
|
72
|
-
|
73
|
-
active_level = levels.index(Raygun.configuration.breadcrumb_level)
|
74
|
-
crumb_level = levels.index(crumb.level) || -1
|
75
|
-
|
76
|
-
discard = crumb_level < active_level
|
77
|
-
|
78
|
-
if discard && Raygun.configuration.debug
|
79
|
-
Raygun.log("[Raygun.breadcrumbs] discarding breadcrumb because #{crumb.level} is below active breadcrumb level (#{Raygun.configuration.breadcrumb_level})")
|
80
|
-
end
|
81
|
-
|
82
|
-
!discard
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
1
|
+
require_relative 'breadcrumb'
|
2
|
+
|
3
|
+
module Raygun
|
4
|
+
module Breadcrumbs
|
5
|
+
class Store
|
6
|
+
def self.initialize(with: [])
|
7
|
+
Thread.current[:breadcrumbs] ||= with
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.clear
|
11
|
+
Thread.current[:breadcrumbs] = nil
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.stored
|
15
|
+
Thread.current[:breadcrumbs]
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.record(
|
19
|
+
message: nil,
|
20
|
+
category: '',
|
21
|
+
level: :info,
|
22
|
+
timestamp: Time.now.utc.to_i,
|
23
|
+
metadata: {},
|
24
|
+
class_name: nil,
|
25
|
+
method_name: nil,
|
26
|
+
line_number: nil
|
27
|
+
)
|
28
|
+
raise ArgumentError.new('missing keyword: message') if message == nil
|
29
|
+
crumb = Breadcrumb.new
|
30
|
+
|
31
|
+
crumb.message = message
|
32
|
+
crumb.category = category
|
33
|
+
crumb.level = level
|
34
|
+
crumb.metadata = metadata
|
35
|
+
crumb.timestamp = timestamp
|
36
|
+
crumb.type = 'manual'
|
37
|
+
|
38
|
+
caller = caller_locations[1]
|
39
|
+
crumb.class_name = class_name
|
40
|
+
crumb.method_name = method_name || caller.label
|
41
|
+
crumb.line_number = line_number || caller.lineno
|
42
|
+
|
43
|
+
Thread.current[:breadcrumbs] << crumb if should_record?(crumb)
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.any?
|
47
|
+
stored != nil && stored.length > 0
|
48
|
+
end
|
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
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def self.should_record?(crumb)
|
63
|
+
if stored.nil?
|
64
|
+
if Raygun.configuration.debug
|
65
|
+
Raygun.log('[Raygun.breadcrumbs] store is uninitialized while breadcrumb is being recorded, discarding breadcrumb')
|
66
|
+
end
|
67
|
+
|
68
|
+
return false
|
69
|
+
end
|
70
|
+
|
71
|
+
levels = Raygun::Breadcrumbs::BREADCRUMB_LEVELS
|
72
|
+
|
73
|
+
active_level = levels.index(Raygun.configuration.breadcrumb_level)
|
74
|
+
crumb_level = levels.index(crumb.level) || -1
|
75
|
+
|
76
|
+
discard = crumb_level < active_level
|
77
|
+
|
78
|
+
if discard && Raygun.configuration.debug
|
79
|
+
Raygun.log("[Raygun.breadcrumbs] discarding breadcrumb because #{crumb.level} is below active breadcrumb level (#{Raygun.configuration.breadcrumb_level})")
|
80
|
+
end
|
81
|
+
|
82
|
+
!discard
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
data/lib/raygun/breadcrumbs.rb
CHANGED
@@ -1,34 +1,34 @@
|
|
1
|
-
module Raygun
|
2
|
-
module Breadcrumbs
|
3
|
-
BREADCRUMB_LEVELS = [
|
4
|
-
:debug,
|
5
|
-
:info,
|
6
|
-
:warning,
|
7
|
-
:error,
|
8
|
-
:fatal
|
9
|
-
]
|
10
|
-
|
11
|
-
def record_breadcrumb(
|
12
|
-
message: nil,
|
13
|
-
category: '',
|
14
|
-
level: :info,
|
15
|
-
timestamp: Time.now.utc.to_i,
|
16
|
-
metadata: {},
|
17
|
-
class_name: nil,
|
18
|
-
method_name: nil,
|
19
|
-
line_number: nil
|
20
|
-
)
|
21
|
-
class_name = class_name || self.class.name
|
22
|
-
Raygun::Breadcrumbs::Store.record(
|
23
|
-
message: message,
|
24
|
-
category: category,
|
25
|
-
level: level,
|
26
|
-
timestamp: timestamp,
|
27
|
-
metadata: metadata,
|
28
|
-
class_name: class_name,
|
29
|
-
method_name: method_name,
|
30
|
-
line_number: line_number,
|
31
|
-
)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
1
|
+
module Raygun
|
2
|
+
module Breadcrumbs
|
3
|
+
BREADCRUMB_LEVELS = [
|
4
|
+
:debug,
|
5
|
+
:info,
|
6
|
+
:warning,
|
7
|
+
:error,
|
8
|
+
:fatal
|
9
|
+
]
|
10
|
+
|
11
|
+
def record_breadcrumb(
|
12
|
+
message: nil,
|
13
|
+
category: '',
|
14
|
+
level: :info,
|
15
|
+
timestamp: Time.now.utc.to_i,
|
16
|
+
metadata: {},
|
17
|
+
class_name: nil,
|
18
|
+
method_name: nil,
|
19
|
+
line_number: nil
|
20
|
+
)
|
21
|
+
class_name = class_name || self.class.name
|
22
|
+
Raygun::Breadcrumbs::Store.record(
|
23
|
+
message: message,
|
24
|
+
category: category,
|
25
|
+
level: level,
|
26
|
+
timestamp: timestamp,
|
27
|
+
metadata: metadata,
|
28
|
+
class_name: class_name,
|
29
|
+
method_name: method_name,
|
30
|
+
line_number: line_number,
|
31
|
+
)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|