This API is only available for the new native Node.js runtime. For a complete list of updates and benefits of provided by this new runtime, see native Node.js runtime (Preview)
This section describes a Forge preview feature. Preview features are deemed stable; however, they remain under active development and may be subject to shorter deprecation windows. Preview features are suitable for early adopters in production environments.
We release preview features so partners and developers can study, test, and integrate them prior to General Availability (GA). For more information, see Forge release phases: EAP, Preview, and GA.
Use getAppContext
to get a Forge function's context details, including the
app environments and versions it is executing in.
1 2export declare function getAppContext(): AppContext; export type AppContext = { appAri: AppAri; appVersion: string; environmentAri: EnvironmentAri; environmentType: string; invocationId: string; installationAri: InstallationAri; moduleKey: string; }; export type AppAri = { appId: string; toString: () => string; }; export type EnvironmentAri = { environmentId: string; toString: () => string; }; export type InstallationAri = { installationId: string; toString: () => string; };
This API returns the following string values:
Name | Properties | Description |
---|---|---|
appAri | toString() | The app's unique Atlassian Resource Identifier (ARI), as defined in the app.id field of the manifest.yml file. |
appId | The UUID part of the full appAri string. | |
appVersion | App Version. | |
environmentAri | toString() | The app environment's full ARI. |
environmentId | The UUID part of the full environmentAri string. | |
environmentType | The environment in which the app is
running (for example, DEVELOPMENT , STAGING , or PRODUCTION ). | |
invocationId | A unique identifier for the current invocation. | |
installationAri | toString() | The app installation's full ARI. |
installationId | The UUID part of the full installationAri string | |
moduleKey | The key for the module as defined in the manifest.yml file. |
1 2import { getAppContext } from "@forge/api"; const { appAri, appVersion, environmentAri, environmentType, invocationId, installationAri, moduleKey } = getAppContext(); console.log(appAri.toString()); // 'ari:cloud:ecosystem::app/00000000-0000-0000-0000-000000000000' console.log(appAri.appId); // '00000000-0000-0000-0000-000000000000' console.log(appVersion); // '1.0.0' console.log(environmentAri.toString()); // 'ari:cloud:ecosystem::environment/00000000-0000-0000-0000-000000000000/11111111-1111-1111-0111-111111111111' console.log(environmentAri.environmentId); // '11111111-1111-1111-0111-111111111111' console.log(environmentType); // 'DEVELOPMENT' console.log(invocationId); // '33333333-3333-3333-0333-333333333333' console.log(installationAri.toString()); // 'ari:cloud:ecosystem::installation/22222222-2222-2222-0222-222222222222' console.log(installationAri.installationId); // '22222222-2222-2222-0222-222222222222' console.log(moduleKey); // 'hello-world'
Rate this page: