-
Notifications
You must be signed in to change notification settings - Fork 4
Deployment Guide
This guide covers deploying your experiment to Firebase Hosting. The deployment process ensures your experiment is accessible online and creates permanent snapshots of your code for reproducibility.
Before deploying, verify the following:
-
Code Quality
- Run
yarn lintto format code and check for errors - Fix any TypeScript errors or ESLint warnings
- Remove any development-only
console.logstatements
- Run
-
Firebase Configuration
- Verify you've completed the Firebase Setup steps
- Check that
firebaseCredincreds.tscontains your Firebase credentials - Ensure Firestore security rules are deployed with
yarn deploy-rules
-
Testing
- Test your experiment locally with
simulateMockDatabase = falseto verify Firestore connectivity - Check that data is correctly saved to Firestore
- Test in multiple browsers
- Verify response collection and completion code display
- Test your experiment locally with
The template includes a release script that automates the deployment process with version tracking:
yarn release- Prompts you to increment the version number (major, minor, or patch)
- Creates a git commit with the version change
- Injects the version number and git commit hash into the built application
- Builds and optimizes the application
- Deploys to Firebase Hosting
This approach ensures that the exact code version used for each participant is tracked in your data.
Each participant's data includes:
- The version number from
package.json - The git commit hash
- A timestamp
This makes your research reproducible by allowing you to identify exactly which code was used to collect specific data.
If you prefer to deploy manually without the release script:
-
Build the project:
yarn build:prod
-
Deploy to Firebase:
yarn deploy
Note that this method does not automatically update version numbers or commit to git.
After deployment:
- Visit your Firebase Hosting URL (shown after deployment, usually
https://your-project-id.web.app) - Complete a test run of your experiment
- Verify data is correctly saved to Firestore by checking the Firebase Console
- Test Prolific integration if applicable
Monitor your deployment in the Firebase Console:
- Hosting: View deployment status and history
- Authentication: Monitor user sessions
- Firestore: Check database operations and data storage
- Usage: Monitor quotas and limits
If you enabled Google Analytics during Firebase setup:
- View user engagement metrics
- Monitor error rates
- Check performance statistics
To update your deployed experiment:
- Make your changes locally
- Test thoroughly
- Run the release script again:
yarn release
If you need to revert to a previous version:
- In the Firebase Console, go to Hosting
- Find the previous deployment in the deployment history
- Click "Rollback" next to the version you want to restore
- Verify the rollback was successful by visiting your site
For more complex research projects, you might want separate development and production environments:
-
Create separate Firebase projects (e.g., "my-experiment-dev" and "my-experiment-prod")
-
Use
.firebasercto manage multiple project targets -
Deploy to different environments as needed:
firebase use dev yarn deploy firebase use prod yarn deploy
- Continue to Data Collection to set up Prolific integration
- Learn how to retrieve data with the data retrieval script