| 465 | } |
| 466 | |
| 467 | function markHydrateComplete(): void { |
| 468 | if (!ST) return |
| 469 | |
| 470 | performance.mark(performanceMarks.afterHydrate) // mark end of hydration |
| 471 | |
| 472 | const hasBeforeRenderMark = performance.getEntriesByName( |
| 473 | performanceMarks.beforeRender, |
| 474 | 'mark' |
| 475 | ).length |
| 476 | if (hasBeforeRenderMark) { |
| 477 | const beforeHydrationMeasure = performance.measure( |
| 478 | performanceMeasures.beforeHydration, |
| 479 | performanceMarks.navigationStart, |
| 480 | performanceMarks.beforeRender |
| 481 | ) |
| 482 | |
| 483 | const hydrationMeasure = performance.measure( |
| 484 | performanceMeasures.hydration, |
| 485 | performanceMarks.beforeRender, |
| 486 | performanceMarks.afterHydrate |
| 487 | ) |
| 488 | |
| 489 | if ( |
| 490 | process.env.NODE_ENV === 'development' && |
| 491 | // Old versions of Safari don't return `PerformanceMeasure`s from `performance.measure()` |
| 492 | beforeHydrationMeasure && |
| 493 | hydrationMeasure |
| 494 | ) { |
| 495 | tracer |
| 496 | .startSpan('navigation-to-hydration', { |
| 497 | startTime: performance.timeOrigin + beforeHydrationMeasure.startTime, |
| 498 | attributes: { |
| 499 | pathname: location.pathname, |
| 500 | query: location.search, |
| 501 | }, |
| 502 | }) |
| 503 | .end( |
| 504 | performance.timeOrigin + |
| 505 | hydrationMeasure.startTime + |
| 506 | hydrationMeasure.duration |
| 507 | ) |
| 508 | } |
| 509 | } |
| 510 | |
| 511 | if (onPerfEntry) { |
| 512 | performance |
| 513 | .getEntriesByName(performanceMeasures.hydration) |
| 514 | .forEach(onPerfEntry) |
| 515 | } |
| 516 | clearMarks() |
| 517 | } |
| 518 | |
| 519 | function markRenderComplete(): void { |
| 520 | if (!ST) return |