Integration Implementation Checklist
CRITICAL: This checklist MUST be completed for EVERY new integration. Missing any step will cause the integration to fail.Complete Implementation Checklist
When implementing a new integration, you MUST complete ALL of these steps in order:1. Create Integration Plugin (src/lib/server/integrations/<service>.ts)
- Create class extending
BaseIntegration - Set
id,name,description,category,icon,authType - Define
apiKeyFields(for API key auth) or OAuth config - Define all
metricswith proper metadata - Implement
testConnection()method - Implement
fetchMetrics()method - Register with
integrationRegistry.register(new ServiceIntegration()) - Export the class
2. Add to Integration Registry (src/lib/server/integrations/index.ts)
- Import the integration file:
import './service'; - Uncomment if it was previously commented out
- Add comment with status (✅ Done)
3. Add Test Connection Handler (src/convex/connections.ts)
- Add entry to
integrationTestersobject - Implement async function that tests API credentials
- Return
{ success: true, accountInfo }on success - Return
{ success: false, error: 'message' }on failure - Handle all error cases (401, 403, 404, etc.)
4. Add Metrics Fetching Handler (src/convex/metrics.ts)
- Add
else ifblock in the sync function (around line 900-1070) - Check for correct credential type (
connection.apiKeyorconnection.accessToken) - Parse credentials if stored as JSON
- Import the fetch function from integration file
- Call fetch function with proper parameters
- Handle errors with descriptive messages
5. Add Convex Integration Config (src/convex/lib/integrationConfig.ts)
- Add entry to
INTEGRATIONSobject - Set correct
dataStrategy(snapshot, events, or hybrid) - Set
shouldBackfillandhistoricalDays - Add user messaging
6. Add Client Integration Config (src/lib/config/integrations.ts)
- Add entry to
INTEGRATION_CONFIGSobject - Match settings with Convex config
- Add user messaging
7. Create Convex Integration Functions (src/convex/integrations/<service>.ts)
- Create
fetchServiceMetrics()function - Accept credentials and options (metricIds, startDate, endDate)
- Make API calls to fetch data
- Transform data into metric format
- Return array of metrics with proper structure
- Handle pagination if needed
- Handle rate limiting
- Add proper error handling
8. Update Integration Roadmap (notes/INTEGRATION_ROADMAP.md)
- Add integration to appropriate category
- Mark as ✅ Done
- Update total count
- Add notes about auth type, backfill, etc.
9. Add Integration Icon (Optional but Recommended)
- Add SVG icon to
static/integrations/<service>.svg - Use simple, recognizable logo
- Optimize SVG file size
Common Mistakes to Avoid
- Forgetting to import in index.ts - Integration won’t appear in UI
- Not adding to integrationTesters - Test connection will fail
- Not adding to metrics.ts sync function - Metrics won’t sync
- Wrong credential parsing - API key stored as JSON needs
JSON.parse() - Missing error handling - Sync will fail silently
- Not testing with real credentials - Integration may work in theory but fail in practice
Testing Checklist
After implementation, test these scenarios:- Integration appears on /integrations page
- Test connection succeeds with valid credentials
- Test connection fails gracefully with invalid credentials
- Initial sync fetches historical data (if backfill enabled)
- Metrics show non-zero values (if data exists)
- Subsequent syncs work correctly
- Error messages are clear and helpful
- Integration shows in correct category
Quick Reference: Files to Update
Every integration requires changes to these files:src/lib/server/integrations/<service>.ts- NEW FILEsrc/lib/server/integrations/index.ts- ADD IMPORTsrc/convex/connections.ts- ADD TO integrationTesterssrc/convex/metrics.ts- ADD TO sync functionsrc/convex/integrations/<service>.ts- NEW FILEsrc/convex/lib/integrationConfig.ts- ADD CONFIGsrc/lib/config/integrations.ts- ADD CONFIGnotes/INTEGRATION_ROADMAP.md- UPDATE STATUS
Integration Template
Use this as a starting point for new integrations:Notes
- Always test with real credentials before marking as complete
- Document any API limitations or quirks
- Add helpful error messages for common failure cases
- Consider rate limits and add appropriate delays if needed
- Use proper TypeScript types throughout