bugsnag 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.1
@@ -0,0 +1,81 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "bugsnag"
8
+ s.version = "1.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["James Smith"]
12
+ s.date = "2012-01-15"
13
+ s.description = "Ruby notifier for bugsnag.com"
14
+ s.email = "james@bugsnag.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE.txt",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "bugsnag.gemspec",
28
+ "lib/bugsnag.rb",
29
+ "lib/bugsnag/configuration.rb",
30
+ "lib/bugsnag/helpers.rb",
31
+ "lib/bugsnag/notification.rb",
32
+ "lib/bugsnag/rack.rb",
33
+ "lib/bugsnag/rails.rb",
34
+ "lib/bugsnag/rails/action_controller_rescue.rb",
35
+ "lib/bugsnag/rails/controller_methods.rb",
36
+ "lib/bugsnag/railtie.rb",
37
+ "lib/bugsnag/version.rb",
38
+ "rails/init.rb",
39
+ "test/helper.rb",
40
+ "test/test_bugsnag.rb"
41
+ ]
42
+ s.homepage = "http://github.com/bugsnag/bugsnag-ruby"
43
+ s.licenses = ["MIT"]
44
+ s.require_paths = ["lib"]
45
+ s.rubygems_version = "1.8.10"
46
+ s.summary = "Ruby notifier for bugsnag.com"
47
+
48
+ if s.respond_to? :specification_version then
49
+ s.specification_version = 3
50
+
51
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
52
+ s.add_runtime_dependency(%q<multi_json>, [">= 0"])
53
+ s.add_runtime_dependency(%q<httparty>, [">= 0"])
54
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
55
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
56
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
57
+ s.add_development_dependency(%q<rcov>, [">= 0"])
58
+ s.add_runtime_dependency(%q<multi_json>, [">= 0"])
59
+ s.add_runtime_dependency(%q<httparty>, [">= 0"])
60
+ else
61
+ s.add_dependency(%q<multi_json>, [">= 0"])
62
+ s.add_dependency(%q<httparty>, [">= 0"])
63
+ s.add_dependency(%q<shoulda>, [">= 0"])
64
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
65
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
66
+ s.add_dependency(%q<rcov>, [">= 0"])
67
+ s.add_dependency(%q<multi_json>, [">= 0"])
68
+ s.add_dependency(%q<httparty>, [">= 0"])
69
+ end
70
+ else
71
+ s.add_dependency(%q<multi_json>, [">= 0"])
72
+ s.add_dependency(%q<httparty>, [">= 0"])
73
+ s.add_dependency(%q<shoulda>, [">= 0"])
74
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
75
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
76
+ s.add_dependency(%q<rcov>, [">= 0"])
77
+ s.add_dependency(%q<multi_json>, [">= 0"])
78
+ s.add_dependency(%q<httparty>, [">= 0"])
79
+ end
80
+ end
81
+
@@ -1,17 +1,9 @@
1
1
  require "rubygems"
2
2
 
3
- # begin
4
- # require "active_support"
5
- # require "active_support/core_ext"
6
- # rescue LoadError
7
- # require "activesupport"
8
- # require "activesupport/core_ext"
9
- # end
10
-
11
- require "bugsnag/configuration"
12
- require "bugsnag/event"
13
- require "bugsnag/notifier"
14
3
  require "bugsnag/version"
4
+ require "bugsnag/configuration"
5
+ require "bugsnag/notification"
6
+ require "bugsnag/helpers"
15
7
 
16
8
  require "bugsnag/rack"
17
9
  require "bugsnag/railtie" if defined?(Rails::Railtie)
@@ -20,30 +12,29 @@ module Bugsnag
20
12
  LOG_PREFIX = "** [Bugsnag] "
21
13
 
22
14
  class << self
23
- attr_accessor :notifier
24
-
25
15
  def configure
26
- yield(configuration)
27
- self.notifier = Notifier.new(configuration)
28
-
29
- log "Bugsnag exception handler #{VERSION} ready, #{configuration.to_hash.inspect}"
16
+ yield(configuration)
17
+ log "Bugsnag exception handler #{VERSION} ready, api_key=#{configuration.api_key}" if configuration.api_key
30
18
  end
31
19
 
32
- def notify(exception)
33
- notifier.notify(exception)
20
+ def notify(exception, session_data={})
21
+ opts = {
22
+ :releaseStage => configuration.release_stage,
23
+ :projectRoot => configuration.project_root.to_s,
24
+ :appVersion => configuration.app_version
25
+ }.merge(session_data)
26
+
27
+ # Send the notification
28
+ notification = Notification.new(configuration.api_key, exception, opts)
29
+ notification.deliver
34
30
  end
35
31
 
36
32
  def log(message)
37
- logger.info(LOG_PREFIX + message) if logger
33
+ configuration.logger.info(LOG_PREFIX + message) if configuration.logger
38
34
  end
39
35
 
40
- private
41
36
  def configuration
42
37
  @configuration ||= Bugsnag::Configuration.new
43
38
  end
44
-
45
- def logger
46
- configuration.logger
47
- end
48
39
  end
49
40
  end
@@ -1,18 +1,5 @@
1
1
  module Bugsnag
2
2
  class Configuration
3
- @@options = :api_key, :release_stage, :endpoint, :project_root, :logger
4
- @@options.each do |attribute|
5
- attr_accessor attribute
6
- end
7
-
8
- def initialize
9
- @endpoint = "http://api.bugsnag.com/notify"
10
- end
11
-
12
- def to_hash
13
- @@options.inject({}) do |hash, option|
14
- hash.merge(option.to_sym => send(option))
15
- end
16
- end
3
+ attr_accessor :api_key, :release_stage, :project_root, :app_version, :framework, :endpoint, :logger, :disable_auto_notification
17
4
  end
18
5
  end
@@ -0,0 +1,26 @@
1
+ module Bugsnag
2
+ module Helpers
3
+ def self.cleanup_hash(hash)
4
+ hash.inject({}) do |h, (k, v)|
5
+ h[k.gsub(/\./, "-")] = v.to_s
6
+ h
7
+ end
8
+ end
9
+
10
+ def self.apply_filters(hash, filters)
11
+ if filters
12
+ hash.each do |k, v|
13
+ if filters.any? {|f| k.to_s.include?(f.to_s) }
14
+ hash[k] = "[FILTERED]"
15
+ elsif v.respond_to?(:to_hash)
16
+ apply_filters(hash[k])
17
+ end
18
+ end
19
+ end
20
+ end
21
+
22
+ def self.param_context(params)
23
+ "#{params[:controller]}##{params[:action]}"
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,97 @@
1
+ require "httparty"
2
+ require "multi_json"
3
+
4
+ module Bugsnag
5
+ class Notification
6
+ DEFAULT_ENDPOINT = "http://api.bugsnag.com/notify"
7
+
8
+ NOTIFIER_NAME = "Ruby Bugsnag Notifier"
9
+ NOTIFIER_VERSION = Bugsnag::VERSION
10
+ NOTIFIER_URL = "http://www.bugsnag.com"
11
+
12
+ include HTTParty
13
+ headers "Content-Type" => "application/json"
14
+
15
+ attr_accessor :apiKey, :exception, :endpoint,
16
+ :appVersion, :releaseStage, :projectRoot,
17
+ :userId, :context, :metaData
18
+
19
+ def initialize(api_key, exception, opts={})
20
+ self.apiKey = api_key
21
+ self.exception = exception
22
+ self.endpoint = DEFAULT_ENDPOINT
23
+
24
+ opts.reject! {|k,v| v.nil?}.each {|k,v| self.send("#{k}=", v)}
25
+ end
26
+
27
+ def deliver
28
+ Bugsnag.log("Notifying #{self.endpoint} of exception")
29
+
30
+ payload = {
31
+ :apiKey => self.apiKey,
32
+ :notifier => notifier_identification,
33
+ :errors => [{
34
+ :userId => self.userId,
35
+ :appVersion => self.appVersion,
36
+ :releaseStage => self.releaseStage,
37
+ :context => self.context,
38
+ :exceptions => [exception_hash],
39
+ :metaData => self.metaData
40
+ }.reject {|k,v| v.nil? }]
41
+ }
42
+
43
+ begin
44
+ response = self.class.post(self.endpoint, {:body => MultiJson.encode(payload)})
45
+ rescue Exception => e
46
+ Bugsnag.log("Notification to #{self.endpoint} failed, #{e.inspect}")
47
+ end
48
+
49
+ return response
50
+ end
51
+
52
+
53
+ private
54
+ def notifier_identification
55
+ unless @notifier
56
+ @notifier = {
57
+ :name => NOTIFIER_NAME,
58
+ :version => NOTIFIER_VERSION,
59
+ :url => NOTIFIER_URL
60
+ }
61
+ end
62
+
63
+ @notifier
64
+ end
65
+
66
+ def stacktrace_hash
67
+ return [] unless self.exception.backtrace
68
+ self.exception.backtrace.map do |trace|
69
+ method = nil
70
+ file, line_str, method_str = trace.split(":")
71
+
72
+ trace_hash = {
73
+ :file => file,
74
+ :lineNumber => line_str.to_i
75
+ }
76
+
77
+ if method_str
78
+ method_match = /in `([^']+)'/.match(method_str)
79
+ method = method_match.captures.first if method_match
80
+ end
81
+
82
+ trace_hash[:method] = method if method
83
+ trace_hash[:inProject] = true if self.projectRoot && file.match(/^#{self.projectRoot}/)
84
+
85
+ trace_hash
86
+ end
87
+ end
88
+
89
+ def exception_hash
90
+ {
91
+ :errorClass => self.exception.class.to_s,
92
+ :message => self.exception.message,
93
+ :stacktrace => stacktrace_hash
94
+ }
95
+ end
96
+ end
97
+ end
@@ -8,15 +8,43 @@ module Bugsnag
8
8
  begin
9
9
  response = @app.call(env)
10
10
  rescue Exception => raised
11
- Bugsnag.notify(raised)
11
+ error_id = Bugsnag.notify(raised, bugsnag_request_data(env))
12
12
  raise
13
13
  end
14
14
 
15
- if env["rack.exception"]
16
- Bugsnag.notify(env["rack.exception"])
15
+ if env['rack.exception']
16
+ error_id = Bugsnag.notify(env['rack.exception'], bugsnag_request_data(env))
17
17
  end
18
18
 
19
19
  response
20
20
  end
21
+
22
+ private
23
+ def bugsnag_request_data(env)
24
+ request = ::Rack::Request.new(env)
25
+
26
+ session = env['rack.session'] || {}
27
+ params = env['action_dispatch.request.parameters'] || request.params || {}
28
+
29
+ {
30
+ :userId => session[:session_id] || session["session_id"],
31
+ :context => Bugsnag::Helpers.param_context(params),
32
+ :metaData => {
33
+ :request => {
34
+ :url => request.url,
35
+ :controller => params[:controller],
36
+ :action => params[:action],
37
+ :params => bugsnag_filter_if_filtering(env, Bugsnag::Helpers.cleanup_hash(params.to_hash)),
38
+ },
39
+ :session => bugsnag_filter_if_filtering(env, Bugsnag::Helpers.cleanup_hash(session)),
40
+ :environment => bugsnag_filter_if_filtering(env, Bugsnag::Helpers.cleanup_hash(env))
41
+ }
42
+ }
43
+ end
44
+
45
+ def bugsnag_filter_if_filtering(env, hash)
46
+ @params_filters ||= env["action_dispatch.parameter_filter"]
47
+ Bugsnag::Helpers.apply_filters(hash, @params_filters)
48
+ end
21
49
  end
22
- end
50
+ end
@@ -1,4 +1,7 @@
1
+ # Rails 2.x support
2
+
1
3
  require "bugsnag"
4
+ require "bugsnag/rails/controller_methods"
2
5
  require "bugsnag/rails/action_controller_rescue"
3
6
 
4
7
  module Bugsnag
@@ -6,12 +9,22 @@ module Bugsnag
6
9
  def self.initialize
7
10
  if defined?(ActionController::Base)
8
11
  ActionController::Base.send(:include, Bugsnag::Rails::ActionControllerRescue)
12
+ ActionController::Base.send(:include, Bugsnag::Rails::ControllerMethods)
13
+ end
14
+
15
+ # Try to find where to log to
16
+ rails_logger = nil
17
+ if defined?(::Rails.logger)
18
+ rails_logger = ::Rails.logger
19
+ elsif defined?(RAILS_DEFAULT_LOGGER)
20
+ rails_logger = RAILS_DEFAULT_LOGGER
9
21
  end
10
22
 
11
- Bugsnag.configure(true) do |config|
23
+ Bugsnag.configure do |config|
12
24
  config.logger = rails_logger
13
- config.environment_name = RAILS_ENV if defined?(RAILS_ENV)
25
+ config.release_stage = RAILS_ENV if defined?(RAILS_ENV)
14
26
  config.project_root = RAILS_ROOT if defined?(RAILS_ROOT)
27
+ config.framework = "Rails: #{::Rails::VERSION::STRING}" if defined?(::Rails::VERSION)
15
28
  end
16
29
  end
17
30
  end
@@ -4,12 +4,24 @@ module Bugsnag
4
4
  def self.included(base)
5
5
  base.send(:alias_method, :rescue_action_in_public_without_bugsnag, :rescue_action_in_public)
6
6
  base.send(:alias_method, :rescue_action_in_public, :rescue_action_in_public_with_bugsnag)
7
+
8
+ base.send(:alias_method, :rescue_action_locally_without_bugsnag, :rescue_action_locally)
9
+ base.send(:alias_method, :rescue_action_locally, :rescue_action_locally_with_bugsnag)
7
10
  end
8
11
 
9
12
  private
10
13
  def rescue_action_in_public_with_bugsnag(exception)
11
- Bugsnag.notify(exception)
12
- rescue_action_in_public_without_scepter(exception)
14
+ auto_notify(exception) unless Bugsnag.configuration.disable_auto_notification
15
+ rescue_action_in_public_without_bugsnag(exception)
16
+ end
17
+
18
+ def rescue_action_locally_with_bugsnag(exception)
19
+ auto_notify(exception) unless Bugsnag.configuration.disable_auto_notification
20
+ rescue_action_locally_without_bugsnag(exception)
21
+ end
22
+
23
+ def auto_notify(exception)
24
+ notify_bugsnag(exception)
13
25
  end
14
26
  end
15
27
  end
@@ -1,7 +1,78 @@
1
1
  module Bugsnag
2
2
  module Rails
3
3
  module ControllerMethods
4
- # TODO
4
+ private
5
+ def notify_bugsnag(exception, custom_data=nil)
6
+ unless bugsnag_local_request?
7
+ request_data = bugsnag_request_data
8
+ request_data[:metaData][:custom] = custom_data if custom_data
9
+ Bugsnag.notify(exception, request_data)
10
+ end
11
+ end
12
+
13
+ def bugsnag_request_data
14
+ {
15
+ :userId => bugsnag_session_id,
16
+ :context => Bugsnag::Helpers.param_context(params),
17
+ :metaData => {
18
+ :request => {
19
+ :url => bugsnag_request_url,
20
+ :controller => params[:controller],
21
+ :action => params[:action],
22
+ :params => bugsnag_filter_if_filtering(params.to_hash),
23
+ },
24
+ :session => bugsnag_filter_if_filtering(bugsnag_session_data),
25
+ :environment => bugsnag_filter_if_filtering(Bugsnag::Helpers.cleanup_hash(request.env))
26
+ }
27
+ }
28
+ end
29
+
30
+ def bugsnag_local_request?
31
+ if defined?(::Rails.application.config)
32
+ ::Rails.application.config.consider_all_requests_local || request.local?
33
+ else
34
+ consider_all_requests_local || local_request?
35
+ end
36
+ end
37
+
38
+ def bugsnag_session_id
39
+ session = bugsnag_session_data
40
+ session[:session_id] || session["session_id"]
41
+ end
42
+
43
+ def bugsnag_context
44
+ "#{params[:controller]}##{params[:action]}"
45
+ end
46
+
47
+ def bugsnag_request_url
48
+ url = "#{request.protocol}#{request.host}"
49
+
50
+ unless [80, 443].include?(request.port)
51
+ url << ":#{request.port}"
52
+ end
53
+
54
+ url << request.fullpath
55
+ url
56
+ end
57
+
58
+ def bugsnag_session_data
59
+ if session.respond_to?(:to_hash)
60
+ session.to_hash
61
+ else
62
+ session.data
63
+ end
64
+ end
65
+
66
+ def bugsnag_filter_if_filtering(hash)
67
+ return hash if ! hash.is_a?(Hash)
68
+
69
+ if respond_to?(:filter_parameters)
70
+ filter_parameters(hash) rescue hash
71
+ else
72
+ hash
73
+ end
74
+ end
75
+
5
76
  end
6
77
  end
7
78
  end
@@ -1,3 +1,5 @@
1
+ # Rails 3.x support
2
+
1
3
  require "bugsnag"
2
4
  require "rails"
3
5
 
@@ -13,9 +15,10 @@ module Bugsnag
13
15
 
14
16
  config.after_initialize do
15
17
  Bugsnag.configure do |config|
16
- config.logger ||= Rails.logger
18
+ config.logger ||= Rails.logger
17
19
  config.release_stage ||= Rails.env
18
- config.project_root ||= Rails.root
20
+ config.project_root ||= Rails.root
21
+ config.framework = "Rails: #{::Rails::VERSION::STRING}"
19
22
  end
20
23
 
21
24
  if defined?(::ActionController::Base)
@@ -1 +1,3 @@
1
+ # On Rails 2.x GEM_ROOT/rails/init.rb is auto loaded for all gems
2
+ # so this is the place to initialize Rails 2.x plugin support
1
3
  require "bugsnag/rails"
@@ -1,29 +1,22 @@
1
1
  require 'helper'
2
2
 
3
+ class BugsnagTestException < RuntimeError; end
4
+
3
5
  class TestBugsnag < Test::Unit::TestCase
4
- should "get a 200 response from bugsnag.com for basic exceptions" do
5
- flunk "oh my" if lets.code != 200
6
- end
7
-
8
- private
9
- def lets
6
+ should "get a 200 response from bugsnag for exceptions" do
7
+ Bugsnag.configure do |config|
8
+ config.api_key = "a799e9c27c3fb3017e4a556fd815317e"
9
+ config.endpoint = "http://localhost:8000/notify"
10
+ config.release_stage = "production"
11
+ config.project_root = File.dirname(__FILE__)
12
+ config.user_id = "static_user_id"
13
+ end
14
+
10
15
  begin
11
- go
16
+ raise BugsnagTestException.new("Exception test from bugsnag gem")
12
17
  rescue Exception => e
13
- event = Bugsnag::Event.new(e, "12345", {:app_environment => {:releaseStage => "production"}})
14
-
15
- # Bugsnag::Notifier.set_endpoint("http://localhost:8000")
16
- # Bugsnag::Notifier.notify("145260904aa22d52bf2a82076d157c38", event)
17
-
18
- return Bugsnag::Notifier.notify("d6db01214d22ac808ce6afdfa4c3f148", event)
18
+ response = Bugsnag.notify(e)
19
+ flunk "oh my" if response.code != 200
19
20
  end
20
21
  end
21
-
22
- def go
23
- deep
24
- end
25
-
26
- def deep
27
- raise RuntimeError.new("Stuff happens")
28
- end
29
22
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bugsnag
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 0
10
- version: 1.0.0
9
+ - 1
10
+ version: 1.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - James Smith
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-10-10 00:00:00 Z
18
+ date: 2012-01-15 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  prerelease: false
@@ -150,10 +150,11 @@ files:
150
150
  - README.rdoc
151
151
  - Rakefile
152
152
  - VERSION
153
+ - bugsnag.gemspec
153
154
  - lib/bugsnag.rb
154
155
  - lib/bugsnag/configuration.rb
155
- - lib/bugsnag/event.rb
156
- - lib/bugsnag/notifier.rb
156
+ - lib/bugsnag/helpers.rb
157
+ - lib/bugsnag/notification.rb
157
158
  - lib/bugsnag/rack.rb
158
159
  - lib/bugsnag/rails.rb
159
160
  - lib/bugsnag/rails/action_controller_rescue.rb
@@ -1,71 +0,0 @@
1
- require "multi_json"
2
-
3
- module Bugsnag
4
- class Event
5
- attr_accessor :exception, :user_id, :app_environment, :web_environment, :meta_data
6
-
7
- def initialize(exception, user_id, env={})
8
- self.exception = exception
9
- self.user_id = user_id
10
- self.app_environment = env[:app_environment]
11
- self.web_environment = env[:web_environment]
12
- self.meta_data = env[:meta_data]
13
- end
14
-
15
- def error_class
16
- exception.class.to_s
17
- end
18
-
19
- def message
20
- exception.message
21
- end
22
-
23
- def stacktrace(project_path=nil)
24
- return @stacktrace if @stacktrace
25
-
26
- if exception.backtrace
27
- @stacktrace = exception.backtrace.map do |trace|
28
- method = nil
29
- file, line, method_str = trace.split(":")
30
-
31
- trace_hash = {
32
- :file => file,
33
- :lineNumber => line
34
- }
35
-
36
- if method_str
37
- method_match = /in `([^']+)'/.match(method_str)
38
- method = method_match.captures.first if method_match
39
- end
40
-
41
- trace_hash[:method] = method if method
42
- trace_hash[:inProject] = true if project_path && file.match(/^#{project_path}/)
43
-
44
- trace_hash
45
- end
46
- else
47
- @stacktrace = []
48
- end
49
-
50
- @stacktrace
51
- end
52
-
53
- def as_hash
54
- {
55
- :userId => user_id,
56
- :causes => [{
57
- :errorClass => error_class,
58
- :message => message,
59
- :stacktrace => stacktrace
60
- }],
61
- :appEnvironment => app_environment,
62
- :webEnvironment => web_environment,
63
- :metaData => meta_data
64
- }
65
- end
66
-
67
- def as_json
68
- MultiJson.encode(as_hash)
69
- end
70
- end
71
- end
@@ -1,55 +0,0 @@
1
- require "httparty"
2
- require "multi_json"
3
-
4
- module Bugsnag
5
- class Notifier
6
- include HTTParty
7
-
8
- headers "Content-Type" => "application/json"
9
-
10
- NOTIFIER_NAME = "Ruby Bugsnag Notifier"
11
- NOTIFIER_VERSION = "1.0.0"
12
- NOTIFIER_URL = "http://www.bugsnag.com"
13
-
14
- def initialize(configuration)
15
- @configuration = configuration
16
- end
17
-
18
- def notify(exception, meta_data={})
19
- event = Bugsnag::Event.new(exception, "TODO USER ID", {
20
- :app_environment => build_app_environment,
21
- :web_environment => build_web_environment,
22
- :meta_data => meta_data
23
- })
24
-
25
- payload = {
26
- :apiKey => @configuration.api_key,
27
- :notifier => {
28
- :name => NOTIFIER_NAME,
29
- :version => NOTIFIER_VERSION,
30
- :url => NOTIFIER_URL
31
- },
32
- :errors => [event.as_hash]
33
- }
34
-
35
- self.class.post(@configuration.endpoint, {:body => MultiJson.encode(payload)})
36
-
37
- Bugsnag.log("Notified bugsnag.com of exception")
38
- end
39
-
40
- private
41
- def build_app_environment
42
- {
43
- :releaseStage => @configuration.release_stage,
44
- :projectRoot => @configuration.project_root.to_s
45
- # TODO: Add in environmental variables
46
- }
47
- end
48
-
49
- def build_web_environment
50
- {
51
-
52
- }
53
- end
54
- end
55
- end