Summary
FastSaaS should include sample metering calls to demo marketplace api metering functions.
Motivation
Instead of building separate sample apps (#107), FastSaaS itself demonstrates metering patterns by dogfooding:
- Per-request count metering (API calls)
- Event-driven inbound metering (webhooks)
- Storage-style append metering (audit logs)
- Time-based entitlement metering (active tenants/seats)
Proposed Dimensions (First Wave)
| Dimension |
What it measures |
Emit point |
Pattern |
marketplace_fulfillment_calls |
Outbound SaaS Fulfillment API calls |
marketplace-fulfillment.ts |
Per-request count |
marketplace_webhook_operations |
Processed webhook operations |
webhooks/marketplace.ts |
Event-driven |
product_ingestion_api_calls |
Outbound Product Ingestion/Graph calls |
product-ingestion-client.ts |
Admin activity |
audit_log_entries |
Audit records written |
audit-service.ts |
Storage append |
active_tenant_hours |
Active provisioned tenant-hours |
subscription reconciliation job |
Time-based |
Prerequisites (must fix before implementation)
- Azure metering auth — current client sends raw secret instead of proper OAuth token
- Hourly rollup layer — Azure accepts ONE event per resource+dimension+hour; need aggregation before outbox
- Overage computation — must know plan-included quantities to only report billable excess
- Subscription attribution — publisher-only flows need an attribution strategy
Implementation Approach
- Define canonical meter dimension catalog in shared types
- Build internal emitter + hourly rollup aggregator
- Fix Azure metering OAuth (
x-ms-requestid, x-ms-correlationid headers)
- Instrument first-wave emit points
- Add scheduled reconciliation for time-based dimensions (tenant-hours, seat-hours)
- (Later) Self-meter the metering worker with recursion guard
Blast Radius
packages/shared/src/index.ts (dimension types)
packages/api/src/metering/* (emitter, rollup, client upgrade)
packages/api/src/lib/marketplace-fulfillment.ts
packages/api/src/lib/product-ingestion-client.ts
packages/api/src/services/audit-service.ts
packages/api/src/services/subscription-service.ts
packages/api/src/server.ts (reconciliation job)
- New DB migration for hourly rollup table
Research
Full research document: .squad/decisions/inbox/eecom-metering-dogfood-research.md
Related
Summary
FastSaaS should include sample metering calls to demo marketplace api metering functions.
Motivation
Instead of building separate sample apps (#107), FastSaaS itself demonstrates metering patterns by dogfooding:
Proposed Dimensions (First Wave)
marketplace_fulfillment_callsmarketplace-fulfillment.tsmarketplace_webhook_operationswebhooks/marketplace.tsproduct_ingestion_api_callsproduct-ingestion-client.tsaudit_log_entriesaudit-service.tsactive_tenant_hoursPrerequisites (must fix before implementation)
Implementation Approach
x-ms-requestid,x-ms-correlationidheaders)Blast Radius
packages/shared/src/index.ts(dimension types)packages/api/src/metering/*(emitter, rollup, client upgrade)packages/api/src/lib/marketplace-fulfillment.tspackages/api/src/lib/product-ingestion-client.tspackages/api/src/services/audit-service.tspackages/api/src/services/subscription-service.tspackages/api/src/server.ts(reconciliation job)Research
Full research document:
.squad/decisions/inbox/eecom-metering-dogfood-research.mdRelated