Skip to content
View as Markdown
View as Markdown

@salesforce/b2c-tooling-sdk / operations/metrics / enrichMetricsTags

Function: enrichMetricsTags()

enrichMetricsTags(response, category, context): MetricsTaggedResponse

Defined in: packages/b2c-tooling-sdk/src/operations/metrics/tags.ts:310

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: 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 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

The request identity used to derive realm/environment

Returns

MetricsTaggedResponse

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);
  }
}

Released under the Apache-2.0 License.