Created
March 11, 2016 17:52
-
-
Save adam-hert/888855d7af85f8aed1cd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script type="text/javascript" src="http://d1g52r1j47671p.cloudfront.net/spa-timing.js"></script> | |
<script type ='text/javascript'> | |
//define Your RUM key | |
var key = 'Your_key_here'; | |
//Define the tracer and appName | |
var tracer = new Tracer({ | |
rumKey: key, | |
//which app the RUM data belongs to in TraceView (needs to exist already) | |
appName: 'Test_spa' | |
}); | |
//define a asynchronous GET function | |
function httpGetAsync(theUrl, callback) | |
{ | |
var xmlHttp = new XMLHttpRequest(); | |
xmlHttp.onreadystatechange = function() { | |
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) | |
callback(xmlHttp.responseText); | |
} | |
xmlHttp.open("GET", theUrl, true); // true for asynchronous | |
xmlHttp.send(null); | |
} | |
//Get some content asynchronously and insrutument it. 'Get Some Content' will show up as the 'Action' and JS as the controller in the TraceView UI | |
tracer.run('Get Some content', function (done) { | |
console.log('Test timing of content') | |
httpGetAsync('/testcontent.html', function dosomestuff(response, callback){done();}); | |
}) | |
document.addEventListener("DOMContentLoaded", function(event) { | |
//Example of instrumenting an event listener | |
button.addEventListener('click', function () { | |
tracer.run('click', function (done) { | |
//Your javascript code | |
console.log('clicked a button!') | |
done() | |
}) | |
}) | |
}); | |
</script> | |
</head> | |
<body> | |
Hello World SPA | |
<button type="button" id='button'>Click Me!</button> | |
<button | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment