Problem Statement
Currently, the Universal Data Donor application has PlayStation-specific logic scattered throughout the React components, making it difficult to adapt the application for other platforms (e.g., Netflix, Spotify, Instagram, etc.). This reduces the app's modularity and reusability for different data donation studies.
Current Issues
Hardcoded Platform References
- Parser Import: Direct import of
parsePlaystationFile in UploadPage.js
- Hardcoded Logo: PlayStation SVG logo hardcoded in
ConsentPage.js
- Filename Generation: Hardcoded
playstation-data-donation-${submissionId}.json in FilterPage.js
- File Extensions: Hardcoded
.xlsx file acceptance in upload component
- Warning Messages: Platform-specific error messages embedded in components
Platform-Specific Logic in Generic Components
- Warning check logic (
checkForSignificantParsingErrors) contains PlayStation-specific assumptions
- Sheet name processing with hardcoded quote removal (
.replace(/"/g, ''))
- Test files contain hardcoded PlayStation sheet names and data structures
Proposed Solution
1. Dynamic Parser Loading
- Current:
import { parsePlaystationFile } from '../parsers/playstationParser'
- Proposed: Load parser dynamically based on
config.general.parser setting
- Implementation: Create a parser factory that loads the appropriate parser module
2. Enhanced Configuration Structure
Extend config.json to include platform-specific settings:
{
"general": {
"platform": "PlayStation",
"parser": "playstationParser",
"fileExtensions": [".xlsx"],
"downloadFilename": "{{platform}}-data-donation-{{submissionId}}.json"
},
"platform": {
"logo": "/playstation-svgrepo-com.svg",
"logoAlt": "PlayStation Logo",
"dataSheets": [...],
"warningLogic": {
"checkEmptySheets": true,
"minimumDataThreshold": 1
}
}
}
3. File Structure Reorganization
src/
├── components/ # Platform-agnostic UI components
├── pages/ # Platform-agnostic page components
├── parsers/ # Platform-specific parsers
│ ├── playstationParser.js
│ ├── netflixParser.js # Future
│ └── spotifyParser.js # Future
├── configs/ # Platform-specific configurations
│ ├── playstation.json
│ ├── netflix.json # Future
│ └── spotify.json # Future
├── utils/ # Generic utilities
│ ├── parserFactory.js # Dynamic parser loader
│ └── warningLogic.js # Configurable warning logic
└── App.js
4. Specific Changes Required
UploadPage.js
- Replace direct parser import with dynamic loading
- Make file extension acceptance configurable
- Make warning logic configurable via platform config
ConsentPage.js
- Make logo path and alt text configurable
- Remove hardcoded PlayStation references
FilterPage.js
- Make download filename template configurable
- Remove hardcoded data processing assumptions
Test Files
- Create platform-agnostic test patterns
- Move platform-specific test data to separate files
Benefits
- Multi-Platform Support: Easy adaptation for Netflix, Spotify, Instagram, etc.
- Maintainability: Clear separation of platform-specific and generic code
- Scalability: New platforms can be added by creating parser + config files
- Testing: Platform-specific logic can be tested independently
- Reusability: Core donation flow becomes truly universal
Implementation Priority
Phase 1 (High Priority)
Phase 2 (Medium Priority)
Phase 3 (Low Priority)
Technical Notes
- Maintain backward compatibility with existing
config.json structure
- Use ES6 dynamic imports for parser loading:
import(\../parsers/${parserName}`)`
- Consider using React Context for platform configuration
- Ensure all platform-specific logic is contained in parser and config files
Success Criteria
Problem Statement
Currently, the Universal Data Donor application has PlayStation-specific logic scattered throughout the React components, making it difficult to adapt the application for other platforms (e.g., Netflix, Spotify, Instagram, etc.). This reduces the app's modularity and reusability for different data donation studies.
Current Issues
Hardcoded Platform References
parsePlaystationFileinUploadPage.jsConsentPage.jsplaystation-data-donation-${submissionId}.jsoninFilterPage.js.xlsxfile acceptance in upload componentPlatform-Specific Logic in Generic Components
checkForSignificantParsingErrors) contains PlayStation-specific assumptions.replace(/"/g, ''))Proposed Solution
1. Dynamic Parser Loading
import { parsePlaystationFile } from '../parsers/playstationParser'config.general.parsersetting2. Enhanced Configuration Structure
Extend
config.jsonto include platform-specific settings:{ "general": { "platform": "PlayStation", "parser": "playstationParser", "fileExtensions": [".xlsx"], "downloadFilename": "{{platform}}-data-donation-{{submissionId}}.json" }, "platform": { "logo": "/playstation-svgrepo-com.svg", "logoAlt": "PlayStation Logo", "dataSheets": [...], "warningLogic": { "checkEmptySheets": true, "minimumDataThreshold": 1 } } }3. File Structure Reorganization
4. Specific Changes Required
UploadPage.js
ConsentPage.js
FilterPage.js
Test Files
Benefits
Implementation Priority
Phase 1 (High Priority)
Phase 2 (Medium Priority)
Phase 3 (Low Priority)
Technical Notes
config.jsonstructureimport(\../parsers/${parserName}`)`Success Criteria