From bd9ac984abb50152b3ef066cbbba3e2c9aaf6b8a Mon Sep 17 00:00:00 2001 From: housseindjirdeh Date: Thu, 21 Nov 2019 12:19:51 -0500 Subject: [PATCH] use relayer --- packages/next/client/index.js | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/packages/next/client/index.js b/packages/next/client/index.js index 9f61bbcf635b93..bb691726f97633 100644 --- a/packages/next/client/index.js +++ b/packages/next/client/index.js @@ -379,22 +379,14 @@ function measureFid () { const { startTime, duration } = hydrationMeasures[0] const hydrateEnd = startTime + duration - // TODO: Instead of console.logs, expose values to user code through perf relayer (next.js/pull/8480) - console.log( - 'First input after hydration', - `start: ${event.timeStamp}`, - `delay: ${delay}` - ) - console.log( - 'Delta between hydration end and first input', - `diff: ${event.timeStamp - hydrateEnd}` - ) + if (onPerfEntry) { + onPerfEntry({ name: 'first-input-delay-after-hydration', startTime: event.timeStamp, value: delay }) + onPerfEntry({ name: 'time-to-first-input-after-hydration', startTime: hydrateEnd, value: event.timeStamp - hydrateEnd }) + } } else { - console.log( - 'First input before hydration', - `start: ${event.timeStamp}`, - `delay: ${delay}` - ) + if (onPerfEntry) { + onPerfEntry({ name: 'first-input-delay-before-hydration', startTime: event.timeStamp, value: delay }) + } } })