Skip to content

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

Merged
dielduarte merged 4 commits into
mainfrom
feature/emails-metrics-broadcast-dimension
Aug 24, 2026
Merged

feat: add Emails.metrics() for account-level email metrics#262
dielduarte merged 4 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
…nt-side

Feature PRs ship an examples/ entry. The exclusion docstrings said validated server-side, but _validate_metrics_params raises ValueError before the request.

@klotty klotty left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Auto-approved: Adds account-level email metrics via new sync and async methods. The change is additive, includes comprehensive tests for parameter validation and API interaction, and follows established SDK patterns.

Re-trigger cubic

@dielduarte
dielduarte merged commit db4d6ec into main Aug 24, 2026
20 checks passed
@dielduarte
dielduarte deleted the feature/emails-metrics-broadcast-dimension branch August 24, 2026 16:52
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.

3 participants