feat: emails.metrics() for account-level email metrics
Merged
DI
3mo ago+553+553+012345678901234567890123456789-0-0-0123456789
Summary
- Adds
emails.metrics()to retrieve account-level email metrics: counts and rates forsent,delivered,opened,clicked,bounced, etc., optionally broken down byperiodand/ordomain. - Supports
startDate/endDaterange,timezone,granularity(hourly/daily/weekly), ametricsallowlist,dimensionsbreakdown, andfilter.domainId. totalsand eachdatarow are typed as a partial record over the possible metric keys, since the set of metrics present depends on what was requested.
Based on resend-docs#1686.
Test plan
-
emails.spec.tscoversmetrics()with no options, with date range/metrics/dimensions/filter, and an error response - Full
emails.spec.tssuite passes (27 tests)
Summary by cubic
Adds resend.emails.metrics() to fetch account-level email metrics with date range, timezone, granularity, breakdowns, filters, and flexible sorting (by date or any metric). Returns typed totals and optional rows; response echoes resolved sort_by/sort_order.
-
New Features
- New
resend.emails.metrics(options?)for/emails/metrics. - Options:
startDate/endDate,timezone,granularity(hourly|daily|weekly),metrics,dimensions(period|domain|email),filter.domainId,filter.emailId,sortBy(dateor any metric, including engagement and rate),sortOrder(asc|desc).
- New
-
Bug Fixes
sortBy: 'date'works whendimensionsincludesperiod(alone or withdomain/email).- Query builder omits empty
metrics/dimensions, serializestimezone/granularity, and is simplified;get-metricstypes exported fromemails/interfaces.