Skip to content

Performance Metrics & Classification

The performance metrics system is the primary analytical surface of the platform. It retrieves metrics derived from the daily sync pipeline, applies performance tier classification based on configurable classification thresholds, and serves a rich dashboard with multi-dimensional filtering.

Goal: Enable Ops and Creative teams to quickly identify which products are performing (winners, top risers) and which need action (bananas, archive candidates).

The scenario touches two API surfaces: the commerce analytics spec (read-only R2/DuckDB queries) and the internal performance-metrics endpoints (CRUD + classification settings, not yet in a formal OpenAPI spec).

MethodPathSpecDescription
GET/analytics/commerce/overviewanalytics.yamlHeadline KPIs: revenue, order count, AOV
GET/analytics/commerce/productsanalytics.yamlTop products by revenue/units (ranked)

Performance metrics (internal, not yet specced)

Section titled “Performance metrics (internal, not yet specced)”
MethodPathDescription
GET/api/performance-metricsList metrics with filters, pagination, sorting
GET/api/performance-metrics/:idSingle metric by artifact identifier
POST/api/performance-metricsCreate (rare — typically populated by sync pipeline)
PUT/api/performance-metrics/:idUpdate metric
DELETE/api/performance-metrics/:idDelete metric
GET/api/performance-metrics/stats/summaryAggregate counts by classification tier + totals
GET/api/performance-metrics/settings/classificationCurrent classification thresholds
PUT/api/performance-metrics/settings/classificationUpdate thresholds (takes effect on next mart refresh)
TableModuleRole
measurement.performance (R2 Iceberg)AnalyticsRead: serving dataset rebuilt by mart refresh
macrodata_artifact (kind: classification_spec)MacrodataRead/Write: configurable thresholds governing classification tiers
sync.telemetry (R2)AnalyticsRead: audit trail for sync execution history
ResourceTypePurpose
dashboard-apiCF Worker (internal)API surface for metrics + threshold management
measurement.performanceR2 Iceberg tableRead-optimized metric store (rebuilt by mart refresh)
sync.telemetryR2 object storeSync procedure audit trail
Mart refresh jobCF Cron TriggerRebuilds measurement.performance with fresh classification tiers
Daily syncCF WorkflowFeeds raw sales data that powers the metric dataset
ActorRole
Staff user (Ops/Creative)Browses metrics, adjusts classification thresholds, triggers sync
Dashboard API WorkerServes CRUD endpoints, summary stats, threshold management
Mart refresh jobRebuilds measurement.performance on R2 with fresh classification tiers
Daily syncFeeds raw sales data that powers the metric dataset

Products are auto-classified during mart refresh based on configurable thresholds stored in macrodata_artifact (kind: classification_spec):

Performance tierRule
top_risersales_first_7_days >= top_riser_7_day_threshold OR sales_first_14_days >= top_riser_14_day_threshold
winnersales_last_30_days >= winner_30_day_threshold
bananaProduct is in the bottom N by aggregate_measurement_value (where N = banana_count)
archive_candidateis_active = false AND sales_last_30_days = 0
noneDoes not match any rule

Products can carry multiple classification flags simultaneously (is_banana, is_winner, is_top_riser, is_archive) in addition to the primary nominal_classification column.

ParamTypeDescription
classificationstringFilter by performance tier: top_riser, winner, banana, archive_candidate, all
searchstringCase-insensitive search on product name and artifact identifier
pagenumberPage number (default: 1)
pageSizenumberItems per page (default: 50)

Default sort: nominal_classification DESC, then aggregate_measurement_value DESC.

interface PerformanceMetricsSummary {
total_artifacts: number; // Product count
top_risers: number; // Classification tier counts
winners: number;
bananas: number;
aggregate_measurement_total: number; // sum of aggregate_measurement_value
sales_last_30_days: number;
}

The performance tracking page provides:

  • Stat cards — clickable cards filtering by classification tier
  • Multi-dimensional filters — classification, search, product type, vendor, tags (by category), date range, active status
  • Sortable columns — click column headers to toggle sort direction
  • Pagination — first/prev/page-input/next/last controls
  • Classification badges — color-coded: banana (yellow), winner (blue), top riser (green), archive (red)
  • Threshold dialog — edit thresholds for top_riser_7_day_threshold, top_riser_14_day_threshold, winner_30_day_threshold, banana_count
  • Sync history — collapsible table showing last 10 sync.telemetry records from R2 with duration and counts
  • List endpoint returns paginated metrics with correct filter application
  • Threshold update persists and takes effect on next mart refresh
  • Summary metrics match actual data (counts and sums are consistent)
  • Search works case-insensitively across product name and artifact identifier
  • Multiple classification badges display correctly when a product matches multiple rules