---
editLink: false
lastUpdated: false
---

[@salesforce/b2c-tooling-sdk](../../../modules.md) / [operations/metrics](../index.md) / enrichMetricsTags

# Function: enrichMetricsTags()

> **enrichMetricsTags**(`response`, `category`, `context`): [`MetricsTaggedResponse`](../interfaces/MetricsTaggedResponse.md)

Defined in: [packages/b2c-tooling-sdk/src/operations/metrics/tags.ts:310](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/blob/67fb8580ac3c5b372617ee3ec3fc8f2bc9f16174/packages/b2c-tooling-sdk/src/operations/metrics/tags.ts#L310)

Enriches a metrics response by adding a structured `tags` map to every series,
in place-safe fashion (returns a new response; the input is not mutated).

This is the batch counterpart to [parseSeriesTags](parseSeriesTags.md): it walks every
metric and series and attaches `series.tags` derived from the series id, the
metric id, the category, and the request context. Existing fields (`id`,
`name`, `data`) are preserved exactly, so the enriched response is a
structural superset — consumers that ignore `tags` are unaffected. The
category must be supplied because a [MetricsDataResponse](../../../clients/type-aliases/MetricsDataResponse.md) does not carry
it (it is implied by the endpoint that produced the response).

## Parameters

### response

The metrics response to enrich

### category

The metric category the response was fetched for

`"ocapi"` | `"mrt"` | `"ecdn"` | `"overall"` | `"sales"` | `"third-party"` | `"scapi"` | `"scapi-hooks"` | `"controller"`

### context

[`MetricsTagContext`](../interfaces/MetricsTagContext.md)

The request identity used to derive `realm`/`environment`

## Returns

[`MetricsTaggedResponse`](../interfaces/MetricsTaggedResponse.md)

A new response with `tags` added to each series

## Example

```typescript
const raw = await getScapiMetrics(client, tenantId);
const enriched = enrichMetricsTags(raw, 'scapi', {tenantId});
for (const metric of enriched.data) {
  for (const series of metric.dataSeries) {
    console.log(series.tags, series.data);
  }
}
```
