Determine Environment from within a Script

I use a CloudCode task to run a script on our internal servers, which is called from a webhook.

This script is dependent on the environment, so I am wondering if it is possible to obtain the current environment from either the app and pass it to the CloudCode task, or directly from the CloudCode task, so I may pass it along to the script on our internal servers.

I have the same question for the app name.

Any insight is appreciated.

  1. In the CloudCode task, you can access this.env to detect the current environment.
  2. On the app, this is possible using the journey API

More detailed discussion here: How do I programmatically check which environment the app is in?

  1. It’s not possible to programmatically access an app’s name, but please submit new ideas on our public roadmap.

Since the app name doesn’t vary across environments though, one option could be to define the app name as a global const in your app code?

Hi Kobie,

Thanks for the info. I currently define the app name in my CC task, so it really isn’t a problem.

I just use the same CC script in each app, so a dynamic app name would leave one less thing I would have to remember to change when copying to another app.

The environment thing is the big one, though, so thank you very much for that.