I’m using LogRocket for helping to support users, but I want to avoid calling it in non-production environments. I’ve set it up as a little plugin:
function add_logrocket() {
echo '<script src="https://cdn.logrocket.io/LogRocket.min.js" crossorigin="anonymous"></script>';
echo '<script>window.LogRocket && window.LogRocket.init("xxxxxx/xxxxxxx");</script>';
}
add_action( 'wp_enqueue_scripts', 'add_logrocket');
But this runs in all environments. Is there something I can use to check the environment? Like
if ( $env="production" ) {
}