appflux_ruby 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: e2e783505b000e326a643061f4ca5ed87711a811
4
- data.tar.gz: 784bbf15113d2dc88b0f9478df27972249631132
2
+ SHA256:
3
+ metadata.gz: 364f9ef0534d86572819348b1df7161b73bfa30f78f0e5e6dde105cf1e33f6b8
4
+ data.tar.gz: 8e12d5ab4484b714d3734efd8a8877466679dc48d3d975016aaec20afc5849ab
5
5
  SHA512:
6
- metadata.gz: 841bce7a30416c02449da7a1da4404fa24eeeead44bf1d0dc44ea7f1ad24af002a9c222e06a241569d29f9d91dbac3b40c19085bfb9db5d6a8714c6b2d5fcf2b
7
- data.tar.gz: 8e2a8f9cc34257eeb7b208b41ecf769d5df6cc300dcd4ed6ebb7efc77fe157ed9c4a85090dcda08302327ab72f0f2d09720ddb24290ce29fab102ee0521330c8
6
+ metadata.gz: da9f36f9cba80d190ba7c36f00fd1c68eddd8df1cd21c8b01ca4837e16ec59e87f0d33357928a89d92d950260ff58aa0fe3a85ecd939aaff9fc8cbc17b6aa7e0
7
+ data.tar.gz: 10c9f6eb057f2559aa2ccd2873dcbc42342a524c49ed3d3b7fb882505558b9c171dda22b9cd2d3382e62851dc59c620e046352d9a7a917120bbe473c4a41eace
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2016 Shubham Gupta
3
+ Copyright (c) 2019 Shubham Gupta
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,43 +1,41 @@
1
1
  # Appflux Ruby
2
-
3
2
  ---
3
+ [![Maintainability](https://api.codeclimate.com/v1/badges/64eff633689a54b902cf/maintainability)](https://codeclimate.com/github/appflux/appflux-ruby/maintainability) [![Gem Version](https://badge.fury.io/rb/appflux_ruby.svg)](https://badge.fury.io/rb/appflux_ruby)
4
4
 
5
- [![Maintainability](https://api.codeclimate.com/v1/badges/64eff633689a54b902cf/maintainability)](https://codeclimate.com/github/appflux/appflux-ruby/maintainability)
6
-
5
+ Appflux is an exception notification library for Rack/Rails application. It is extremely lightweight, easy to setup and always free. Signup on appflux.io, create a project and find your keys to setup your application. The exceptions are delivered to your email as well as can be seen on the dashboard. Appflux also offers a simple and classic messaging platform.
7
6
 
8
- The appflux-ruby gem sends notifications when an exception occurs in your Rack/Rails application. The community edition integrates nicely with your appflux.io dashboard. We also offer an enterprise version that also offers a project communication platform.
7
+ ## Why do we need another exception notification library?
8
+ 1. While [exception_notification](https://github.com/smartinez87/exception_notification) is a good open source library, it is really painful to setup. The notification messages are very verbose and often spam the inbox. And... it does not come with a GUI. Appflux offers a decent simplistic dashboard that most open source solutions lack.
9
+ 2. There are a lot of very good commercial exception notification softwares out there. But they are more focussed on managers, not developers.
9
10
 
10
- ## Features
11
+ ## Some Features
11
12
  1. Automatically reports unhandled exceptions.
12
13
  2. Reports handled exceptions.
13
14
  3. Automagically supports Delayed Job and Sidekiq.
14
- 4. Figures out common information used to debug a Rails application.
15
+ 4. Figures out common information (from commonly used gems) used to debug a Rails application.
15
16
  5. Send custom diagnostic information.
16
- 6. Nicely integrates with your Appflux.io dashboard.
17
-
17
+ 6. Nicely integrates with Appflux.io dashboard.
18
18
 
19
19
  ## Requirements
20
20
  1. Ruby 1.9.3 or greater
21
21
  2. Rails 3.0 or greater, Grape, Sinatra or any other Rack application.
22
22
 
23
-
24
23
  ## Setup
25
- > Appflux is free. Basic error monitoring will always remain free.
24
+ > If you have more than one project, you should first create an organization.
26
25
  1. Sign up on appflux.io.
27
26
  2. Confirm your account and create a project.
28
27
  3. Follow the instructions on the setup page.
29
28
 
30
29
  ## What's more ?
31
30
  Appflux offers an integrated platform to monitor, analyze and discuss your ruby application. You can:
32
- 1. Get notified of exceptions in real-time.
33
- 2. Post messages and discuss issues with other collaborators.
34
- 3. Maintain all project related files in one location.
31
+ 1. Get notified of exceptions.
32
+ 2. Post messages and discuss issues with other collaborators and clients.
33
+ 3. Keeps all project related files.
35
34
 
36
35
  ## What's cookin' ?
37
36
  1. Support for out-of-the-box user behavior analysis for Rails applications.
38
37
  2. Cohort analysis for Rails applications.
39
38
 
40
-
41
39
  ## Help
42
40
  1. hi@appflux.io
43
41
  2. [@_guptashubham](https://twitter.com/_guptashubham)
@@ -10,7 +10,7 @@ module AppfluxRuby
10
10
  ##
11
11
  # @return [ID] Identify the application where to send the notification.
12
12
  # This value *must* be set.
13
- attr_accessor :app_id
13
+ attr_accessor :app_id, :ignored_environments
14
14
 
15
15
  ##
16
16
  # @return [Logger] the default logger used for debug output
@@ -12,19 +12,24 @@ module AppfluxRuby
12
12
  class << self
13
13
 
14
14
  def notify exception, environment = Hash.new
15
- request = build_request(exception, environment)
16
- response = request.run
15
+ if should_report_exception?
16
+ ::Rails.logger.info('Notifying Appflux of this exception.')
17
+ request = build_request(exception, environment)
18
+ response = request.run
17
19
 
18
- unless response.code == 200
19
- if defined?(::Rails)
20
- ::Rails.logger.fatal("[Bugflux-Failed] Failed to notify Bugflux, please check with your configuration in config/initializers/bugflux.rb. Error Code: #{ response.code }")
21
- else
22
- puts "[Bugflux-Failed] Failed to notify Bugflux, please check with your configuration in config/initializers/bugflux.rb. Error Code: #{ response.code }"
20
+ unless response.code == 200
21
+ if defined?(::Rails)
22
+ ::Rails.logger.fatal("[Appflux-Failed] Failed to notify Appflux, please check with your configuration in config/initializers/appflux.rb. Error Code: #{ response.code }")
23
+ else
24
+ puts "[Appflux-Failed] Failed to notify Appflux, please check with your configuration in config/initializers/appflux.rb. Error Code: #{ response.code }"
25
+ end
23
26
  end
27
+ else
28
+ ::Rails.logger.info("[Appflux] Skipping to notify Appflux for #{ ::Rails.env } environment.")
24
29
  end
25
30
  end
26
31
 
27
- def build_request exception, environment
32
+ private def build_request exception, environment
28
33
  notice = ::AppfluxRuby::MessageBuilders::Bugflux.new(exception, environment).build
29
34
  request = ::Typhoeus::Request.new(
30
35
  ::AppfluxRuby::Bugflux.config.host,
@@ -33,6 +38,10 @@ module AppfluxRuby
33
38
  headers: { Accept: "application/json" }
34
39
  )
35
40
  end
41
+
42
+ private def should_report_exception?
43
+ !AppfluxRuby::Bugflux.config.ignored_environments.include?(::Rails.env)
44
+ end
36
45
  end
37
46
  end
38
47
  end
@@ -16,7 +16,6 @@ module AppfluxRuby
16
16
  if job.payload_object.respond_to?(:job_data)
17
17
  params[:active_job] = job.payload_object.job_data
18
18
  end
19
- puts 'Sending exception notification to bugflux.'
20
19
  ::AppfluxRuby::BugfluxNotifier.notify(exception, params)
21
20
  raise exception
22
21
  end
@@ -44,7 +44,7 @@ module AppfluxRuby
44
44
 
45
45
  ENV_EXCEPTION_METHODS = %i( backtrace message cause class )
46
46
 
47
- SUPPORTED_BACKGROUND_JOB_PROCESSORS = %w(delayed_job)
47
+ SUPPORTED_BACKGROUND_JOB_PROCESSORS = %w(delayed_job sidekiq)
48
48
 
49
49
  def initialize exception, rack_env
50
50
  super(exception, rack_env)
@@ -130,7 +130,7 @@ module AppfluxRuby
130
130
  ## Adds background processor information as a dedicated tab on the UI.
131
131
  def add_background_job_info
132
132
  if @rack_env[:component].in?(SUPPORTED_BACKGROUND_JOB_PROCESSORS)
133
- builder_klass_string = @rack_env[:component].classify#.constantize
133
+ builder_klass_string = @rack_env[:component].classify
134
134
  builder_klass = "::AppfluxRuby::MessageBuilders::#{ builder_klass_string }".constantize
135
135
 
136
136
  @bugflux_notice[:custom_tabs] ||= Hash.new
@@ -0,0 +1,18 @@
1
+ module AppfluxRuby
2
+ module MessageBuilders
3
+ class Sidekiq
4
+
5
+ def initialize options
6
+ @options = options
7
+ end
8
+
9
+ def to_hash
10
+ @options
11
+ end
12
+
13
+ def self.to_hash options
14
+ new(options).to_hash
15
+ end
16
+ end
17
+ end
18
+ end
@@ -13,7 +13,6 @@ module AppfluxRuby
13
13
  response = @app.call(env)
14
14
  rescue Exception => ex
15
15
  # TODO: Need to figure out a logger implementation.
16
- puts 'Sending exception notification to bugflux.'
17
16
  ::AppfluxRuby::BugfluxNotifier.notify(ex, env)
18
17
  raise ex
19
18
  end
@@ -27,7 +27,6 @@ module AppfluxRuby
27
27
  super
28
28
  rescue Exception => ex
29
29
  # TODO: Need to replace with Logger.
30
- puts 'Sending exception notification to bugflux.'
31
30
  ::AppfluxRuby::BugfluxNotifier.notify(ex)
32
31
  raise ex
33
32
  end
@@ -10,7 +10,6 @@ module AppfluxRuby
10
10
  module ClassMethods
11
11
  def before_bugflux_notify(*methods)
12
12
  run_bugflux_callbacks(methods) do
13
-
14
13
  end
15
14
  end
16
15
 
@@ -34,9 +33,7 @@ module AppfluxRuby
34
33
  end
35
34
  end
36
35
  end
37
-
38
36
  end
39
-
40
37
  end
41
38
 
42
39
  module InstanceMethods
@@ -44,8 +41,11 @@ module AppfluxRuby
44
41
  def __send_user_info_to_bugflux__ notifier_object
45
42
  if respond_to?(:current_user) && current_user
46
43
  notifier_object.add_tab('User',
47
- { 'Current User Id': current_user.id,
48
- 'User Attributes': current_user.inspect
44
+ {
45
+ id: current_user.id,
46
+ type: current_user.class.name,
47
+ name: current_user.try(:name),
48
+ email: current_user.try(:email)
49
49
  }
50
50
  )
51
51
  end
@@ -0,0 +1,21 @@
1
+ module AppfluxRuby
2
+ module Sidekiq
3
+ class ErrorHandler
4
+ def call(_worker, context, _queue)
5
+ yield
6
+ rescue Exception => exception
7
+ ::AppfluxRuby::Bugflux.initialize_additional_data
8
+ params = {
9
+ component: 'sidekiq',
10
+ args: context['args'],
11
+ queue: context['queue'],
12
+ message: context['error_message'],
13
+ options: context.except('args', 'queue', 'error_message')
14
+ }
15
+
16
+ ::AppfluxRuby::BugfluxNotifier.notify(exception, params)
17
+ raise exception
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,3 +1,3 @@
1
1
  module AppfluxRuby
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
@@ -0,0 +1,23 @@
1
+ AppfluxRuby::Bugflux.configure do |config|
2
+ config.app_id = '<your-app-id>'
3
+ config.ignored_environments = %w( test development )
4
+ end
5
+
6
+ if defined?(::Delayed)
7
+ require 'appflux_ruby/delayed/plugin'
8
+ require 'appflux_ruby/message_builders/delayed_job'
9
+
10
+ Delayed::Worker.plugins << ::AppfluxRuby::Delayed::Plugin
11
+ end
12
+
13
+ if defined?(::Sidekiq)
14
+ require 'appflux_ruby/sidekiq/error_handler'
15
+ require 'appflux_ruby/message_builders/sidekiq'
16
+
17
+ Sidekiq.configure_server do |config|
18
+ config.server_middleware do |chain|
19
+ chain.add(AppfluxRuby::Sidekiq::ErrorHandler)
20
+ end
21
+ end
22
+
23
+ end
@@ -3,7 +3,7 @@ module AppfluxRuby
3
3
  source_root File.expand_path("../", __FILE__)
4
4
 
5
5
  def create_bugflux_initializer
6
- copy_file 'bugflux.rb', 'config/initializers/bugflux.rb'
6
+ copy_file 'appflux.rb', 'config/initializers/appflux.rb'
7
7
  end
8
8
 
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appflux_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shubham Gupta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-01 00:00:00.000000000 Z
11
+ date: 2019-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus
@@ -71,12 +71,14 @@ files:
71
71
  - lib/appflux_ruby/message_builders/bugflux.rb
72
72
  - lib/appflux_ruby/message_builders/custom_message.rb
73
73
  - lib/appflux_ruby/message_builders/delayed_job.rb
74
+ - lib/appflux_ruby/message_builders/sidekiq.rb
74
75
  - lib/appflux_ruby/rack/middleware.rb
75
76
  - lib/appflux_ruby/rails/active_record.rb
76
77
  - lib/appflux_ruby/rails/controller_methods.rb
77
78
  - lib/appflux_ruby/rails/railtie.rb
79
+ - lib/appflux_ruby/sidekiq/error_handler.rb
78
80
  - lib/appflux_ruby/version.rb
79
- - lib/generators/appflux_ruby/bugflux.rb
81
+ - lib/generators/appflux_ruby/appflux.rb
80
82
  - lib/generators/appflux_ruby/install_generator.rb
81
83
  - test/appflux-ruby_test.rb
82
84
  - test/test_helper.rb
@@ -99,8 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
101
  - !ruby/object:Gem::Version
100
102
  version: '0'
101
103
  requirements: []
102
- rubyforge_project:
103
- rubygems_version: 2.2.2
104
+ rubygems_version: 3.0.3
104
105
  signing_key:
105
106
  specification_version: 4
106
107
  summary: Ruby library for integration with http://appflux.io
@@ -1,10 +0,0 @@
1
- AppfluxRuby::Bugflux.configure do |config|
2
- config.app_id = '<your-app-id>'
3
- end
4
-
5
- if defined?(::Delayed)
6
- require 'appflux_ruby/delayed/plugin'
7
- require 'appflux_ruby/message_builders/delayed_job'
8
-
9
- Delayed::Worker.plugins << ::AppfluxRuby::Delayed::Plugin
10
- end