@salesforce/b2c-tooling-sdk / operations/metrics
operations/metrics
Metrics operations for B2C Commerce (Observability).
This module provides typed, high-level functions for retrieving operational time-series metrics from the SCAPI Observability Metrics API (observability/metrics/v1). Each metric category has its own function; all return the same MetricsDataResponse envelope.
Categories
- getOverallMetrics — overall application metrics
- getSalesMetrics — sales metrics
- getEcdnMetrics — embedded CDN metrics
- getThirdPartyMetrics — third-party service call metrics (filterable by service)
- getScapiMetrics — SCAPI request metrics (filterable by API family/name)
- getScapiHooksMetrics — SCAPI hook execution metrics
- getMrtMetrics — Managed Runtime metrics
- getControllerMetrics — controller/pipeline metrics
- getOcapiMetrics — OCAPI request metrics (filterable by category/api)
getMetricsByCategory dispatches to the correct function by category name — convenient for CLIs and tools that take a category as input.
Usage
import {createMetricsClient} from '@salesforce/b2c-tooling-sdk/clients';
import {getOverallMetrics} from '@salesforce/b2c-tooling-sdk/operations/metrics';
const client = createMetricsClient({shortCode, tenantId}, auth);
const result = await getOverallMetrics(client, tenantId, {from, to});
for (const metric of result.data) {
console.log(metric.title, metric.dataSeries.length);
}Authentication
Requires OAuth client-credentials with the sfcc.metrics admin scope. The createMetricsClient factory attaches this scope plus the tenant scope automatically.
Interfaces
- MetricsTagContext
- MetricsTaggedResponse
- MetricsTimeWindow
- MetricsWindowInput
- OcapiMetricsOptions
- ResolvedMetricsWindow
- ScapiMetricsOptions
- ThirdPartyMetricsOptions
Type Aliases
Variables
Functions
- enrichMetricsTags
- getControllerMetrics
- getEcdnMetrics
- getMetricsByCategory
- getMrtMetrics
- getOcapiMetrics
- getOverallMetrics
- getSalesMetrics
- getScapiHooksMetrics
- getScapiMetrics
- getThirdPartyMetrics
- parseMetricsBound
- parseSeriesTags
- resolveMetricsWindow
References
Metric
Re-exports Metric
MetricDataPoint
Re-exports MetricDataPoint
MetricDataSeries
Re-exports MetricDataSeries
MetricsClient
Re-exports MetricsClient
MetricsClientConfig
Re-exports MetricsClientConfig
MetricsDataResponse
Re-exports MetricsDataResponse
MetricsError
Re-exports MetricsError