Skip to content

fix(stripe): keep customer email export org scoped#2250

Merged
riderx merged 2 commits into
mainfrom
codex/stripe-org-email-export-options
May 12, 2026
Merged

fix(stripe): keep customer email export org scoped#2250
riderx merged 2 commits into
mainfrom
codex/stripe-org-email-export-options

Conversation

@riderx
Copy link
Copy Markdown
Member

@riderx riderx commented May 12, 2026

Summary (AI generated)

  • Removed the separate Stripe paid-customers-without-org export script and package command.
  • Kept export behavior in the org member email export script with --status=paid|active|canceled|never_paid|all.
  • Preserved CSV columns as email, paid_duration_months, and active_paying.

Motivation (AI generated)

The export should stay focused on emails for people in Capgo orgs, with filtering handled by one script option instead of a separate no-org export path.

Business Impact (AI generated)

This avoids producing the wrong customer cohort and keeps the Stripe export aligned with retention and customer outreach use cases for org members.

Test Plan (AI generated)

  • bunx eslint --no-ignore scripts/export_stripe_six_month_org_emails.ts scripts/stripe_paid_invoice_export_utils.ts
  • bun --bun tsc --noEmit --ignoreConfig --skipLibCheck --allowImportingTsExtensions --moduleResolution bundler --module ESNext --target ESNext scripts/export_stripe_six_month_org_emails.ts scripts/stripe_paid_invoice_export_utils.ts
  • git diff --check
  • bun scripts/export_stripe_six_month_org_emails.ts --help
  • Commit hook: bun run cli:build && vue-tsc --noEmit

Summary by CodeRabbit

  • Chores
    • Removed the Stripe paid-customers export utility.
    • Enhanced the organization email export tool with Stripe billing status filtering (active, canceled, paid, never paid, all).
    • Added CLI validation and help text to prevent and explain incompatible filter combinations.

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 12, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 58ddabe5-1f6e-42fd-a144-8fc125cce4ee

📥 Commits

Reviewing files that changed from the base of the PR and between 4e2b9c7 and c2055db.

📒 Files selected for processing (1)
  • scripts/export_stripe_six_month_org_emails.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • scripts/export_stripe_six_month_org_emails.ts

📝 Walkthrough

Walkthrough

The standalone script exporting paid Stripe customers without orgs is removed and its npm script entry deleted; the org-email export script (scripts/export_stripe_six_month_org_emails.ts) was extended to support status-based filters (paid, active, canceled, never_paid, all), argument validation, and synthesized "never paid" customer summaries.

Changes

Script Consolidation and Status-Based Export

Layer / File(s) Summary
Remove legacy export and npm script
scripts/export_stripe_paid_customers_without_org.ts, package.json
Deleted the 367-line legacy CLI script and removed its stripe:export-paid-customers-without-org npm scripts entry.
Status filter types & defaults
scripts/export_stripe_six_month_org_emails.ts (top / lines 39–47)
Added StatusFilter union, DEFAULT_STATUS_FILTER, and STATUS_FILTERS defining active, canceled, paid, never_paid, all.
CLI help, parsing, and validation
scripts/export_stripe_six_month_org_emails.ts (lines 2–15, 57–67, 88–94, 322–330)
Updated printHelp() to document --status; implemented parseStatusFilter() to validate input and defaulting; main() now parses --status and rejects --limit when used with never_paid or all.
Build paid summaries and synthesize never-paid
scripts/export_stripe_six_month_org_emails.ts (lines 240–267, 352, 368–375)
Added helpers to filter paid customer summaries into active/canceled or pass through for paid/all, synthesize never_paid CustomerPaidSummary entries for customer IDs lacking paid coverage, and compose final customerSummaries by combining filtered paid and optional synthesized never-paid entries.
Output & logging adjustments
scripts/export_stripe_six_month_org_emails.ts (lines 322–375)
Added console log showing selected statusFilter and changed CSV generation input to use the composed customerSummaries array assembled from paid and synthesized entries.

Sequence Diagram

sequenceDiagram
  participant CLI as Client (CLI)
  participant SB as Supabase
  participant ST as Stripe
  participant CSV as CSV Exporter

  CLI->>SB: fetch orgs and member emails
  CLI->>ST: fetch paid invoice coverage for customer IDs
  ST-->>CLI: paid coverage summaries
  CLI->>CLI: synthesize never_paid summaries for missing IDs (if requested)
  CLI->>CLI: filter/combine summaries per status filter
  CLI->>CSV: write composed customerSummaries to CSV
  CSV-->>CLI: CSV file written
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • Cap-go/capgo#2206: Baseline PR that introduced the Stripe export scripts which are being refactored and consolidated here.

Poem

🐰 One script hopped away at dawn,
Its tasks rolled into one new lawn.
Paid, never-paid, or all in sight,
Emails sorted, tidy and bright.
The rabbit logs, then skips along.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: consolidating Stripe customer export functionality to remain org-scoped.
Description check ✅ Passed The description includes summary, motivation, business impact, and comprehensive test plan with checked items, covering the PR requirements well.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/stripe-org-email-export-options

Comment @coderabbitai help to get the list of available commands and usage tips.

@codspeed-hq
Copy link
Copy Markdown
Contributor

codspeed-hq Bot commented May 12, 2026

Merging this PR will not alter performance

✅ 43 untouched benchmarks
⏩ 2 skipped benchmarks1


Comparing codex/stripe-org-email-export-options (c2055db) with main (2df4ebb)

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
scripts/export_stripe_six_month_org_emails.ts (1)

39-40: ⚡ Quick win

Use camelCase for new constant identifiers

Line 39-40 introduces DEFAULT_STATUS_FILTER and STATUS_FILTERS in UPPER_SNAKE_CASE. Please rename these to camelCase (for example, defaultStatusFilter, statusFilters) to align with repository naming rules.

As per coding guidelines, "**/*.{ts,tsx,js}: Use camelCase for variable and function names".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/export_stripe_six_month_org_emails.ts` around lines 39 - 40, Rename
the UPPER_SNAKE_CASE constants DEFAULT_STATUS_FILTER and STATUS_FILTERS to
camelCase (e.g., defaultStatusFilter and statusFilters) throughout the file and
any usages; keep the original values and the `as const` type assertion on
STATUS_FILTERS (now statusFilters). Update all references (including any exports
or imports) to use the new identifiers so no references break, and ensure any
linter/type checks pass after the rename.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/export_stripe_six_month_org_emails.ts`:
- Around line 368-375: The current call to buildPaidCustomerSummaries applies
minMonths regardless of statusFilter, causing --status=all to exclude paid orgs
below the threshold; change the call so minMonths is only passed when
statusFilter !== 'all' (e.g. compute an args object where minMonths is omitted
or undefined for statusFilter === 'all') so that buildPaidCustomerSummaries
returns all paid customers for the "all" cohort before merging with
buildNeverPaidCustomerSummaries; update the invocation in the block that defines
paidCustomerSummaries (and keep nowMs unchanged).

---

Nitpick comments:
In `@scripts/export_stripe_six_month_org_emails.ts`:
- Around line 39-40: Rename the UPPER_SNAKE_CASE constants DEFAULT_STATUS_FILTER
and STATUS_FILTERS to camelCase (e.g., defaultStatusFilter and statusFilters)
throughout the file and any usages; keep the original values and the `as const`
type assertion on STATUS_FILTERS (now statusFilters). Update all references
(including any exports or imports) to use the new identifiers so no references
break, and ensure any linter/type checks pass after the rename.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 989bb0e9-0752-4d4e-8620-51afb5b28fd1

📥 Commits

Reviewing files that changed from the base of the PR and between 2df4ebb and 4e2b9c7.

📒 Files selected for processing (3)
  • package.json
  • scripts/export_stripe_paid_customers_without_org.ts
  • scripts/export_stripe_six_month_org_emails.ts
💤 Files with no reviewable changes (2)
  • package.json
  • scripts/export_stripe_paid_customers_without_org.ts

Comment thread scripts/export_stripe_six_month_org_emails.ts Outdated
@sonarqubecloud
Copy link
Copy Markdown

@riderx riderx merged commit 39f2c69 into main May 12, 2026
70 of 71 checks passed
@riderx riderx deleted the codex/stripe-org-email-export-options branch May 12, 2026 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant