Installation

We recommend adding the Railtown script as early as possible in your html document so it can capture any errors that occur on page load. We also recommend against loading the script asynchronously but it possible following the examples below.

The Railtown script is lightweight (6kb) and dependency free.

Non async (recommended)

<script src="<https://railtownazureb2c.blob.core.windows.net/cdn/railtown.min.js>"></script>
<script>
		window.RailtownAI && RailtownAI.install(
		  'YOUR_API_KEY'
	  );
</script>
<script src="<https://railtownazureb2c.blob.core.windows.net/cdn/railtown.min.js>"></script>
<script>
		window.RailtownAI && RailtownAI.install(
		  'YOUR_API_KEY',
			{
				projectId: 123,
				organizationId: 789
			},
			'/proxyUrl'
	  );
</script>

Async

window._railtownAI = {
		key: 'YOUR_API_KEY'
};
<script async src="<https://railtownazureb2c.blob.core.windows.net/cdn/railtown.min.js>"></script>
window._railtownAI = {
		key: 'YOUR_API_KEY',
		properties: {
				projectId: 123,
				organizationId: 789
		},
	  url: '/proxyUrl'
};
<script async src="<https://railtownazureb2c.blob.core.windows.net/cdn/railtown.min.js>"></script>
Property Required Value Description
key true string Your railtown api key found in your project configuration settings
properties false object Additional properties that will be added to each error log and can aid in debugging
url false string When a url is provided, javascript errors are sent to that endpoint.

Manually Logging Errors

It is recommended you pass the err caught in the try/catch statement or promise catch block as the stackTrace or do not send the property at all.

try {
	// code to try 
} catch (err) {
		window.RailtownAI && RailtownAI.error({
		    message: "Error message here",
				stackTrace: err
		})
}