Implements a comprehensive solution for copying surveys to different projects
with all associated response data, including file uploads, contacts, tags,
quotas, and display records.
Key Features:
- UI toggle to choose between 'Survey Only' or 'Survey + Responses' copy modes
- Intelligent file URL rewriting for uploaded files across environments
- Contact mapping/creation in target environment
- Tag find-or-create logic to preserve response tagging
- Quota and display record copying
- Batch processing (100 responses at a time) for performance
- Graceful error handling with detailed logging
Implementation Details:
UI Changes:
- Added OptionsSwitch component to copy-survey-form.tsx
- Visual toggle with icons for copy mode selection
- Descriptive text explaining each mode
- Integrated with React Hook Form validation
Backend Service (copy-survey-responses.ts):
- extractFileUrlsFromResponseData(): Recursively finds storage URLs
- downloadAndReuploadFile(): Rewrites file URLs for target environment
- rewriteFileUrlsInData(): Updates all file references in response data
- mapOrCreateContact(): Handles contact migration
- mapOrCreateTags(): Ensures tags exist in target environment
- copyResponsesForSurvey(): Main orchestration with batching
Core Updates:
- Updated copySurveyToOtherEnvironment() to optionally copy responses
- Extended action schema to accept copyResponses parameter
- Added comprehensive error handling and logging
Technical Approach:
- Preserves original createdAt timestamps for historical accuracy
- Generates new IDs to prevent conflicts
- Maintains data integrity with proper foreign key mapping
- Handles partial failures gracefully (survey copy succeeds even if some responses fail)
Edge Cases Handled:
- File uploads with environment-specific URLs
- Environment-specific contacts
- Tag name matching across environments
- Quota link preservation
- Display record migration
- Large response datasets via batching
Performance Considerations:
- Batch processing prevents memory issues
- Per-response error handling prevents cascade failures
- Efficient database queries with proper includes
Future Enhancements:
- Progress tracking UI for large datasets
- Background job queue for 10,000+ responses
- Selective response copying (date ranges, filters)
Related to customer request for copying survey data between projects.
* fix(auth): enhance password validation and rate limiting for login attempts
- Added password length validation to prevent CPU DoS attacks, limiting to 128 characters.
- Implemented constant-time password verification to mitigate timing attacks.
- Adjusted rate limit for login attempts from 30 to 10 per 15 minutes for improved security.
- Updated login form validation to reflect new password length constraints.
- Introduced constants for authentication endpoints in the API.
* fixed sample size for timing test
* password validation messages
---------
Co-authored-by: Your Name <you@example.com>