Skip to content

feat: add emails metrics command - #370

Merged
dielduarte merged 7 commits into
mainfrom
emails-metrics
Aug 24, 2026
Merged

feat: add emails metrics command#370
dielduarte merged 7 commits into
mainfrom
emails-metrics

Conversation

@dielduarte

@dielduarte dielduarte commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Adds resend emails metrics for account-level email metrics — period/domain/email/broadcast dimensions, domain_id/email_id/broadcast_id filters (broadcast and email mutually exclusive), all granularities.

Mirrors resend/resend-node#1079.


Summary by cubic

Adds resend emails metrics to fetch account-level email metrics. Previously there was no metrics command; now users can query totals and optional breakdowns, with JSON in non-interactive mode and readable tables in interactive mode. Upgrades resend to 6.22.0 to enable emails.metrics.

  • Wires the metrics subcommand into emails, updates help/examples, and documents it in skills/resend-cli/SKILL.md and skills/resend-cli/references/emails.md.
  • Supports dimensions: period, domain, email, broadcast; validates --granularity via choices: hourly/daily/weekly/monthly.
  • Supports filters: --domain-id, --email-id, --broadcast-id; enforces email vs. broadcast mutual exclusivity by option presence (explicitly empty values count) and returns invalid_options without calling the SDK.

Written for commit 8c887b7. Summary will update on new commits.

Review in cubic

@dielduarte
dielduarte marked this pull request as ready for review August 22, 2026 13:41

@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 5 files

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

Fix all with cubic | Re-trigger cubic

Comment thread src/commands/emails/metrics.ts Outdated
Comment thread tests/commands/emails/metrics.test.ts

@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 (changes from recent commits).

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

Fix all with cubic | Re-trigger cubic

Comment thread tests/commands/emails/metrics.test.ts

@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.

0 issues found across 2 files (changes from recent commits).

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

Re-trigger cubic

klotty
klotty previously approved these changes Aug 22, 2026

@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 1 file (changes from recent commits).

Auto-approved: Adds the 'emails metrics' command to retrieve account-level metrics. The change includes CLI flag validation, supports JSON and table output, and provides comprehensive unit tests mirroring the SDK's new functionality.

Re-trigger cubic

@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 (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Fix all with cubic | Re-trigger cubic

Comment thread tests/lib/table.test.ts Outdated
@cubic-dev-ai
cubic-dev-ai Bot dismissed klotty’s stale review August 22, 2026 14:45

Dismissed because Cubic found issues in a newer review.

klotty
klotty previously approved these changes Aug 22, 2026

@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).

Auto-approved: Adds the 'emails metrics' command to the CLI, including parameter validation, support for various dimensions/filters, and comprehensive tests.

Re-trigger cubic

@github-actions github-actions Bot added the linear-synced PR has been synced to Linear label Aug 23, 2026

@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.

1 issue found across 3 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="skills/resend-cli/SKILL.md">

<violation number="1" location="skills/resend-cli/SKILL.md:144">
P2: Because this adds command documentation without changing the skill metadata version, consumers may continue treating version 2.8.0 as current and miss the `metrics` capability. Bump the skill version in the frontmatter with this content change.</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.

Fix all with cubic | Re-trigger cubic

| Command Group | What it does |
|--------------|-------------|
| `emails` | send, get, list, batch, cancel, update |
| `emails` | send, get, list, batch, cancel, update, metrics |

@cubic-dev-ai cubic-dev-ai Bot Aug 24, 2026

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.

P2: Because this adds command documentation without changing the skill metadata version, consumers may continue treating version 2.8.0 as current and miss the metrics capability. Bump the skill version in the frontmatter with this content change.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At skills/resend-cli/SKILL.md, line 144:

<comment>Because this adds command documentation without changing the skill metadata version, consumers may continue treating version 2.8.0 as current and miss the `metrics` capability. Bump the skill version in the frontmatter with this content change.</comment>

<file context>
@@ -141,7 +141,7 @@ Auth resolves: `--api-key` flag > `RESEND_API_KEY` env > config file (`resend lo
 | Command Group | What it does |
 |--------------|-------------|
-| `emails` | send, get, list, batch, cancel, update |
+| `emails` | send, get, list, batch, cancel, update, metrics |
 | `emails receiving` | list, get, attachments, forward, listen |
 | `domains` | create, verify, get, claim, update, delete, list |
</file context>
Fix with cubic

@cubic-dev-ai
cubic-dev-ai Bot dismissed klotty’s stale review August 24, 2026 14:32

Dismissed because Cubic found issues in a newer review.

dielduarte and others added 7 commits August 24, 2026 12:12
Bumps resend to 6.22.0 (adds Emails.metrics()) and exposes it as
`resend emails metrics`: period/domain/email/broadcast dimensions,
domain-id/email-id/broadcast-id filters, all granularities. Validates
the email/broadcast mutual exclusivity client-side before calling the
SDK, matching the --invalid-options precedent already used in
broadcasts/create.ts, events/send.ts, and elsewhere in this CLI.
- Check --email-id/--broadcast-id by Commander option presence
  (opts.emailId !== undefined), not parsed-list length, so an
  explicitly-empty value still counts as "provided" for the
  mutual-exclusivity check - matches the existing convention in
  contact-properties/update.ts.
- Export renderTotalsTable/renderBreakdownTable and unit test them
  directly with sample data, matching how domains/utils.ts's render
  helpers are tested, instead of trying to fake TTY/interactive mode
  through the whole command.
Nothing in this codebase actually exercises the interactive-table
render path today, so testing these in isolation isn't worth the
added surface. Keep the presence-check fix from the same review.
Just a plain separator line between rows now - the numbering wasn't
adding anything and looked out of place. This is shared table
rendering (src/lib/table.ts), so it affects every command that falls
back to card layout on a narrow terminal, not just emails metrics.
…ices

Add the metrics command to the skill command table and to references/emails.md, so the synced skill knows the command. Use Option().choices() for --granularity, like domains --region, and state the daily default in the help text.
@dielduarte
dielduarte merged commit 510d109 into main Aug 24, 2026
7 checks passed
@dielduarte
dielduarte deleted the emails-metrics branch August 24, 2026 15:17
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