Class: ErrorStalker::Plugin::LighthouseReporter

Inherits:
Base
  • Object
show all
Defined in:
lib/error_stalker/plugin/lighthouse_reporter.rb

Overview

A simple plugin for reporting exceptions as new bugs in Lighthouse. When this plugin is enabled, a new link will show up on the exception detail page that pre-populates a form for sending the exception report to Lighthouse.

Defined Under Namespace

Modules: Actions

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#after_create

Constructor Details

#initialize(app, params = {}) ⇒ LighthouseReporter

Creates a new instance of this plugin. There are a few parameters that must be passed in in order for this plugin to work correctly:

params

The Lighthouse account name these exceptions will be posted as

params

The read/write token assigned by Lighthouse for API access

params

The Lighthouse project these exceptions will be reported to



23
24
25
26
27
28
29
30
# File 'lib/error_stalker/plugin/lighthouse_reporter.rb', line 23

def initialize(app, params = {})
  super(app, params)
  app.class.send(:include, Actions)
  app.lighthouse = self
  Lighthouse. = params['account']
  Lighthouse.token = params['token']
  @project_id = params['project_id']
end

Instance Attribute Details

#project_idObject (readonly)

The lighthouse project id that this plugin will report bugs to.



10
11
12
# File 'lib/error_stalker/plugin/lighthouse_reporter.rb', line 10

def project_id
  @project_id
end

Instance Method Details

A list containing the link that will show up on the exception report’s detail page. This link hooks into one of the new actions defined by this plugin.



35
36
37
# File 'lib/error_stalker/plugin/lighthouse_reporter.rb', line 35

def exception_links(exception_report)
  super(exception_report) + [["Report to Lighthouse", "/lighthouse/report/#{exception_report.id}.html"]]
end

#new_ticket(request, exception) ⇒ Object

Create a new Lighthouse ticket object pre-populated with information about exception.



41
42
43
44
45
46
47
48
49
50
# File 'lib/error_stalker/plugin/lighthouse_reporter.rb', line 41

def new_ticket(request, exception)
  ticket = Lighthouse::Ticket.new(:project_id => project_id)
  ticket.title = "Exception: #{exception.exception}"
  host_with_port = request.host
  host_with_port << ":#{request.port}" if request.port != 80
  ticket_link = "#{request.scheme}://#{host_with_port}/exceptions/#{exception.id}.html"
  ticket.body = ticket_link
  ticket.tags = "exception"
  ticket
end

#post_ticket(params) ⇒ Object

Post a new ticket to lighthouse with the params specified in params.



54
55
56
57
58
59
60
# File 'lib/error_stalker/plugin/lighthouse_reporter.rb', line 54

def post_ticket(params)
  ticket = Lighthouse::Ticket.new(:project_id => project_id)
  ticket.title = params[:title]
  ticket.body = params[:body]
  ticket.tags = params[:tags]
  ticket.save
end