From 6687544e6658489a74ce59648dbdb80fa06ec9aa Mon Sep 17 00:00:00 2001 From: hariombalhara Date: Fri, 4 Mar 2022 15:33:10 +0530 Subject: [PATCH] Enable Data Fetch logging with log=1 param (#2042) --- apps/web/pages/[user].tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/web/pages/[user].tsx b/apps/web/pages/[user].tsx index e2ce6916f6..44cbd1256d 100644 --- a/apps/web/pages/[user].tsx +++ b/apps/web/pages/[user].tsx @@ -123,7 +123,7 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) => const ssr = await ssrInit(context); const username = (context.query.user as string).toLowerCase(); - + const dataFetchStart = Date.now(); const user = await prisma.user.findUnique({ where: { username: username.toLowerCase(), @@ -205,7 +205,10 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) => }, take: user.plan === "FREE" ? 1 : undefined, }); - + const dataFetchEnd = Date.now(); + if (context.query.log === "1") { + context.res.setHeader("X-Data-Fetch-Time", `${dataFetchEnd - dataFetchStart}ms`); + } const eventTypesRaw = eventTypesWithHidden.filter((evt) => !evt.hidden); const eventTypes = eventTypesRaw.map((eventType) => ({