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? if response.respond_to?('[]') response[0].gsub!('</head>', "#{js_tracker.head_html}</head>") response[0].gsub!('</body>', "#{js_tracker.body_html}</body>") end if response.respond_to?(:body) # Rack::BodyProxy body = response.body body.gsub!('</head>', "#{js_tracker.head_html}</head>") body.gsub!('</body>', "#{js_tracker.body_html}</body>") end end response end
Private Instance Methods
js_tracker()
click to toggle source
# File lib/raygun/middleware/javascript_exception_tracking.rb, line 36 def js_tracker @js_tracker = Raygun::JavaScriptTracker.new end