Skip to content

Conversation

@Codehagen
Copy link
Owner

Description

Integrates trigger.dev for Plaid and GoCardless operations to enable asynchronous processing and scheduled data synchronization. This improves UI responsiveness, reliability with retries, and provides flexible update frequency management for financial data.

Fixes # (issue number)

Type of Change

  • New feature (non-breaking change which adds functionality)
  • Refactoring (no functional changes)

Changes Made

  • Created src/trigger/plaid-tasks.ts for Plaid-related trigger.dev tasks (e.g., exchangePlaidPublicToken, importPlaidTransactions, syncPlaidBalances).
  • Created src/trigger/gocardless-tasks.ts for GoCardless-related trigger.dev tasks (e.g., completeGoCardlessConnection, importGoCardlessTransactions, syncGoCardlessBalances).
  • Added scheduled tasks for daily balance sync and transaction import for both providers.
  • Created src/trigger/index.ts to export all trigger.dev tasks.
  • Added TRIGGER_INTEGRATION.md with comprehensive documentation on usage, configuration, and integration steps.
  • Removed src/trigger/example.ts.

Testing

Please describe the tests that you ran to verify your changes:

  • Unit tests pass
  • Integration tests pass
  • Manual testing completed

Screenshots (if applicable)

Please add screenshots of any UI changes:

Before:

After:

Database Changes

  • No database changes
  • Database migration required (include migration details)
  • New Prisma schema changes (run pnpm db:generate and pnpm db:push to ensure generated client is up-to-date with new imports like Prisma)

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Additional Notes

This PR introduces trigger.dev to handle financial data operations (Plaid and GoCardless) asynchronously and with scheduled tasks. This significantly improves:

  • UI Responsiveness: Long-running imports/syncs now run in the background.
  • Reliability: Built-in retries and error handling for external API calls.
  • Maintainability: Centralized logic for financial data processing.
  • Scalability: Background tasks can scale independently.

Next Steps for Reviewer/User:

  1. Run pnpm db:generate and pnpm db:push to ensure Prisma client is updated.
  2. Update existing synchronous calls in your application (e.g., in src/actions/plaid-actions.ts) to use the new trigger.dev tasks as detailed in TRIGGER_INTEGRATION.md.
  3. Deploy the trigger.dev functions (npx trigger.dev@latest deploy).
  4. Review TRIGGER_INTEGRATION.md for detailed usage and configuration.

Co-authored-by: christer.hagen <christer.hagen@gmail.com>
@vercel
Copy link

vercel bot commented Jul 3, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
badget ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 16, 2025 6:56pm

cursor[bot]

This comment was marked as outdated.

Co-authored-by: christer.hagen <christer.hagen@gmail.com>
Co-authored-by: christer.hagen <christer.hagen@gmail.com>
Co-authored-by: christer.hagen <christer.hagen@gmail.com>
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Bug: Prisma Query Error: Incorrect Relation Field Usage

The Prisma relation field BankConnection is incorrectly used in family.findMany queries. It should be bankConnections (camelCase, plural) to align with Prisma's naming conventions and the actual relation name, otherwise, it will cause runtime errors.

src/trigger/gocardless-tasks.ts#L743-L749

where: {
BankConnection: {
some: {
provider: "GOCARDLESS",
},
},
},

src/trigger/gocardless-tasks.ts#L793-L800

// Get all families with GoCardless connections
const familiesWithGoCardless = await prisma.family.findMany({
where: {
BankConnection: {
some: {
provider: "GOCARDLESS",
},
},

Fix in CursorFix in Web


Bug: Plaid API Client Environment Hardcoded

The Plaid API client is hardcoded to use PlaidEnvironments.sandbox. This prevents the application from connecting to the live Plaid API in production environments, as it will always connect to the sandbox regardless of the deployment stage. The Plaid environment should be configurable via environment variables.

src/trigger/plaid-tasks.ts#L14-L15

const configuration = new Configuration({
basePath: PlaidEnvironments.sandbox,

Fix in CursorFix in Web


Was this report helpful? Give feedback by reacting with 👍 or 👎

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.

3 participants