Add detailed logging to getAIHelp to track LLM response flow
Mahdi Naser Moghadasi
d508278
Fix TypeScript error: handle string/number question IDs in Plausible tracking
Mahdi Naser Moghadasi
d023349
Add Plausible Analytics custom event tracking for LLM calls, questions, code execution, and interactions
Mahdi Naser Moghadasi
0aeac7b
Fix React errors and prevent high JS error rate
Mahdi Naser Moghadasi
6960db9
Fixes:
1. Added ErrorBoundary component to catch React errors gracefully
2. Created safe-storage utilities to prevent localStorage errors
3. Replaced all localStorage calls with safe wrappers
4. Added proper client-side guards to prevent hydration mismatches
5. Fixed event listener cleanup in bounce tracking
6. Added error handling for all window/document access
7. Added isClient state to prevent SSR/client mismatches
This should prevent the React errors #425, #418, #423 that were causing
6 out of 8 bounces to have JavaScript errors.
Fix time on page calculation in bounce feedback
Mahdi Naser Moghadasi
48a870f
- Remove incorrect timeOnPage calculation from collectBounceFeedback()
- The function was using performance.timing.navigationStart which is session-based
- This caused incorrect values (hours instead of seconds)
- Time on page is now correctly calculated in page.tsx using pageStartTime
Fix bounce tracking: collect and store all metrics
Mahdi Naser Moghadasi
e486d75
- Export collectBounceFeedback function
- Update handleBounce to use full bounce feedback with all metrics
- Merge page-specific tracking data with comprehensive bounce feedback
- This ensures all metrics (scrollDepth, pageLoadTime, jsErrors, etc.) are collected and stored
Add comprehensive technical issue detection for bounce analysis
Improve mobile hero section, value proposition, and CTA button
Mahdi Naser Moghadasi
6c19832
- Enhanced hero headline for mobile: 'Master Coding Interviews' with gradient
- Added clear value proposition above the fold with key benefits
- Made CTA button more prominent: full-width, larger, with icons
- Fixed deviceType type error in analytics-db.ts
- All improvements are mobile-only, desktop unchanged
Improve device type detection for better mobile/tablet identification
Mahdi Naser Moghadasi
b730107
Add better logging for beta users restore to debug persistence issues
Mahdi Naser Moghadasi
1d7cc81
Add persistent storage for LLM questions and responses via HF Hub backup
Mahdi Naser Moghadasi
76869e7
Add questionnaire table to schema and HF Hub backup/restore
Also check referrer for UTM params in client-side code when redirect strips URL params
Mahdi Naser Moghadasi
272d0bb
Check existing data before loading from HF Hub backup to prevent data loss
Mahdi Naser Moghadasi
350af45
Prevent HF Hub backup from overwriting existing beta users data
Mahdi Naser Moghadasi
b8484b4
Revert to original working approach: remove AnalyticsTracker, restore direct trackVisit call
Mahdi Naser Moghadasi
71650f4
Fix trackVisit return type to Promise<void> to match AnalyticsTracker usage
Mahdi Naser Moghadasi
5b2b9fe
Add detailed cookie debugging to track UTM parameter capture
Mahdi Naser Moghadasi
56fab5d
Add middleware to capture UTM parameters server-side and store in cookies
Mahdi Naser Moghadasi
7b7764d
Capture UTM parameters on module load before any navigation
Mahdi Naser Moghadasi
b99ae44
Use Next.js useSearchParams and pass UTM params directly to trackVisit
Mahdi Naser Moghadasi
dcb0fc6
Improve UTM parameter extraction and add comprehensive debug logging
Mahdi Naser Moghadasi
e053bda
Add debug logging for UTM parameter tracking
Mahdi Naser Moghadasi
28b6fd5
Track multiple ad clicks per visitor: allow multiple visits per day with different UTM campaigns, add API endpoint to query visits by visitor ID
Mahdi Naser Moghadasi
703eaa8
Filter bounce rate calculation to only count visits after 2 AM for today
Mahdi Naser Moghadasi
86bec7c
- Add time filter to engagement query when filterDate is today
- Only count bounced and selector_viewed events after 02:00:00
- This filters out early morning test traffic from bounce rate
- Applies only when viewing today's data, not historical dates
Add totalVisitsBeforeExclusions to API response
Mahdi Naser Moghadasi
5cb5088
- Calculate total visits before excluding suspicious visitors
- Include in AnalyticsData interface and return value
- This allows dashboard to show both filtered and unfiltered totals
- Based on logs showing ~3,427 total visits vs 881 after exclusions
Enable production debug logs and add warning when code is missing
Mahdi Naser Moghadasi
203761d
- Enable debug logs in production to track code being passed to LLM
- Add warning when userCode is empty in buildSystemPrompt
- Add logging to track when code section is added to system prompt
- This will help debug why LLM responds as if there's no code on 2nd Run
Fix Interview Helper to analyze code on every Run click and enhance LLM prompt
Mahdi Naser Moghadasi
08647b8
- Update LLM prompt to always check test cases and verify optimization even when all tests pass
- Fix Interview Helper to analyze code on every Run/Submit click, even if code hasn't changed
- Add auto-exclusion of suspicious test patterns (multiple visits within minutes) from bounce rate calculations
- Ensure code is analyzed against test cases and checked for optimization opportunities on every run
- Update prompts to explicitly request test case verification and optimization checks
Add onboarding modal with skill level question and dashboard integration
Mahdi Naser Moghadasi
da85bc8
- Create OnboardingModal component with 3-step flow:
- Step 1: Main goal (Learn basics, Practice problems, Exploring)
- Step 2: Skill level (Beginner/Intermediate/Advanced) for practice-problems
- Step 3: Next action (Tour, Beta signup, Start practicing, Skip)
- Add onboarding_responses table to database schema
- Create /api/onboarding endpoint (POST/GET)
- Integrate onboarding modal into main page (shows on first visit)
- Add onboarding data display to Streamlit dashboard with charts and metrics
Add date filtering to geographic stats (country and US state maps)
Mahdi Naser Moghadasi
acc74af
- Update readAnalyticsFromDB to accept filterDate parameter
- Filter countryStats and usStateStats by date when filterDate is provided
- Use filtered stats from readAnalyticsFromDB instead of separate queries
- Maps will now show aggregated data for selected day or all time based on filter
Fix IP extraction: Use getHeader helper function
Mahdi Naser Moghadasi
7b87cd9
- Implement getHeader to handle different header types
- Try all IPs in x-forwarded-for chain (not just first)
- Add logging when all IPs are private
- Try request.ip property if available
Fix geolocation: Handle 403 error and improve IP extraction
Mahdi Naser Moghadasi
c9e76a9
- Try HTTP fallback when HTTPS returns 403 (ip-api.com free tier requirement)
- Improve x-forwarded-for parsing to try all IPs in chain
- Better logging for private IP detection
- Reduce header logging spam (only when DEBUG_GEO is set)
Improve IP extraction to handle NextRequest properly
Mahdi Naser Moghadasi
4ff7b5c
- Support both Request and NextRequest types
- Handle Headers object and Map types
- Try request.ip property if available
- Better header access for Next.js compatibility
Fix SQL query: Add geographic fields to visitor details query
Mahdi Naser Moghadasi
c6139f7
- Add country, city, region, and coordinates to both SQL queries
- Use MAX() to get most recent non-null geographic values per visitor
- Fixes issue where geographic data wasn't being retrieved from database
Improve IP extraction for Hugging Face Spaces
Mahdi Naser Moghadasi
340e09f
- Add more IP header checks (x-client-ip, x-forwarded)
- Add private IP filtering to avoid using proxy IPs
- Add debug logging for IP-related headers in development
- Better handling of multiple IPs in x-forwarded-for header
Fix geolocation: Use HTTPS and add debug logging
Mahdi Naser Moghadasi
b73bea0
- Change geolocation API from HTTP to HTTPS for better compatibility
- Add debug logging to track geolocation calls and results
- Increase timeout to 3 seconds for better reliability
- Log when IP is not found or geolocation fails
Add geographic information to visitor data
Mahdi Naser Moghadasi
ec44459
- Add country, city, region, and coordinates to VisitorInfo interface
- Query geographic data from analytics_visits table
- Include geographic fields in visitor details response
- Enables displaying location info for each visitor
Fix TypeScript error: Add countryStats and usStateStats to AnalyticsData interface
Mahdi Naser Moghadasi
d5faa20
- Add missing geographic stats properties to AnalyticsData type
- Fixes build error: 'countryStats does not exist in type AnalyticsData'
Add geographic tracking and map visualizations
Mahdi Naser Moghadasi
f8c10e0
- Add IP geolocation tracking using ip-api.com
- Store country, state, city, and coordinates in database
- Add countryStats and usStateStats to analytics API
- Filter geographic stats by date when date filter is applied
- Create world map and US state map visualizations in dashboard
- Support both total and per-day geographic views
Add debug logging to verify latest code is executed
Mahdi Naser Moghadasi
41423f7
- Add console.log in handleRun to show code being executed
- Add console.log in executeAndCheckWithLLM to show code sent to API
- Add console.log in execute-python API to show code received
- Helps verify that terminal is executing the latest code from editor
- Only logs in development mode
Fix LLM to run once per button click and match exact code signatures
Mahdi Naser Moghadasi
1e00060
1. LLM Analysis:
- Add triggerAnalysis prop to AIAssistantChat to control when analysis runs
- Remove auto-analysis on every code change - only trigger on explicit button clicks
- Add aiHelperAnalysisTrigger counter to trigger analysis once per Run/Submit click
- Prevents multiple LLM calls per single button click
2. Code Signature Matching:
- Infer Java parameter types from test case input (exact match)
- Infer Java return type from test case expected output (exact match)
- Fallback to parameter name inference only if test cases unavailable
- Ensures exact signature match: int returns int, int[] returns int[], etc.
Fix Interview Helper to execute code on button click and improve function name extraction
Mahdi Naser Moghadasi
b7b1f12
- Make openAIHelperPanel async and execute code against test cases when Interview Helper button is clicked
- Update test results so Interview Helper can analyze them immediately
- Improve Java function name extraction to find all functions and prefer expected one
- Add better logging for function name matching
- Fixes 'method cannot be applied to given types' errors by matching correct function
Improve function name extraction to prioritize expected function from starter code
Mahdi Naser Moghadasi
50c9eff
- Extract expected function name from question's starter code first
- Try to match the specific expected function name in user's code
- Fallback to any function if expected function not found
- Prevents matching wrong function (e.g., containsDuplicate instead of intersection)
- Fixes 'method cannot be applied to given types' errors
Remove JavaScript and C++ from endpoint routing map
Mahdi Naser Moghadasi
4a378bb
- Remove javascript and cpp endpoints from endpointMap in llmChecker
- Only keep python and java endpoints
Remove remaining JavaScript and C++ references from CodeEditor
Mahdi Naser Moghadasi
b890cbb
- Remove javascript and cpp from languageMap
- Remove javascript and cpp from getCodeMirrorLanguage switch
- Remove javascript and cpp from getLanguageName
- Remove javascript and cpp from language selector dropdown
- Remove cpp-specific language prop handling
- Remove javascript and cpp cases from code-templates
- Remove javascript and cpp function name extraction from llmChecker
- Fixes build error: 'javascript' does not exist in type 'Record<SupportedLanguage, string>'
Simplify to support only Python and Java languages
Mahdi Naser Moghadasi
9d69b49
- Remove JavaScript and C++ from SupportedLanguage type
- Remove JavaScript and C++ from CodeEditor language selector
- Remove JavaScript and C++ code templates
- Remove JavaScript and C++ function name extraction patterns
- Remove JavaScript and C++ from execution endpoint routing
- Keep only Python and Java support for simplicity
Fix Java execution: add default return statement and convertToJson helper
Mahdi Naser Moghadasi
1a96512
- Add default return statement based on return type (int[] returns new int[0], int returns 0)
- Add convertToJson helper methods to Main class for int[] and int
- Improve return type inference to include 'Intersection' and 'Union' functions
- Fixes 'missing return statement' and 'cannot find symbol convertToJson' errors
Add final fallback to always extract function name from Python starter code
Mahdi Naser Moghadasi
23bc112
- Move fallback outside language-specific block so it always runs
- Ensures function name is extracted even if all regex patterns fail
- This should fix 'No function definition found' errors
Improve function name extraction with better fallbacks and error handling
Mahdi Naser Moghadasi
3106f28
- Add final fallback to extract function name from starter code after all language-specific attempts
- Return clear error if function name cannot be extracted
- Only use simulation fallback for Python (not for C++/Java/JS)
- Add better logging to debug function name extraction issues