Class: ExceptionNotifier::TeamsNotifier
- Inherits:
-
BaseNotifier
- Object
- BaseNotifier
- ExceptionNotifier::TeamsNotifier
- Includes:
- BacktraceCleaner
- Defined in:
- lib/exception_notifier/teams_notifier.rb
Defined Under Namespace
Classes: MissingController
Instance Attribute Summary collapse
-
#httparty ⇒ Object
Returns the value of attribute httparty.
Attributes inherited from BaseNotifier
Instance Method Summary collapse
- #call(exception, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ TeamsNotifier
constructor
A new instance of TeamsNotifier.
Methods included from BacktraceCleaner
Methods inherited from BaseNotifier
#_post_callback, #_pre_callback, #send_notice
Constructor Details
#initialize(options = {}) ⇒ TeamsNotifier
Returns a new instance of TeamsNotifier.
17 18 19 20 21 |
# File 'lib/exception_notifier/teams_notifier.rb', line 17 def initialize( = {}) super @default_options = @httparty = HTTParty end |
Instance Attribute Details
#httparty ⇒ Object
Returns the value of attribute httparty.
15 16 17 |
# File 'lib/exception_notifier/teams_notifier.rb', line 15 def httparty @httparty end |
Instance Method Details
#call(exception, options = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/exception_notifier/teams_notifier.rb', line 23 def call(exception, = {}) @options = .merge(@default_options) @exception = exception @backtrace = exception.backtrace ? clean_backtrace(exception) : nil @env = @options.delete(:env) @application_name = @options.delete(:app_name) || rails_app_name @gitlab_url = @options.delete(:git_url) @jira_url = @options.delete(:jira_url) @webhook_url = @options.delete(:webhook_url) raise ArgumentError, "You must provide 'webhook_url' parameter." unless @webhook_url if @env.nil? @controller = @request_items = nil else @controller = @env['action_controller.instance'] || MissingController.new request = ActionDispatch::Request.new(@env) @request_items = { url: request.original_url, http_method: request.method, ip_address: request.remote_ip, parameters: request.filtered_parameters, timestamp: Time.current } if request.session['warden.user.user.key'] current_user = User.find(request.session['warden.user.user.key'][0][0]) @request_items[:current_user] = { id: current_user.id, email: current_user.email } end end payload = @options[:body] = payload.to_json @options[:headers] ||= {} @options[:headers]['Content-Type'] = 'application/json' @options[:debug_output] = $stdout @httparty.post(@webhook_url, @options) end |