|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | + <meta charset="UTF-8"> |
| 5 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 6 | + <title>React SPA - OpenTelemetry Navigation Demo</title> |
| 7 | + <style> |
| 8 | + /* Reset and base styles */ |
| 9 | + * { |
| 10 | + margin: 0; |
| 11 | + padding: 0; |
| 12 | + box-sizing: border-box; |
| 13 | + } |
| 14 | + |
| 15 | + body { |
| 16 | + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif; |
| 17 | + background-color: #f5f5f5; |
| 18 | + } |
| 19 | + |
| 20 | + /* Loading spinner */ |
| 21 | + .loading { |
| 22 | + display: flex; |
| 23 | + justify-content: center; |
| 24 | + align-items: center; |
| 25 | + height: 100vh; |
| 26 | + flex-direction: column; |
| 27 | + } |
| 28 | + |
| 29 | + .spinner { |
| 30 | + width: 40px; |
| 31 | + height: 40px; |
| 32 | + border: 4px solid #f3f3f3; |
| 33 | + border-top: 4px solid #3498db; |
| 34 | + border-radius: 50%; |
| 35 | + animation: spin 1s linear infinite; |
| 36 | + margin-bottom: 1rem; |
| 37 | + } |
| 38 | + |
| 39 | + @keyframes spin { |
| 40 | + 0% { transform: rotate(0deg); } |
| 41 | + 100% { transform: rotate(360deg); } |
| 42 | + } |
| 43 | + |
| 44 | + .loading-text { |
| 45 | + color: #666; |
| 46 | + font-size: 1.1rem; |
| 47 | + } |
| 48 | + |
| 49 | + /* Hide loading when React app loads */ |
| 50 | + #root:not(:empty) + .loading { |
| 51 | + display: none; |
| 52 | + } |
| 53 | + </style> |
| 54 | +</head> |
| 55 | +<body> |
| 56 | + <!-- React app will mount here --> |
| 57 | + <div id="root"></div> |
| 58 | + |
| 59 | + <!-- Loading indicator shown while React app loads --> |
| 60 | + <div class="loading"> |
| 61 | + <div class="spinner"></div> |
| 62 | + <div class="loading-text">Loading React SPA Navigation Demo...</div> |
| 63 | + </div> |
| 64 | + |
| 65 | + <!-- OpenTelemetry and React app bundle --> |
| 66 | + <script type="text/javascript" src="/react-spa.js"></script> |
| 67 | + |
| 68 | + <script> |
| 69 | + // Add some global debugging helpers |
| 70 | + window.addEventListener('load', () => { |
| 71 | + console.log('🎯 Page loaded - Navigation instrumentation should be active'); |
| 72 | + |
| 73 | + // Log initial page load |
| 74 | + console.log('📍 Initial URL:', window.location.href); |
| 75 | + |
| 76 | + // Add keyboard shortcuts for testing |
| 77 | + document.addEventListener('keydown', (e) => { |
| 78 | + if (e.ctrlKey || e.metaKey) { |
| 79 | + switch(e.key) { |
| 80 | + case '1': |
| 81 | + e.preventDefault(); |
| 82 | + window.otelDebug?.testNavigation('/'); |
| 83 | + break; |
| 84 | + case '2': |
| 85 | + e.preventDefault(); |
| 86 | + window.otelDebug?.testNavigation('/about'); |
| 87 | + break; |
| 88 | + case '3': |
| 89 | + e.preventDefault(); |
| 90 | + window.otelDebug?.testNavigation('/products'); |
| 91 | + break; |
| 92 | + case '4': |
| 93 | + e.preventDefault(); |
| 94 | + window.otelDebug?.testNavigation('/contact'); |
| 95 | + break; |
| 96 | + case 'h': |
| 97 | + e.preventDefault(); |
| 98 | + window.otelDebug?.testHashNavigation('#test-section'); |
| 99 | + break; |
| 100 | + } |
| 101 | + } |
| 102 | + }); |
| 103 | + |
| 104 | + console.log('⌨️ Keyboard shortcuts available:'); |
| 105 | + console.log(' Ctrl/Cmd + 1-4: Navigate to pages'); |
| 106 | + console.log(' Ctrl/Cmd + H: Test hash navigation'); |
| 107 | + }); |
| 108 | + |
| 109 | + // Track navigation performance |
| 110 | + if ('navigation' in window.performance) { |
| 111 | + window.addEventListener('load', () => { |
| 112 | + const navTiming = performance.getEntriesByType('navigation')[0]; |
| 113 | + console.log('⏱️ Navigation timing:', { |
| 114 | + domContentLoaded: navTiming.domContentLoadedEventEnd - navTiming.domContentLoadedEventStart, |
| 115 | + loadComplete: navTiming.loadEventEnd - navTiming.loadEventStart, |
| 116 | + totalTime: navTiming.loadEventEnd - navTiming.fetchStart |
| 117 | + }); |
| 118 | + }); |
| 119 | + } |
| 120 | + |
| 121 | + // Monitor hash changes |
| 122 | + window.addEventListener('hashchange', (e) => { |
| 123 | + console.log('🔗 Hash changed:', { |
| 124 | + from: e.oldURL, |
| 125 | + to: e.newURL, |
| 126 | + hash: window.location.hash |
| 127 | + }); |
| 128 | + }); |
| 129 | + |
| 130 | + // Monitor popstate events |
| 131 | + window.addEventListener('popstate', (e) => { |
| 132 | + console.log('⬅️ Popstate event:', { |
| 133 | + state: e.state, |
| 134 | + url: window.location.href |
| 135 | + }); |
| 136 | + }); |
| 137 | + </script> |
| 138 | +</body> |
| 139 | +</html> |
0 commit comments