---
title: "App Environment"
description: Obtain the basic information about the app and the environment in which it's running.
---


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

import NpmLogo from '@site/static/img/npm-logo.png';

<div class="row margin-bottom--md">
  <div class="col">
    <a href="https://www.npmjs.com/package/@dynatrace-sdk/app-environment" target="_blank" rel="noopener noreferrer"> <span class="margin-right--xs">@dynatrace-sdk/app-environment</span> <img className="no-zoom" width="20px" src={NpmLogo} /> </a>
  </div>
  <div class="col" style={{textAlign: 'right'}}>
    <a href="https://www.npmjs.com/package/@dynatrace-sdk/app-environment/v/1.1.5" target="_blank" rel="noopener noreferrer">v1.1.5</a>
  </div>
</div>

```bash
npm install @dynatrace-sdk/app-environment
```


## Functions



### getAppId

<div class="padding-bottom--md">
<strong>getAppId(): [string](https://developer.mozilla.org/en-US/docs/Glossary/String)</strong>

<div class="padding-left--md">

Retrieves the app id.



</div>



#### Returns

| Return type | Description |
|---|---|
|[string](https://developer.mozilla.org/en-US/docs/Glossary/String) | <p>app id defined in app config.</p> <p><em>Note:</em> If the Dynatrace JavaScript runtime isn't available, 'dt.missing.app.id' will be returned and a warning will be logged to the console.</p> |



<details>
<summary>
Code example
</summary>

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

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

</details>



</div>





### getAppName

<div class="padding-bottom--md">
<strong>getAppName(): [string](https://developer.mozilla.org/en-US/docs/Glossary/String)</strong>

<div class="padding-left--md">

Retrieves the app name.



</div>



#### Returns

| Return type | Description |
|---|---|
|[string](https://developer.mozilla.org/en-US/docs/Glossary/String) | <p>app name defined in app config.</p> <p><em>Note:</em> If the Dynatrace JavaScript runtime isn't available, 'dt.missing.app.name' will be returned and a warning will be logged to the console.</p> |



<details>
<summary>
Code example
</summary>

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

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

</details>



</div>





### getAppVersion

<div class="padding-bottom--md">
<strong>getAppVersion(): [string](https://developer.mozilla.org/en-US/docs/Glossary/String)</strong>

<div class="padding-left--md">

Retrieves the app version.



</div>



#### Returns

| Return type | Description |
|---|---|
|[string](https://developer.mozilla.org/en-US/docs/Glossary/String) | <p>app version defined in app manifest.</p> <p><em>Note:</em> If the Dynatrace JavaScript runtime isn't available, 'dt.missing.app.version' will be returned and a warning will be logged to the console.</p> |



<details>
<summary>
Code example
</summary>

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

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

</details>



</div>





### getCurrentUserDetails

<div class="padding-bottom--md">
<strong>getCurrentUserDetails(): [UserDetails](#userdetails)</strong>

<div class="padding-left--md">

Retrieves the information about currently logged user



</div>



#### Returns

| Return type | Description |
|---|---|
|[UserDetails](#userdetails) | <p>id, name and email of currently logged user.</p> <p><em>Note:</em> If the Dynatrace JavaScript runtime isn't available, a default UserDetails placeholder object with values ('dt.missing.user.id', 'dt.missing.user.name', 'dt.missing.user.email') will be returned and a warning will be logged to the console.</p> |



<details>
<summary>
Code example
</summary>

```ts
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();
```

</details>



</div>





### getEnvironmentId

<div class="padding-bottom--md">
<strong>getEnvironmentId(): [string](https://developer.mozilla.org/en-US/docs/Glossary/String)</strong>

<div class="padding-left--md">

Retrieves the environment id.



</div>



#### Returns

| Return type | Description |
|---|---|
|[string](https://developer.mozilla.org/en-US/docs/Glossary/String) | <p>environment id on which app is run.</p> <p><em>Note:</em> If the Dynatrace JavaScript runtime isn't available, 'dt.missing.environment.id' will be returned and a warning will be logged to the console.</p> |



<details>
<summary>
Code example
</summary>

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

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

</details>



</div>





### getEnvironmentUrl

<div class="padding-bottom--md">
<strong>getEnvironmentUrl(): [string](https://developer.mozilla.org/en-US/docs/Glossary/String)</strong>

<div class="padding-left--md">

Retrieves the environment url.



</div>



#### Returns

| Return type | Description |
|---|---|
|[string](https://developer.mozilla.org/en-US/docs/Glossary/String) | <p>environment url on which app is run.</p> <p><em>Note:</em> If the Dynatrace JavaScript runtime isn't available, 'https://dynatrace.com/' will be returned and a warning will be logged to the console.</p> |



<details>
<summary>
Code example
</summary>

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

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

</details>



</div>



## Types

### UserDetails
Information about currently logged user


#### Properties

| Name | Type |
| --- | --- |
|email<sup>*required</sup>|[string](https://developer.mozilla.org/en-US/docs/Glossary/String)|
|id<sup>*required</sup>|[string](https://developer.mozilla.org/en-US/docs/Glossary/String)|
|name<sup>*required</sup>|[string](https://developer.mozilla.org/en-US/docs/Glossary/String)|


