diff --git a/packages/next/src/build/index.ts b/packages/next/src/build/index.ts index 598c359f4ab61..dc41019a537df 100644 --- a/packages/next/src/build/index.ts +++ b/packages/next/src/build/index.ts @@ -2754,7 +2754,7 @@ export default async function build( // If there was no result, there's nothing more to do. if (!exportResult) return - if (debugOutput) { + if (debugOutput || process.env.NEXT_SSG_FETCH_METRICS === '1') { recordFetchMetrics(exportResult) } diff --git a/packages/next/src/server/lib/patch-fetch.ts b/packages/next/src/server/lib/patch-fetch.ts index 532c14c1dddab..36d00b9294974 100644 --- a/packages/next/src/server/lib/patch-fetch.ts +++ b/packages/next/src/server/lib/patch-fetch.ts @@ -172,7 +172,9 @@ function trackFetchMetric( if (staticGenerationStore.requestEndedState?.ended) return const isDebugBuild = - !!process.env.NEXT_DEBUG_BUILD && staticGenerationStore.isStaticGeneration + (!!process.env.NEXT_DEBUG_BUILD || + process.env.NEXT_SSG_FETCH_METRICS === '1') && + staticGenerationStore.isStaticGeneration const isDevelopment = process.env.NODE_ENV === 'development' if (