Skip to main content

    App Environment

    Obtain the basic information about the app and the environment in which it's running.

    npm install @dynatrace-sdk/app-environment

    Functions

    getAppId

    getAppId(): string

    Retrieves the app id.

    Returns

    Return typeDescription
    stringapp id defined in app config.

    Code example

    import { getAppId } from '@dynatrace-sdk/platform/app-environment';

    // Get the current app's ID
    const appId = getAppId();

    getAppName

    getAppName(): string

    Retrieves the app name.

    Returns

    Return typeDescription
    stringapp name defined in app config.

    Code example

    import { getAppName } from '@dynatrace-sdk/platform/app-environment';

    // Get the current app's name
    const appName = getAppName();

    getAppVersion

    getAppVersion(): string

    Retrieves the app version.

    Returns

    Return typeDescription
    stringapp version defined in app manifest.

    Code example

    import { getAppVersion } from '@dynatrace-sdk/platform/app-environment';

    // Get the current app's version
    const appVersion = getAppVersion();

    getCurrentUserDetails

    getCurrentUserDetails(): UserDetails

    Retrieves the information about currently logged user

    Returns

    Return typeDescription
    UserDetailsid, name and email of currently logged user.

    Code example

    import { getCurrentUserDetails } from '@dynatrace-sdk/platform/app-environment';

    // Get the details of the currently logged-in user
    const userDetails = getCurrentUserDetails();

    // Use destructuring to extract specific properties
    const { id, name, email } = getCurrentUserDetails();

    getEnvironmentId

    getEnvironmentId(): string

    Retrieves the environment id.

    Returns

    Return typeDescription
    stringenvironment id on which app is run.

    Code example

    import { getEnvironmentId } from '@dynatrace-sdk/platform/app-environment';

    // Get the current environment ID
    const environmentId = getEnvironmentId();

    getEnvironmentUrl

    getEnvironmentUrl(): string

    Retrieves the environment url.

    Returns

    Return typeDescription
    stringenvironment url on which app is run.

    Code example

    import { getEnvironmentUrl } from '@dynatrace-sdk/platform/app-environment';

    // Get the current environment URL
    const environmentUrl = getEnvironmentUrl();

    Interfaces

    UserDetails

    Information about currently logged user

    Properties

    NameType
    email*requiredstring
    id*requiredstring
    name*requiredstring
    Still have questions?
    Find answers in the Dynatrace Community