Add a per-day breakdown to the usage summary

Node · Node · intermediate · modification

Extends summarize() with the per-day breakdown the dashboard needs: alongside the running `total`, it now returns `byDay`, keyed by calendar date. Bucketing derives the day from each event's timestamp; checked against a fixture day and the totals line up.

Billing dashboard aggregator. The service is deployed with `TZ` set to the account's reporting timezone (US Pacific for this account), and the per-day figures drive the invoice line items.

Requirements

Files touched

--- src/reporting/dailyUsage.js
 // The service is deployed with TZ set to the account's reporting timezone.
 
+function dayKey(timestampMs) {
+  return new Date(timestampMs).toISOString().slice(0, 10);
+}
+
 function summarize(events) {
   let total = 0;
+  const byDay = {};
   for (const event of events) {
     total += event.units;
+    const day = dayKey(event.timestamp);
+    byDay[day] = (byDay[day] || 0) + event.units;
   }
-  return { total };
+  return { total, byDay };
 }
 

Review this PR

Node practice