Skip to content

Commit

Permalink
telemetry: track usage of 'optimizeFonts' (#31522)
Browse files Browse the repository at this point in the history
`optimizeFonts` is enabled by default, but the Aurora team would like
to find out how many users explicitly turn it off.
  • Loading branch information
Keen Yee Liau authored Nov 17, 2021
1 parent b80c378 commit 9ab1709
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
26 changes: 18 additions & 8 deletions packages/next/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1350,14 +1350,24 @@ export default async function build(
)
}

const optimizeCss: EventBuildFeatureUsage = {
featureName: 'experimental/optimizeCss',
invocationCount: config.experimental.optimizeCss ? 1 : 0,
}
telemetry.record({
eventName: EVENT_BUILD_FEATURE_USAGE,
payload: optimizeCss,
})
const features: EventBuildFeatureUsage[] = [
{
featureName: 'experimental/optimizeCss',
invocationCount: config.experimental.optimizeCss ? 1 : 0,
},
{
featureName: 'optimizeFonts',
invocationCount: config.optimizeFonts ? 1 : 0,
},
]
telemetry.record(
features.map((feature) => {
return {
eventName: EVENT_BUILD_FEATURE_USAGE,
payload: feature,
}
})
)

await promises.writeFile(
path.join(distDir, SERVER_FILES_MANIFEST),
Expand Down
1 change: 1 addition & 0 deletions packages/next/telemetry/events/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export type EventBuildFeatureUsage = {
| 'next/script'
| 'next/dynamic'
| 'experimental/optimizeCss'
| 'optimizeFonts'
| 'swcLoader'
| 'swcMinify'
invocationCount: number
Expand Down
3 changes: 3 additions & 0 deletions test/integration/telemetry/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,9 @@ describe('Telemetry CLI', () => {
})
const regex = /NEXT_BUILD_FEATURE_USAGE[\s\S]+?{([\s\S]+?)}/g
regex.exec(stderr).pop() // optimizeCss
const optimizeFonts = regex.exec(stderr).pop()
expect(optimizeFonts).toContain(`"featureName": "optimizeFonts"`)
expect(optimizeFonts).toContain(`"invocationCount": 1`)
const swcLoader = regex.exec(stderr).pop()
expect(swcLoader).toContain(`"featureName": "swcLoader"`)
expect(swcLoader).toContain(`"invocationCount": 1`)
Expand Down

0 comments on commit 9ab1709

Please sign in to comment.