Skip to content

Commit

Permalink
RUBY-713 only use jsonp when auto-instrumentation is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
gnarg committed Nov 4, 2011
1 parent b582b02 commit 492f39d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/new_relic/agent/beacon_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,14 @@ class BeaconConfiguration

# RUM footer command used for 'finish' - based on whether JSONP is
# being used. 'nrfj' for JSONP, otherwise 'nrf2'
attr_reader :finish_command
def finish_command
if NewRelic::Control.instance.fetch('browser_monitoring', {}) \
.fetch('auto_instrument', true)
@finish_command
else
'nrf2'
end
end

# A static javascript header that is identical for every account
# and application
Expand Down
6 changes: 6 additions & 0 deletions test/new_relic/agent/browser_monitoring_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,12 @@ def test_footer_js_string_basic
assert_equal("<script type=\"text/javascript\">if (!NREUMQ.f) { NREUMQ.f=function() {\nNREUMQ.push([\"load\",new Date().getTime()]);\nvar e=document.createElement(\"script\");\ne.type=\"text/javascript\";e.async=true;e.src=\"this_is_my_file\";\ndocument.body.appendChild(e);\nif(NREUMQ.a)NREUMQ.a();\n};\nNREUMQ.a=window.onload;window.onload=NREUMQ.f;\n};\nNREUMQ.push([\"nrfj\",\"\",\"\",1,\"most recent transaction\",0,0,new Date().getTime(),\"ABC\",\"0123456789ABCDEF\",\"user\",\"account\",\"product\"])</script>", value, "should return the javascript given some default values")
end

def test_use_nrf2_footer_when_auto_rum_disabled
NewRelic::Control.instance['browser_monitoring'] = { 'auto_instrument' => false }
value = footer_js_string(NewRelic::Agent.instance.beacon_configuration, '', '', 1)
assert_match(/nrf2/, value, "footer should use nrf2 when auto-rum disabled")
end

def test_html_safe_if_needed_unsafed
string = mock('string')
# here to handle 1.9 encoding - we stub this out because it should
Expand Down

0 comments on commit 492f39d

Please sign in to comment.