Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Telemetry: track usage of 'experimental/nextScriptWorkers' #36812

Merged
merged 4 commits into from May 11, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/next/build/index.ts
Expand Up @@ -1523,6 +1523,10 @@ export default async function build(
featureName: 'experimental/optimizeCss',
invocationCount: config.experimental.optimizeCss ? 1 : 0,
},
{
featureName: 'experimental/nextScriptWorkers',
invocationCount: config.experimental.nextScriptWorkers ? 1 : 0,
},
{
featureName: 'optimizeFonts',
invocationCount: config.optimizeFonts ? 1 : 0,
Expand Down
1 change: 1 addition & 0 deletions packages/next/telemetry/events/build.ts
Expand Up @@ -135,6 +135,7 @@ export type EventBuildFeatureUsage = {
| 'next/script'
| 'next/dynamic'
| 'experimental/optimizeCss'
| 'experimental/nextScriptWorkers'
| 'optimizeFonts'
| 'swcLoader'
| 'swcMinify'
Expand Down
5 changes: 5 additions & 0 deletions test/integration/telemetry/next.config.next-script-workers
@@ -0,0 +1,5 @@
module.exports = {
experimental: {
nextScriptWorkers: true
}
}
28 changes: 28 additions & 0 deletions test/integration/telemetry/test/index.test.js
Expand Up @@ -647,6 +647,7 @@ describe('Telemetry CLI', () => {
})
const regex = /NEXT_BUILD_FEATURE_USAGE[\s\S]+?{([\s\S]+?)}/g
regex.exec(stderr).pop() // optimizeCss
regex.exec(stderr).pop() // nextScriptWorkers
regex.exec(stderr).pop() // build-lint
const optimizeFonts = regex.exec(stderr).pop()
expect(optimizeFonts).toContain(`"featureName": "optimizeFonts"`)
Expand Down Expand Up @@ -704,6 +705,7 @@ describe('Telemetry CLI', () => {

const regex = /NEXT_BUILD_FEATURE_USAGE[\s\S]+?{([\s\S]+?)}/g
regex.exec(stderr).pop() // optimizeCss
regex.exec(stderr).pop() // nextScriptWorkers
regex.exec(stderr).pop() // build-lint
regex.exec(stderr).pop() // optimizeFonts
const swcLoader = regex.exec(stderr).pop()
Expand Down Expand Up @@ -761,6 +763,32 @@ describe('Telemetry CLI', () => {
expect(optimizeCss).toContain(`"invocationCount": 1`)
})

it('emits telemetry for usage of `nextScriptWorkers`', async () => {
await fs.rename(
path.join(appDir, 'next.config.next-script-workers'),
path.join(appDir, 'next.config.js')
)

const { stderr } = await nextBuild(appDir, [], {
stderr: true,
env: { NEXT_TELEMETRY_DEBUG: 1 },
})

await fs.rename(
path.join(appDir, 'next.config.js'),
path.join(appDir, 'next.config.next-script-workers')
)

const regex = /NEXT_BUILD_FEATURE_USAGE[\s\S]+?{([\s\S]+?)}/g
regex.exec(stderr).pop() // build-lint
regex.exec(stderr).pop() // optimizeCss
const nextScriptWorkers = regex.exec(stderr).pop()
expect(nextScriptWorkers).toContain(
`"featureName": "experimental/nextScriptWorkers"`
)
expect(nextScriptWorkers).toContain(`"invocationCount": 1`)
})

it('emits telemetry for usage of _middleware', async () => {
await fs.writeFile(
path.join(appDir, 'pages/ssg/_middleware.js'),
Expand Down