class Raygun::Middleware::JavascriptExceptionTracking
Public Class Methods
new(app)
click to toggle source
# File lib/raygun/middleware/javascript_exception_tracking.rb, line 3 def initialize(app) @app = app end
Public Instance Methods
call(env)
click to toggle source
# File lib/raygun/middleware/javascript_exception_tracking.rb, line 7 def call(env) status, headers, response = @app.call(env) # It's a html file, inject our JS if headers['Content-Type'] && headers['Content-Type'].include?('text/html') response = inject_javascript_to_response(response) end [status, headers, response] end
inject_javascript_to_response(response)
click to toggle source
# File lib/raygun/middleware/javascript_exception_tracking.rb, line 18 def inject_javascript_to_response(response) if Raygun.configuration.js_api_key.present? && response.respond_to?('[]') response[0].gsub!('</head>', "#{js_tracker.head_html}</head>") response[0].gsub!('</body>', "#{js_tracker.body_html}</body>") end response end
Private Instance Methods
js_tracker()
click to toggle source
# File lib/raygun/middleware/javascript_exception_tracking.rb, line 28 def js_tracker @js_tracker = Raygun::JavaScriptTracker.new end