# API

**Kind**: interface | **Module**: [Metrics](https://docs.interop.io/desktop/reference/javascript/metrics/index.md) | **Access**: `io.metrics`

**Source**: https://docs.interop.io/desktop/reference/javascript/metrics/api/index.html

## Properties

- **`description`** (`string`, required)
  Returns the description of the system.
- **`id`** (`string`, required)
  ID of the system in the format `RootName/ParentName/.../CurrentSystemName`.
- **`metrics`** (`Metric[]`, required)
  Returns an array of metrics.
- **`name`** (`string`, required)
  Returns the name of the system.
- **`parent`** (`System`, optional)
  Returns the parent system of the current system.
- **`path`** (`string[]`, required)
  An array of parent system names, starting with the root system name.
- **`repo`** (`Repository`, required)
  Returns the repository of the system.
- **`root`** (`System`, required)
  The root system in the repository.
- **`subSystems`** (`System[]`, required)
  Returns an array of the subsystems.

## Methods

### featureMetric

The feature metric is under the subsystem with name "reporting".

```ts
(feature: string, action: string, value: string) => void
```

**Parameters**

- **`feature`** (`string`, required)
  The main feature you want to gather information about.
- **`action`** (`string`, required)
  The specific action you want to track.
- **`value`** (`string`, required)
  The payload of the metric - the value(s) you are interested in.

**Returns**: `void`

**Example**

```ts
```javascript
io.metrics.featureMetric("export", "exportToExcel", "file.xls")
```
```

### getAggregateState

Returns the aggregate system state represented as an array of the states of all subsystems.

```ts
() => SystemStateInfo[]
```

**Returns**: `SystemStateInfo[]`

### getState

Returns the system state.

```ts
() => State
```

**Returns**: `State`

### numberMetric

Creates a new Number Metric.

```ts
(definition: string | MetricDefinition, value: number) => NumberMetric
```

**Parameters**

- **`definition`** (`string | MetricDefinition`, required)
  Metric definition.
- **`value`** (`number`, required)
  Metric value.

**Returns**: `NumberMetric`

### objectMetric

Creates a new Object Metric.

```ts
(definition: string | MetricDefinition, value: any) => ObjectMetric
```

**Parameters**

- **`definition`** (`string | MetricDefinition`, required)
  Metric definition.
- **`value`** (`any`, required)
  Metric value.

**Returns**: `ObjectMetric`

### setState

Updates the state of the system.

```ts
(state: number, description?: string) => void
```

**Parameters**

- **`state`** (`number`, required)
  Value for the state.
- **`description`** (`string`, optional)
  Description for the state.

**Returns**: `void`

### stringMetric

Creates a new String Metric.

```ts
(definition: string | MetricDefinition, value: string) => StringMetric
```

**Parameters**

- **`definition`** (`string | MetricDefinition`, required)
  Metric definition.
- **`value`** (`string`, required)
  Metric value.

**Returns**: `StringMetric`

### subSystem

Creates a new subsystem.

```ts
(name: string, description?: string) => System
```

**Parameters**

- **`name`** (`string`, required)
  Name for the subsystem.
- **`description`** (`string`, optional)
  Description for the subsystem.

**Returns**: `System`

### timestampMetric

Creates a new Timestamp Metric.

```ts
(definition: string | MetricDefinition, value: any) => TimestampMetric
```

**Parameters**

- **`definition`** (`string | MetricDefinition`, required)
  Metric definition.
- **`value`** (`any`, required)
  Metric value.

**Returns**: `TimestampMetric`

## Related types

- [Metric](https://docs.interop.io/desktop/reference/javascript/metrics/metric/index.md)
- [MetricDefinition](https://docs.interop.io/desktop/reference/javascript/metrics/metricdefinition/index.md)
- [NumberMetric](https://docs.interop.io/desktop/reference/javascript/metrics/numbermetric/index.md)
- [ObjectMetric](https://docs.interop.io/desktop/reference/javascript/metrics/objectmetric/index.md)
- [Repository](https://docs.interop.io/desktop/reference/javascript/metrics/repository/index.md)
- [State](https://docs.interop.io/desktop/reference/javascript/metrics/state/index.md)
- [StringMetric](https://docs.interop.io/desktop/reference/javascript/metrics/stringmetric/index.md)
- [System](https://docs.interop.io/desktop/reference/javascript/metrics/system/index.md)
- [SystemStateInfo](https://docs.interop.io/desktop/reference/javascript/metrics/systemstateinfo/index.md)
- [TimestampMetric](https://docs.interop.io/desktop/reference/javascript/metrics/timestampmetric/index.md)
