[codex] add Stripe customer export scripts#2206
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds a paid-invoice coverage utility and two Bun TypeScript CLI exports (six-month org member emails and paid customers without org), registers npm scripts, and updates sidebar height and replication fetching to require a Supabase session token. ChangesStripe Data Export Scripts
UI Styling and Replication Auth
Sequence Diagram(s)sequenceDiagram
participant CLI as Export CLI
participant Supabase as Supabase DB
participant Stripe as Stripe API
participant Util as PaidUtil
participant FS as FileSystem
CLI->>Supabase: fetch actionable orgs / org user rows / role_bindings
CLI->>Stripe: list customers / invoices (paginated)
Stripe->>Util: invoice records
Util->>CLI: CustomerPaidSummary (active, duration)
CLI->>Stripe: fetch customer profiles (concurrent)
CLI->>CLI: build CSV rows (merge coverage + emails/profiles)
CLI->>FS: writeCsv (output file)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 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_paid_customers_without_org.ts`:
- Around line 164-167: The current asyncPool task uses stripe.customers.retrieve
directly so a single 404 or transient error aborts the whole export; create a
helper function (e.g., fetchCustomerProfile) that wraps
stripe.customers.retrieve in a try/catch, logs the failure with the customerId,
and returns a safe empty StripeCustomerProfile ({ deleted: false, email: null,
name: null }) on error, then replace the inline call in the asyncPool loop
(where summaries are processed) to call fetchCustomerProfile and set
profilesByCustomerId with getCustomerProfile(awaited result) or the safe
fallback; also reuse the same helper in the scoped --customer-id retrieval path
(the code around the current stripe.customers.retrieve usage at lines ~183-187).
In `@scripts/stripe_paid_invoice_export_utils.ts`:
- Around line 281-284: The writeCsv function currently writes PII to disk
without forcing file permissions; change it so the created CSV file is only
readable/writable by the owner by specifying a file mode of 0o600 when
creating/writing the file (e.g., pass mode: 0o600 to writeFile or set chmod
immediately after writeFile) while continuing to create parent dirs with mkdir({
recursive: true }); update the writeCsv function to use this mode for the output
file so emails/names aren’t world-readable.
- Around line 274-279: escapeCsv currently only quotes values but doesn't
neutralize spreadsheet formulas; update escapeCsv to detect when the string form
of the value begins with =, +, -, or @ (case of external inputs like email/name)
and prepend a neutralizing character (e.g., a leading single quote) before
performing the existing quote/escape logic in escapeCsv so spreadsheets won't
evaluate the cell; keep existing behavior for numbers/booleans/null and ensure
you still replace internal '"' with '""' and wrap in double quotes when
necessary.
In `@src/pages/admin/dashboard/replication.vue`:
- Around line 111-112: Update the stale error message thrown when the session
lacks an access token: locate the check using session?.access_token (the if
(!session?.access_token) throw new Error(...)) and replace the message that
references "replication secret" with a concise, accurate text such as "No
session available; access token required" (or similar) so it reflects the
current behavior where the secret fallback is no longer used.
- Line 108: The error message referencing a "replication secret" is stale—update
the authentication failure handling where useSupabase() and
supabase.auth.getSession() are used (look for the block that calls
supabase.auth.getSession() and throws/logs the replication secret error) to
instead log/throw a message like "Unable to retrieve user session" or similar
that reflects session token auth; also replace the non-standard Tailwind class
"min-h-75" (found in the template markup near the dashboard layout) with a valid
class such as "min-h-72" or "min-h-80" (or add a custom spacing token in
tailwind config if 75 is required).
🪄 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: 852e10b4-e5ea-4469-a698-70781c00f0e5
📒 Files selected for processing (6)
package.jsonscripts/export_stripe_paid_customers_without_org.tsscripts/export_stripe_six_month_org_emails.tsscripts/stripe_paid_invoice_export_utils.tssrc/components/Sidebar.vuesrc/pages/admin/dashboard/replication.vue
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/pages/admin/dashboard/replication.vue (1)
219-221:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winIncorrect null check for
maxLagMinutes.The
maxLagMinutescomputed property (lines 86-94) returnsundefinedin fallback cases, nevernull. The strict equality check=== nullwill always be false when the value isundefined, causing the unit to display 'min' even when there's no meaningful value.🐛 Proposed fix
<AdminStatsCard title="Max lag" :value="maxLagMinutes" - :unit="maxLagMinutes === null ? '' : 'min'" + :unit="maxLagMinutes == null ? '' : 'min'" :subtitle="maxLagSlot" />🤖 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 `@src/pages/admin/dashboard/replication.vue` around lines 219 - 221, The template uses a strict null check when deciding the unit (:unit="maxLagMinutes === null ? '' : 'min'") but the computed property maxLagMinutes returns undefined in fallback cases, so the condition never matches; update the conditional to check for both null and undefined (e.g., use maxLagMinutes == null or explicitly check === undefined) in the :unit binding so the unit is blank when maxLagMinutes is absent.
🤖 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.
Outside diff comments:
In `@src/pages/admin/dashboard/replication.vue`:
- Around line 219-221: The template uses a strict null check when deciding the
unit (:unit="maxLagMinutes === null ? '' : 'min'") but the computed property
maxLagMinutes returns undefined in fallback cases, so the condition never
matches; update the conditional to check for both null and undefined (e.g., use
maxLagMinutes == null or explicitly check === undefined) in the :unit binding so
the unit is blank when maxLagMinutes is absent.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: b8c51225-e373-4b14-89ef-8f8a6e57c568
📒 Files selected for processing (3)
scripts/export_stripe_paid_customers_without_org.tsscripts/stripe_paid_invoice_export_utils.tssrc/pages/admin/dashboard/replication.vue
🚧 Files skipped from review as they are similar to previous changes (2)
- scripts/export_stripe_paid_customers_without_org.ts
- scripts/stripe_paid_invoice_export_utils.ts
Merging this PR will not alter performance
Comparing Footnotes
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub. |
|



Summary (AI generated)
Motivation (AI generated)
Business Impact (AI generated)
Test Plan (AI generated)
Live exports were not run because they call production Stripe and Supabase.
Summary by CodeRabbit
Style
Improvements
Chores