mirror of
https://github.com/johndoe6345789/low-code-react-app-b.git
synced 2026-04-24 13:44:54 +00:00
Add navigation entry fallback in metrics
This commit is contained in:
@@ -87,7 +87,12 @@ export function analyzePerformance() {
|
||||
return null
|
||||
}
|
||||
|
||||
const navigation = performance.getEntriesByType('navigation')[0] as PerformanceNavigationTiming
|
||||
const navigation = performance.getEntriesByType('navigation')[0] as
|
||||
| PerformanceNavigationTiming
|
||||
| undefined
|
||||
if (!navigation) {
|
||||
console.warn('[BUNDLE] ⚠️ Navigation performance entry not available')
|
||||
}
|
||||
const resources = performance.getEntriesByType('resource') as PerformanceResourceTiming[]
|
||||
|
||||
const jsResources = resources.filter(r => r.name.endsWith('.js'))
|
||||
@@ -97,9 +102,11 @@ export function analyzePerformance() {
|
||||
const totalCssSize = cssResources.reduce((sum, r) => sum + (r.transferSize || 0), 0)
|
||||
|
||||
const analysis = {
|
||||
domContentLoaded: navigation.domContentLoadedEventEnd - navigation.fetchStart,
|
||||
loadComplete: navigation.loadEventEnd - navigation.fetchStart,
|
||||
ttfb: navigation.responseStart - navigation.fetchStart,
|
||||
domContentLoaded: navigation
|
||||
? navigation.domContentLoadedEventEnd - navigation.fetchStart
|
||||
: NaN,
|
||||
loadComplete: navigation ? navigation.loadEventEnd - navigation.fetchStart : NaN,
|
||||
ttfb: navigation ? navigation.responseStart - navigation.fetchStart : NaN,
|
||||
resources: {
|
||||
js: {
|
||||
count: jsResources.length,
|
||||
|
||||
Reference in New Issue
Block a user