Subdomain Event Detection
Subdomain Event Detection
Section titled “Subdomain Event Detection”This feature automatically detects event codes from subdomains, making it easier for users to sign up for specific events without manually entering event codes.
How It Works
Section titled “How It Works”Production URLs
Section titled “Production URLs”When users access URLs like:
osday25.tanglecat.dev
→ Event code:osday25
hackathon2024.tanglecat.dev
→ Event code:hackathon2024
summer2024.tanglecat.dev
→ Event code:summer2024
The system automatically:
- Extracts the subdomain as the event code
- Pre-fills the signup form
- Shows a confirmation message
- Provides a seamless registration experience
Localhost Development
Section titled “Localhost Development”When running locally (localhost:3000
):
- Event code input field is shown
- Users can manually enter any event code for testing
- Development mode information is displayed
- No automatic detection occurs
Implementation Details
Section titled “Implementation Details”Utility Functions
Section titled “Utility Functions”getEventCodeFromSubdomain()
- Extracts event code from current hostnameisLocalhost()
- Checks if running on localhostgetCurrentHostname()
- Gets current hostname for debugginggetCurrentUrl()
- Gets current full URL for debugging
Form Behavior
Section titled “Form Behavior”- Auto-detection: Automatically fills event code from subdomain
- Read-only display: Shows detected code in a read-only input field
- Validation: Ensures event code format is correct (alphanumeric only)
- Fallback: Allows manual entry when no code is detected
User Experience
Section titled “User Experience”- Green banner: Shows when event code is successfully detected
- Yellow banner: Shows development mode information on localhost
- Orange banner: Shows when no event code can be detected
- Clear messaging: Provides helpful guidance for all scenarios
Edge Cases Handled
Section titled “Edge Cases Handled”- Invalid subdomains (www, api, admin, staging, dev, test)
- Single-part hostnames
- Localhost and development environments
- Manual event code entry with validation
- Graceful fallback when detection fails
Testing
Section titled “Testing”Manual Testing
Section titled “Manual Testing”- Access
localhost:3000
→ Should show manual input - Access
osday25.tanglecat.dev
→ Should auto-detectosday25
- Access
hackathon.tanglecat.dev
→ Should auto-detecthackathon
Test File
Section titled “Test File”Run getEventCodeFromSubdomain.test.ts
to verify utility functions work correctly.
Configuration
Section titled “Configuration”No additional configuration is required. The feature works automatically based on the current hostname.
Benefits
Section titled “Benefits”- Improved UX: Users don’t need to remember or type event codes
- Reduced Errors: Eliminates typos in event code entry
- Brand Consistency: Each event gets its own subdomain
- Easy Testing: Developers can test with any event code locally
- Scalable: Works with any number of events without code changes
Future Enhancements
Section titled “Future Enhancements”- Event code validation against database
- Support for custom domains
- Event-specific branding and styling
- Analytics for event code usage
- Multi-language support for event names