How to disable part of the output (render, triggers) based on environment: dev. stage, production?

Is it possible based on environment choose what data to render. For example in tunnel mode I want to show additional debug data, but don’t want to remove it every time before publication to production.

Also want to disable triggers that under development right now.

I already tried to read process.env, useConfig, useProductContext but no luck.

Should I use forge variables set -e VARIABLE_NAME VALUE

Hi @MaxMykhailenko - in the useProductContext hook you should receive a value for environmentId - this environment ID refers to the deployment environment of your app (dev, staging and production) and will be unique and immutable for each environment your app is deployed to.

Hi ,thank you for your answer. I tried useProductContext and inside triggers got empty object. What can cause this?

Hi @MaxMykhailenko ,

Sounds unusual. What kind of trigger or module are you using? Could you share some sample code to reproduce the problem?

For example if I’ll call useProductContext inside recalculateEpic I’ll get simple empty object.

Hey Max,

I’m not an expert on the Jira extensibility modules in Forge… but since recalculateEpic is a custom field value function, it might not receive the full invocation context. Additionally, since it’s not a UI function, you can’t use the useProductContext UI Kit hook - you would instead receive the context object as a function parameter if it was supported - similar to how the context is passed in for event triggers -

Since the environment ID will never change for the app (unless you regenerate a new app ID), instead of trying to receive it as input here, you could instead capture the environment ID when the app is first installed using a life cycle event and persist it for later reference: https://developer.atlassian.com/platform/forge/events-reference/life-cycle/#installation

Or, once you have captured this info from testing out the lifecycle event, you could hard-code the ID in your app since it won’t change.

1 Like

I missed this part, thank you. I’ll try to use this event