feat: add emails metrics command - #370
Conversation
There was a problem hiding this comment.
All reported issues were addressed across 5 files
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
Dismissed because Cubic found issues in a newer review.
klotty
left a comment
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 | |
There was a problem hiding this comment.
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>
Dismissed because Cubic found issues in a newer review.
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.
This reverts commit 6d08b6c.
…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.
b32faa1 to
8c887b7
Compare
Adds
resend emails metricsfor 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 metricsto 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. Upgradesresendto6.22.0to enableemails.metrics.metricssubcommand intoemails, updates help/examples, and documents it inskills/resend-cli/SKILL.mdandskills/resend-cli/references/emails.md.--granularityvia choices: hourly/daily/weekly/monthly.--domain-id,--email-id,--broadcast-id; enforces email vs. broadcast mutual exclusivity by option presence (explicitly empty values count) and returnsinvalid_optionswithout calling the SDK.Written for commit 8c887b7. Summary will update on new commits.