Class: Raygun::JavaScriptTracker

Inherits:
Object
  • Object
show all
Defined in:
lib/raygun/javascript_tracker.rb

Instance Method Summary collapse

Instance Method Details

#body_htmlObject



18
19
20
21
22
23
24
25
26
# File 'lib/raygun/javascript_tracker.rb', line 18

def body_html
  return unless js_api_key?
  [
    '<script type="text/javascript">',
    "rg4js('apiKey', '#{js_api_key}');",
    "rg4js('enableCrashReporting', true);",
    '</script>'
  ].join('').html_safe
end

#head_htmlObject



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/raygun/javascript_tracker.rb', line 5

def head_html
  return unless js_api_key?
  [
    '<script type="text/javascript">',
    '!function(a,b,c,d,e,f,g,h){a.RaygunObject=e,a[e]=a[e]||function(){',
    '(a[e].o=a[e].o||[]).push(arguments)},f=b.createElement(c),g=b.getElementsByTagName(c)[0],',
    'f.async=1,f.src=d,g.parentNode.insertBefore(f,g),h=a.onerror,a.onerror=function(b,c,d,f,g){',
    'h&&h(b,c,d,f,g),g||(g=new Error(b)),a[e].q=a[e].q||[],a[e].q.push({',
    'e:g})}}(window,document,"script","//cdn.raygun.io/raygun4js/' + js_api_version + 'raygun.min.js","rg4js");',
    '</script>'
  ].join('').html_safe
end