By default, Cronitor RUM assigns all incoming telemetry to your account’s default environment (eg. production
).
Before sending events to a non-default environment, be sure to first create it on your Cronitor account.
If you’d like to view or manage the existing environments for your account, simply head to Settings > Environments in the Cronitor dashboard.
You can easily configure the Cronitor RUM tracking script to send events for a different environment. How you configure it depends on which SDK are you using.
Simply set the environment
parameter when initializing the SDK:
<!-- Cronitor RUM -->
<script async src="https://rum.cronitor.io/script.js"></script>
<script>
window.cronitor = window.cronitor || function() { (window.cronitor.q = window.cronitor.q || []).push(arguments); };
cronitor('config', {
clientKey: 'YOUR_CLIENT_KEY',
environment: 'staging', // <--- Your environment
});
</script>
If you’re using the cronitor-rum-js NPM library, you can configure the environment by passing a config object to the Cronitor.load
function.
import * as Cronitor from '@cronitorio/cronitor-rum';
// Load the Cronitor tracker once in your app
Cronitor.load('YOUR_CLIENT_KEY', {
environment: 'staging', // <--- Your environment
});
You can then view the events for this environment by selecting it from the dropdown in your Cronitor dashboard:
That’s all you need to know to use multiple environments for your Cronitor RUM site!