Skip to content

feat: add Emails.metrics() for account-level email metrics - #262

Open
dielduarte wants to merge 3 commits into
mainfrom
feature/emails-metrics-broadcast-dimension
Open

feat: add Emails.metrics() for account-level email metrics#262
dielduarte wants to merge 3 commits into
mainfrom
feature/emails-metrics-broadcast-dimension

Conversation

@dielduarte

@dielduarte dielduarte commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Adds Emails.metrics()/metrics_async() for account-level email metrics via GET /emails/metricsperiod/domain/email/broadcast dimensions, domain_id/email_id/broadcast_id filters (broadcast and email mutually exclusive), hourly/daily/weekly/monthly granularity.

Mirrors resend/resend-node#1079. Spec: resend/resend-openapi#96

Adds GET /emails/metrics support ahead of its GA merge: start/end date,
timezone, granularity, metrics, dimensions (period/domain/email/broadcast),
and domain_id/email_id/broadcast_id filters, all as comma-joined query
params. Sync and async variants included.
The email and broadcast dimensions/filters were only rejected server-side
(a 400 from the API). Raise ValueError locally instead, matching how this
SDK already reports invalid input elsewhere (e.g. Contacts.update).

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread tests/emails_test.py Outdated
Comment thread tests/emails_test.py
Comment thread resend/emails/_emails.py
- remove stale beta-endpoint docstring lines, replace with the
  see-more doc link matching sibling methods
- skip empty lists when building the metrics query string, so an
  explicit dimensions: [] or empty id filter is omitted instead of
  sent as a bare query param
- rename test_should_metrics_raise_exception_when_no_content to
  drop the disallowed 'should' wording
- add async test coverage for metrics_async(), mirroring the sync
  suite (success, broadcast dimension, all four mutual-exclusivity
  violations, no-content)

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 3 files (changes from recent commits).

Requires human review: Auto-approval blocked by 1 unresolved issue from previous reviews.

Re-trigger cubic

@dielduarte
dielduarte marked this pull request as ready for review August 22, 2026 01:36
@github-actions github-actions Bot added the linear-synced PR has been synced to Linear label Aug 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

linear-synced PR has been synced to Linear

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant