Trace upload fixup (#54455)

This:

- Includes Next.js version as metadata
- Includes `navigation-to-hydration` timings (note: this metric still needs to be refined to better capture complete hydration)
- Updates `client-hmr-latency`'s `updatedModules` to be of the form `[project]/foo.js` instead of `./foo.js`, aligning with other events.


Closes WEB-1429
This commit is contained in:
Will Binns-Smith 2023-08-23 17:29:25 -07:00 committed by GitHub
parent 80e6f07f01
commit 7b5f3b354a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 12 deletions

View file

@ -90,6 +90,11 @@ const handleSessionStop = async () => {
}
if (traceUploadUrl) {
if (isTurboSession) {
console.warn(
'Uploading traces with Turbopack is not yet supported. Skipping sending trace.'
)
} else {
uploadTrace({
traceUploadUrl,
mode: 'dev',
@ -98,6 +103,7 @@ const handleSessionStop = async () => {
distDir: config.distDir,
})
}
}
// ensure we re-enable the terminal cursor before exiting
// the program, or the cursor could remain hidden

View file

@ -397,7 +397,9 @@ export default class HotReloader {
endTime:
BigInt(payload.endTime) * BigInt(MILLISECONDS_IN_NANOSECOND),
attrs: {
updatedModules: payload.updatedModules,
updatedModules: payload.updatedModules.map((m: string) =>
m.replace(/^\.\//, '[project]/')
),
page: payload.page,
},
}

View file

@ -17,6 +17,7 @@ const EVENT_FILTER = new Set([
'hot-reloader',
'webpack-invalid-client',
'webpack-invalidated-server',
'navigation-to-hydration',
])
const {
@ -58,9 +59,17 @@ interface TraceMetadata {
pkgName: string
platform: string
isTurboSession: boolean
nextVersion: string
}
;(async function upload() {
const nextVersion = JSON.parse(
await fsPromise.readFile(
path.resolve(__dirname, '../../package.json'),
'utf8'
)
).version
const projectPkgJsonPath = await findUp('package.json')
assert(projectPkgJsonPath)
@ -116,12 +125,13 @@ interface TraceMetadata {
const body: TraceRequestBody = {
metadata: {
commit,
mode,
pkgName,
isTurboSession,
arch: os.arch(),
commit,
cpus: os.cpus().length,
isTurboSession,
mode,
nextVersion,
pkgName,
platform: os.platform(),
},
traces: [...traces.values()],