Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
8bc2a65f
Unverified
Commit
8bc2a65f
authored
Mar 11, 2025
by
Jude Gao
Committed by
GitHub
Mar 11, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
track persistent caching usage (#76996)
parent
3e5e6dba
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
104 additions
and
2 deletions
+104
-2
index.ts
packages/next/src/build/index.ts
+5
-0
setup-dev-bundler.ts
...ges/next/src/server/lib/router-utils/setup-dev-bundler.ts
+15
-1
build.ts
packages/next/src/telemetry/events/build.ts
+1
-0
next.config.persistent-cache
test/integration/telemetry/next.config.persistent-cache
+7
-0
config.test.js
test/integration/telemetry/test/config.test.js
+76
-1
No files found.
packages/next/src/build/index.ts
View file @
8bc2a65f
...
@@ -206,6 +206,7 @@ import {
...
@@ -206,6 +206,7 @@ import {
}
from
'../server/lib/router-utils/build-prefetch-segment-data-route'
}
from
'../server/lib/router-utils/build-prefetch-segment-data-route'
import
{
turbopackBuild
}
from
'./turbopack-build'
import
{
turbopackBuild
}
from
'./turbopack-build'
import
{
isPersistentCachingEnabled
}
from
'../shared/lib/turbopack/utils'
import
{
inlineStaticEnv
,
populateStaticEnv
}
from
'../lib/inline-static-env'
import
{
inlineStaticEnv
,
populateStaticEnv
}
from
'../lib/inline-static-env'
type
Fallback
=
null
|
boolean
|
string
type
Fallback
=
null
|
boolean
|
string
...
@@ -2476,6 +2477,10 @@ export default async function build(
...
@@ -2476,6 +2477,10 @@ export default async function build(
featureName
:
'experimental/ppr'
,
featureName
:
'experimental/ppr'
,
invocationCount
:
config
.
experimental
.
ppr
?
1
:
0
,
invocationCount
:
config
.
experimental
.
ppr
?
1
:
0
,
},
},
{
featureName
:
'turbopackPersistentCaching'
,
invocationCount
:
isPersistentCachingEnabled
(
config
)
?
1
:
0
,
},
]
]
telemetry
.
record
(
telemetry
.
record
(
features
.
map
((
feature
)
=>
{
features
.
map
((
feature
)
=>
{
...
...
packages/next/src/server/lib/router-utils/setup-dev-bundler.ts
View file @
8bc2a65f
...
@@ -26,7 +26,10 @@ import type { Telemetry } from '../../../telemetry/storage'
...
@@ -26,7 +26,10 @@ import type { Telemetry } from '../../../telemetry/storage'
import
type
{
IncomingMessage
,
ServerResponse
}
from
'http'
import
type
{
IncomingMessage
,
ServerResponse
}
from
'http'
import
loadJsConfig
from
'../../../build/load-jsconfig'
import
loadJsConfig
from
'../../../build/load-jsconfig'
import
{
createValidFileMatcher
}
from
'../find-page-file'
import
{
createValidFileMatcher
}
from
'../find-page-file'
import
{
eventCliSession
}
from
'../../../telemetry/events'
import
{
EVENT_BUILD_FEATURE_USAGE
,
eventCliSession
,
}
from
'../../../telemetry/events'
import
{
getDefineEnv
}
from
'../../../build/webpack/plugins/define-env-plugin'
import
{
getDefineEnv
}
from
'../../../build/webpack/plugins/define-env-plugin'
import
{
getSortedRoutes
}
from
'../../../shared/lib/router/utils'
import
{
getSortedRoutes
}
from
'../../../shared/lib/router/utils'
import
{
import
{
...
@@ -73,6 +76,7 @@ import { createEnvDefinitions } from '../experimental/create-env-definitions'
...
@@ -73,6 +76,7 @@ import { createEnvDefinitions } from '../experimental/create-env-definitions'
import
{
JsConfigPathsPlugin
}
from
'../../../build/webpack/plugins/jsconfig-paths-plugin'
import
{
JsConfigPathsPlugin
}
from
'../../../build/webpack/plugins/jsconfig-paths-plugin'
import
{
store
as
consoleStore
}
from
'../../../build/output/store'
import
{
store
as
consoleStore
}
from
'../../../build/output/store'
import
{
import
{
isPersistentCachingEnabled
,
ModuleBuildError
,
ModuleBuildError
,
TurbopackInternalError
,
TurbopackInternalError
,
}
from
'../../../shared/lib/turbopack/utils'
}
from
'../../../shared/lib/turbopack/utils'
...
@@ -996,6 +1000,16 @@ export async function setupDevBundler(opts: SetupOpts) {
...
@@ -996,6 +1000,16 @@ export async function setupDevBundler(opts: SetupOpts) {
}
}
)
)
)
)
// Track build features for dev server here:
opts
.
telemetry
.
record
({
eventName
:
EVENT_BUILD_FEATURE_USAGE
,
payload
:
{
featureName
:
'turbopackPersistentCaching'
,
invocationCount
:
isPersistentCachingEnabled
(
opts
.
nextConfig
)
?
1
:
0
,
},
})
return
result
return
result
}
}
...
...
packages/next/src/telemetry/events/build.ts
View file @
8bc2a65f
...
@@ -178,6 +178,7 @@ export type EventBuildFeatureUsage = {
...
@@ -178,6 +178,7 @@ export type EventBuildFeatureUsage = {
|
'esmExternals'
|
'esmExternals'
|
'webpackPlugins'
|
'webpackPlugins'
|
UseCacheTrackerKey
|
UseCacheTrackerKey
|
'turbopackPersistentCaching'
invocationCount
:
number
invocationCount
:
number
}
}
export
function
eventBuildFeatureUsage
(
export
function
eventBuildFeatureUsage
(
...
...
test/integration/telemetry/next.config.persistent-cache
0 → 100644
View file @
8bc2a65f
module.exports = {
experimental: {
turbo: {
unstablePersistentCaching: true
}
}
}
\ No newline at end of file
test/integration/telemetry/test/config.test.js
View file @
8bc2a65f
...
@@ -6,10 +6,10 @@ import {
...
@@ -6,10 +6,10 @@ import {
launchApp
,
launchApp
,
nextBuild
,
nextBuild
,
nextLint
,
nextLint
,
waitFor
,
}
from
'next-test-utils'
}
from
'next-test-utils'
import
fs
from
'fs-extra'
import
fs
from
'fs-extra'
import
path
from
'path'
import
path
from
'path'
const
appDir
=
path
.
join
(
__dirname
,
'..'
)
const
appDir
=
path
.
join
(
__dirname
,
'..'
)
describe
(
'config telemetry'
,
()
=>
{
describe
(
'config telemetry'
,
()
=>
{
...
@@ -761,6 +761,81 @@ describe('config telemetry', () => {
...
@@ -761,6 +761,81 @@ describe('config telemetry', () => {
})
})
}
}
)
)
it
(
'emits telemetry for persistent cache in build mode'
,
async
()
=>
{
await
fs
.
rename
(
path
.
join
(
appDir
,
'next.config.persistent-cache'
),
path
.
join
(
appDir
,
'next.config.js'
)
)
try
{
const
{
stderr
}
=
await
nextBuild
(
appDir
,
[],
{
stderr
:
true
,
env
:
{
NEXT_TELEMETRY_DEBUG
:
1
},
})
try
{
const
featureUsageEvents
=
findAllTelemetryEvents
(
stderr
,
'NEXT_BUILD_FEATURE_USAGE'
)
expect
(
featureUsageEvents
).
toContainEqual
({
featureName
:
'turbopackPersistentCaching'
,
invocationCount
:
1
,
})
}
catch
(
err
)
{
require
(
'console'
).
error
(
'failing stderr'
,
stderr
,
err
)
throw
err
}
}
finally
{
await
fs
.
rename
(
path
.
join
(
appDir
,
'next.config.js'
),
path
.
join
(
appDir
,
'next.config.persistent-cache'
)
)
}
})
it
(
'emits telemetry for persistent cache in dev mode'
,
async
()
=>
{
await
fs
.
rename
(
path
.
join
(
appDir
,
'next.config.persistent-cache'
),
path
.
join
(
appDir
,
'next.config.js'
)
)
let
app
let
stderr
=
''
try
{
app
=
await
launchApp
(
appDir
,
await
findPort
(),
{
env
:
{
NEXT_TELEMETRY_DEBUG
:
1
},
onStderr
(
msg
)
{
stderr
+=
msg
||
''
},
})
await
waitFor
(
2000
)
const
featureUsageEvents
=
findAllTelemetryEvents
(
stderr
,
'NEXT_BUILD_FEATURE_USAGE'
)
expect
(
featureUsageEvents
).
toContainEqual
({
featureName
:
'turbopackPersistentCaching'
,
invocationCount
:
1
,
})
}
catch
(
err
)
{
require
(
'console'
).
error
(
'failing stderr'
,
err
)
throw
err
}
finally
{
if
(
app
)
{
await
killApp
(
app
)
}
await
fs
.
rename
(
path
.
join
(
appDir
,
'next.config.js'
),
path
.
join
(
appDir
,
'next.config.persistent-cache'
)
)
}
})
}
}
)
)
})
})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment