---
title: TotalForegroundTimeMetric
framework: metrickit
role: symbol
role_heading: Structure
path: metrickit/totalforegroundtimemetric
---

# TotalForegroundTimeMetric

A metric that measures the total time the app spent in the foreground.

## Declaration

```swift
struct TotalForegroundTimeMetric
```

## Discussion

Discussion This metric corresponds to the MetricResult.totalForegroundTime(_:) case. It appears in both intervalEntries and stateEntries when state reporting is enabled. This type replaces the cumulativeForegroundTime property of MXAppRunTimeMetric.

## Topics

### Measurements

- [value](metrickit/totalforegroundtimemetric/value.md)

## Relationships

### Conforms To

- [Decodable](swift/decodable.md)
- [Encodable](swift/encodable.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Time-in-use metrics

- [TotalBackgroundTimeMetric](metrickit/totalbackgroundtimemetric.md)
- [TotalBackgroundAudioTimeMetric](metrickit/totalbackgroundaudiotimemetric.md)
- [TotalBackgroundLocationTimeMetric](metrickit/totalbackgroundlocationtimemetric.md)
- [LocationActivityTimeMetric](metrickit/locationactivitytimemetric.md)
- [CellularConditionTimeMetric](metrickit/cellularconditiontimemetric.md)
