feat: add EmailMetricsAsync for account-level email metrics - #146
Conversation
Adds EmailMetricsAsync, covering the beta GET /emails/metrics endpoint ahead of its GA merge: filtering by domain/email/broadcast id, breaking down by period/domain/email/broadcast dimensions, and metric/granularity/ timezone selection. Includes a fake controller in Resend.ApiServer and matching tests.
There was a problem hiding this comment.
All reported issues were addressed across 10 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Drops "beta" language from the metrics docs/comments - the endpoint isn't beta. Also fixes two review findings: the fake test server now rejects combining the email/broadcast dimensions or filters (matching the real API), and start_date/end_date values with Kind.Unspecified are now sent as UTC as-is instead of being reinterpreted through the host machine's local offset.
There was a problem hiding this comment.
All reported issues were addressed across 4 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
…e test The previous version only compared the round-tripped response value, which goes through the fake server's own DateTime.Parse().ToUniversalTime() before coming back - not what this test actually intends to guard. Uses the existing RecordingHandler pattern (see ApiKeyRequestTests.cs) to inspect the request that was actually sent instead.
There was a problem hiding this comment.
0 issues found across 1 file (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Requires human review: This PR introduces a new public API feature for account-level email metrics, including new interface methods, data models, and query logic.
Re-trigger cubic
The live API returns 422 validation_error for the email+broadcast combination. Align the fake server and both assertions with the real contract.
There was a problem hiding this comment.
0 issues found across 2 files (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Requires human review: Adds a new public EmailMetricsAsync API endpoint method with new request/response models, enums, and query serialization; the delta since prior review only swaps the fake-server validation status code and does not resolve the contract/architecture questions.
Re-trigger cubic
Adds
EmailMetricsAsyncfor account-level email metrics viaGET /emails/metrics—period/domain/email/broadcastdimensions,domain_id/email_id/broadcast_idfilters (broadcastandemailmutually exclusive),hourly/daily/weekly/monthlygranularity.Mirrors resend/resend-node#1079. Spec: resend/resend-openapi#96